Skip to content

Commit

Permalink
[v3.1.0+1.21] re-integrates with shulker box tooltip (#79)
Browse files Browse the repository at this point in the history
* checkout shulkerboxtooltip integrations from 1.20

* re-added shulkerboxtooltip configs

* replaced `new Identifier` with `Identifier.of`

* re-registered shulkerboxtooltip entrypoint

* bump up mod version to v3.1.0+1.21
  • Loading branch information
Aton-Kish committed Jul 12, 2024
1 parent f77a031 commit 64b784a
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 12 deletions.
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ repositories {
url "https://maven.shedaniel.me/"
}

// Shulker Box Tooltip
maven {
url "https://maven.misterpemodder.com/libs-release"
}

// // Quick Shulker
// maven {
// url "https://maven.kyrptonaught.dev"
// }

// // Shulker Box Tooltip
// maven {
// url "https://maven.misterpemodder.com/libs-release"
// }
}

loom {
Expand Down Expand Up @@ -92,13 +92,13 @@ dependencies {
// Reinforced Chests
modImplementation "atonkish.reinfchest:reinforced-chests:${project.reinforced_chests_version}"

// Shulker Box Tooltip
modImplementation "com.misterpemodder:shulkerboxtooltip-fabric:${project.shulker_box_tooltip_version}"

// // Quick Shulker
// modImplementation "net.kyrptonaught:quickshulker:${project.quick_shulker_version}"
// // Quick Shulker deps
// modImplementation "net.kyrptonaught:shulkerutils:${project.shulkerutils_version}"

// // Shulker Box Tooltip
// modImplementation "com.misterpemodder:shulkerboxtooltip-fabric:${project.shulker_box_tooltip_version}"
}

processResources {
Expand Down Expand Up @@ -172,7 +172,7 @@ curseforge {
requiredDependency "fabric-api"
embeddedLibrary "cloth-config"
optionalDependency "modmenu"
// optionalDependency "shulkerboxtooltip"
optionalDependency "shulkerboxtooltip"
// optionalDependency "quick-shulker"
optionalDependency "reinforced-chests"
}
Expand All @@ -197,7 +197,7 @@ modrinth {
required.project "fabric-api"
embedded.project "cloth-config"
optional.project "modmenu"
// optional.project "shulkerboxtooltip"
optional.project "shulkerboxtooltip"
// optional.project "quickshulker"
optional.project "reinforced-chests"
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ org.gradle.parallel=true
loader_version=0.15.11

# Mod Properties
mod_version=3.0.1+1.21
mod_version=3.1.0+1.21
mod_id=reinfshulker
maven_group=atonkish.reinfshulker
archives_base_name=reinforced-shulker-boxes
Expand All @@ -18,8 +18,8 @@ org.gradle.parallel=true
fabric_version=0.100.1+1.21
reinforced_core_version=4.0.1+1.21
reinforced_chests_version=3.0.1+1.21
shulker_box_tooltip_version=5.0.3+1.21
# quick_shulker_version=1.4.0-1.20
# shulker_box_tooltip_version=4.1.0-alpha.4+1.20.6
# # Quick Shulker deps
# shulkerutils_version=1.0.4-1.19

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package atonkish.reinfshulker.integration.shulkerboxtooltip;

import com.misterpemodder.shulkerboxtooltip.api.PreviewContext;
import com.misterpemodder.shulkerboxtooltip.api.color.ColorKey;
import com.misterpemodder.shulkerboxtooltip.api.provider.BlockEntityPreviewProvider;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

import net.minecraft.block.Block;
import net.minecraft.util.DyeColor;

import atonkish.reinfcore.util.ReinforcingMaterial;
import atonkish.reinfshulker.block.ReinforcedShulkerBoxBlock;

public class ReinforcedShulkerBoxPreviewProvider extends BlockEntityPreviewProvider {
protected final int maxRowSize;
private final ReinforcingMaterial material;

public ReinforcedShulkerBoxPreviewProvider(ReinforcingMaterial material) {
super(material.getSize(), true);

int size = material.getSize();
this.maxRowSize = size <= 81 ? 9 : size / 9;

this.material = material;
}

@Override
public boolean showTooltipHints(PreviewContext context) {
return true;
}

@Override
@Environment(EnvType.CLIENT)
public ColorKey getWindowColorKey(PreviewContext context) {
DyeColor dye = ((ReinforcedShulkerBoxBlock) Block.getBlockFromItem(context.stack().getItem())).getColor();

if (dye == null)
return ColorKey.SHULKER_BOX;
return switch (dye) {
case ORANGE -> ColorKey.ORANGE_SHULKER_BOX;
case MAGENTA -> ColorKey.MAGENTA_SHULKER_BOX;
case LIGHT_BLUE -> ColorKey.LIGHT_BLUE_SHULKER_BOX;
case YELLOW -> ColorKey.YELLOW_SHULKER_BOX;
case LIME -> ColorKey.LIME_SHULKER_BOX;
case PINK -> ColorKey.PINK_SHULKER_BOX;
case GRAY -> ColorKey.GRAY_SHULKER_BOX;
case LIGHT_GRAY -> ColorKey.LIGHT_GRAY_SHULKER_BOX;
case CYAN -> ColorKey.CYAN_SHULKER_BOX;
case PURPLE -> ColorKey.PURPLE_SHULKER_BOX;
case BLUE -> ColorKey.BLUE_SHULKER_BOX;
case BROWN -> ColorKey.BROWN_SHULKER_BOX;
case GREEN -> ColorKey.GREEN_SHULKER_BOX;
case RED -> ColorKey.RED_SHULKER_BOX;
case BLACK -> ColorKey.BLACK_SHULKER_BOX;
default -> ColorKey.WHITE_SHULKER_BOX;
};
}

@Override
public int getMaxRowSize(PreviewContext context) {
return this.maxRowSize;
}

public ReinforcingMaterial getMaterial() {
return this.material;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package atonkish.reinfshulker.integration.shulkerboxtooltip;

import com.misterpemodder.shulkerboxtooltip.api.ShulkerBoxTooltipApi;
import com.misterpemodder.shulkerboxtooltip.api.provider.PreviewProvider;
import com.misterpemodder.shulkerboxtooltip.api.provider.PreviewProviderRegistry;

import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.Item;
import net.minecraft.util.Identifier;

import atonkish.reinfcore.util.ReinforcingMaterial;
import atonkish.reinfcore.util.ReinforcingMaterials;
import atonkish.reinfshulker.block.entity.ModBlockEntityType;
import atonkish.reinfshulker.item.ModItems;

public class ShulkerBoxTooltip implements ShulkerBoxTooltipApi {
private static void register(PreviewProviderRegistry registry, String namespace, String id,
PreviewProvider provider, Item... items) {
registry.register(Identifier.of(namespace, id), provider, items);
}

@Override
public void registerProviders(PreviewProviderRegistry registry) {
for (ReinforcingMaterial material : ReinforcingMaterials.MAP.values()) {
String namespace = BlockEntityType.getId(ModBlockEntityType.REINFORCED_SHULKER_BOX_MAP.get(material))
.getNamespace();
String id = material.getName() + "_shulker_box";
Item[] items = ModItems.REINFORCED_SHULKER_BOX_MAP.get(material).values().toArray(new Item[0]);
register(registry, namespace, id, new ReinforcedShulkerBoxPreviewProvider(material), items);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"reinfcore": ["atonkish.reinfshulker.ReinforcedShulkerBoxesMod"],
"reinfcore-client": ["atonkish.reinfshulker.ReinforcedShulkerBoxesClientMod"],
"reinfcore-gametest": ["atonkish.reinfshulker.gametest.ReinforcedShulkerBoxesModGameTest"],
"shulkerboxtooltip": ["atonkish.reinfshulker.integration.shulkerboxtooltip.ShulkerBoxTooltip"],
"modmenu": ["atonkish.reinfcore.integration.modmenu.ModMenu"]
},
"mixins": [
Expand Down

0 comments on commit 64b784a

Please sign in to comment.