1.19 port

This commit is contained in:
Buuz135 2022-08-20 17:36:17 +02:00
parent 465d939d60
commit 122a688dcb
31 changed files with 393 additions and 468 deletions

View File

@ -12,7 +12,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
group = 'com.buuz135' group = 'com.buuz135'
version = '1.18.2-1.0.4' version = '1.19.2-1.0.4'
java { java {
archivesBaseName = 'functionalstorage' archivesBaseName = 'functionalstorage'
@ -21,7 +21,7 @@ java {
minecraft { minecraft {
mappings channel: 'official', version: '1.18.2' mappings channel: 'official', version: '1.19.2'
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs { runs {
@ -91,17 +91,18 @@ repositories {
dependencies { dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.1.19' minecraft 'net.minecraftforge:forge:1.19.2-43.1.1'
implementation fg.deobf (project.dependencies.create('com.hrznstudio:titanium:1.18.2-3.5.6-38')) implementation fg.deobf(project.dependencies.create('com.hrznstudio:titanium:1.19.1-3.6.0-10'))
compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.7.0.180:api") compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}"))
runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.7.0.180") compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}"))
runtimeOnly fg.deobf("curse.maven:refined-storage-243076:3712882") runtimeOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}"))
implementation fg.deobf("curse.maven:the-one-probe-245211:3671753") //runtimeOnly fg.deobf("curse.maven:refined-storage-243076:3712882")
implementation fg.deobf("curse.maven:the-one-probe-245211:3927520")
//implementation fg.deobf("curse.maven:allthecompressed-514045:3723881") //implementation fg.deobf("curse.maven:allthecompressed-514045:3723881")
//runtimeOnly fg.deobf("curse.maven:create-328085:3600402") //runtimeOnly fg.deobf("curse.maven:create-328085:3600402")
//runtimeOnly fg.deobf("curse.maven:flywheel-486392:3600401") //runtimeOnly fg.deobf("curse.maven:flywheel-486392:3600401")
implementation fg.deobf("curse.maven:mekanism-268560:3810540") //implementation fg.deobf("curse.maven:mekanism-268560:3810540")
runtimeOnly fg.deobf("curse.maven:refined-pipes-370696:3816785") //runtimeOnly fg.deobf("curse.maven:refined-pipes-370696:3816785")
annotationProcessor "org.spongepowered:mixin:0.8.5:processor" annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
} }

View File

@ -1,2 +1,4 @@
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false
mc_version=1.19.2
jei_version=11.2.0.254

View File

@ -43,30 +43,28 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ColorHandlerEvent;
import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
import net.minecraftforge.client.event.RenderTooltipEvent; import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.generators.BlockModelProvider; import net.minecraftforge.client.model.generators.BlockModelProvider;
import net.minecraftforge.client.model.generators.ItemModelProvider; import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.util.NonNullLazy; import net.minecraftforge.common.util.NonNullLazy;
import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.level.BlockEvent;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.RegistryObject;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -142,12 +140,9 @@ public class FunctionalStorage extends ModuleController {
} }
} }
}).subscribe(); }).subscribe();
EventManager.modGeneric(RegistryEvent.Register.class, RecipeSerializer.class).process(register -> { EventManager.mod(FMLCommonSetupEvent.class).process(fmlCommonSetupEvent -> {
CraftingHelper.register(DrawerlessWoodIngredient.NAME, DrawerlessWoodIngredient.SERIALIZER); CraftingHelper.register(DrawerlessWoodIngredient.NAME, DrawerlessWoodIngredient.SERIALIZER);
}).subscribe(); }).subscribe();
EventManager.modGeneric(RegistryEvent.Register.class, RecipeSerializer.class)
.process(register -> ((RegistryEvent.Register) register).getRegistry()
.registerAll(FramedDrawerRecipe.SERIALIZER.setRegistryName(new ResourceLocation(MOD_ID, "framed_recipe")))).subscribe();
NBTManager.getInstance().scanTileClassForAnnotations(FramedDrawerTile.class); NBTManager.getInstance().scanTileClassForAnnotations(FramedDrawerTile.class);
NBTManager.getInstance().scanTileClassForAnnotations(CompactingFramedDrawerTile.class); NBTManager.getInstance().scanTileClassForAnnotations(CompactingFramedDrawerTile.class);
} }
@ -174,24 +169,25 @@ public class FunctionalStorage extends ModuleController {
COMPACTING_DRAWER = getRegistries().registerBlockWithTile("compacting_drawer", () -> new CompactingDrawerBlock("compacting_drawer", BlockBehaviour.Properties.copy(Blocks.STONE_BRICKS))); COMPACTING_DRAWER = getRegistries().registerBlockWithTile("compacting_drawer", () -> new CompactingDrawerBlock("compacting_drawer", BlockBehaviour.Properties.copy(Blocks.STONE_BRICKS)));
FRAMED_COMPACTING_DRAWER = getRegistries().registerBlockWithTile("compacting_framed_drawer", () -> new CompactingFramedDrawerBlock("compacting_framed_drawer")); FRAMED_COMPACTING_DRAWER = getRegistries().registerBlockWithTile("compacting_framed_drawer", () -> new CompactingFramedDrawerBlock("compacting_framed_drawer"));
DRAWER_CONTROLLER = getRegistries().registerBlockWithTile("storage_controller", DrawerControllerBlock::new); DRAWER_CONTROLLER = getRegistries().registerBlockWithTile("storage_controller", DrawerControllerBlock::new);
LINKING_TOOL = getRegistries().registerGeneric(Item.class, "linking_tool", LinkingToolItem::new); LINKING_TOOL = getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), "linking_tool", LinkingToolItem::new);
for (StorageUpgradeItem.StorageTier value : StorageUpgradeItem.StorageTier.values()) { for (StorageUpgradeItem.StorageTier value : StorageUpgradeItem.StorageTier.values()) {
STORAGE_UPGRADES.put(value, getRegistries().registerGeneric(Item.class, value.name().toLowerCase(Locale.ROOT) + (value == StorageUpgradeItem.StorageTier.IRON ? "_downgrade" : "_upgrade"), () -> new StorageUpgradeItem(value))); STORAGE_UPGRADES.put(value, getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), value.name().toLowerCase(Locale.ROOT) + (value == StorageUpgradeItem.StorageTier.IRON ? "_downgrade" : "_upgrade"), () -> new StorageUpgradeItem(value)));
} }
COLLECTOR_UPGRADE = getRegistries().registerGeneric(Item.class, "collector_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); COLLECTOR_UPGRADE = getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), "collector_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY));
PULLING_UPGRADE = getRegistries().registerGeneric(Item.class, "puller_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); PULLING_UPGRADE = getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), "puller_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY));
PUSHING_UPGRADE = getRegistries().registerGeneric(Item.class, "pusher_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); PUSHING_UPGRADE = getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), "pusher_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY));
VOID_UPGRADE = getRegistries().registerGeneric(Item.class, "void_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); VOID_UPGRADE = getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), "void_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY));
ARMORY_CABINET = getRegistries().registerBlockWithTile("armory_cabinet", ArmoryCabinetBlock::new); ARMORY_CABINET = getRegistries().registerBlockWithTile("armory_cabinet", ArmoryCabinetBlock::new);
CONFIGURATION_TOOL = getRegistries().registerGeneric(Item.class, "configuration_tool", ConfigurationToolItem::new); CONFIGURATION_TOOL = getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), "configuration_tool", ConfigurationToolItem::new);
ENDER_DRAWER = getRegistries().registerBlockWithTile("ender_drawer", EnderDrawerBlock::new); ENDER_DRAWER = getRegistries().registerBlockWithTile("ender_drawer", EnderDrawerBlock::new);
REDSTONE_UPGRADE = getRegistries().registerGeneric(Item.class, "redstone_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); REDSTONE_UPGRADE = getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), "redstone_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY));
CREATIVE_UPGRADE = getRegistries().registerGeneric(Item.class, "creative_vending_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.STORAGE) { CREATIVE_UPGRADE = getRegistries().registerGeneric(ForgeRegistries.ITEMS.getRegistryKey(), "creative_vending_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.STORAGE) {
@Override @Override
public boolean isFoil(ItemStack p_41453_) { public boolean isFoil(ItemStack p_41453_) {
return true; return true;
} }
}); });
getRegistries().registerGeneric(ForgeRegistries.RECIPE_SERIALIZERS.getRegistryKey(), "framed_recipe", () -> FramedDrawerRecipe.SERIALIZER);
} }
public enum DrawerType { public enum DrawerType {
@ -249,12 +245,12 @@ public class FunctionalStorage extends ModuleController {
registerRenderers.registerBlockEntityRenderer((BlockEntityType<? extends DrawerControllerTile>) DRAWER_CONTROLLER.getRight().get(), p -> new ControllerRenderer()); registerRenderers.registerBlockEntityRenderer((BlockEntityType<? extends DrawerControllerTile>) DRAWER_CONTROLLER.getRight().get(), p -> new ControllerRenderer());
registerRenderers.registerBlockEntityRenderer((BlockEntityType<? extends EnderDrawerTile>) ENDER_DRAWER.getRight().get(), p_173571_ -> new EnderDrawerRenderer()); registerRenderers.registerBlockEntityRenderer((BlockEntityType<? extends EnderDrawerTile>) ENDER_DRAWER.getRight().get(), p_173571_ -> new EnderDrawerRenderer());
}).subscribe(); }).subscribe();
EventManager.mod(ColorHandlerEvent.Item.class).process(item -> { EventManager.mod(RegisterColorHandlersEvent.Item.class).process(item -> {
item.getItemColors().register((stack, tint) -> { item.getItemColors().register((stack, tint) -> {
CompoundTag tag = stack.getOrCreateTag(); CompoundTag tag = stack.getOrCreateTag();
LinkingToolItem.LinkingMode linkingMode = LinkingToolItem.getLinkingMode(stack); LinkingToolItem.LinkingMode linkingMode = LinkingToolItem.getLinkingMode(stack);
LinkingToolItem.ActionMode linkingAction = LinkingToolItem.getActionMode(stack); LinkingToolItem.ActionMode linkingAction = LinkingToolItem.getActionMode(stack);
if (tint != 0 && stack.getOrCreateTag().contains(LinkingToolItem.NBT_ENDER)){ if (tint != 0 && stack.getOrCreateTag().contains(LinkingToolItem.NBT_ENDER)) {
return new Color(44, 150, 88).getRGB(); return new Color(44, 150, 88).getRGB();
} }
if (tint == 3 && tag.contains(LinkingToolItem.NBT_CONTROLLER)) { if (tint == 3 && tag.contains(LinkingToolItem.NBT_CONTROLLER)) {
@ -293,7 +289,7 @@ public class FunctionalStorage extends ModuleController {
if (itemTooltipEvent.getItemStack().is(FunctionalStorage.LINKING_TOOL.get()) && itemTooltipEvent.getItemStack().getOrCreateTag().contains(LinkingToolItem.NBT_ENDER)) { if (itemTooltipEvent.getItemStack().is(FunctionalStorage.LINKING_TOOL.get()) && itemTooltipEvent.getItemStack().getOrCreateTag().contains(LinkingToolItem.NBT_ENDER)) {
TooltipUtil.renderItems(itemTooltipEvent.getPoseStack(), EnderDrawerBlock.getFrequencyDisplay(itemTooltipEvent.getItemStack().getOrCreateTag().getString(LinkingToolItem.NBT_ENDER)), itemTooltipEvent.getX() + 14, itemTooltipEvent.getY() + 11); TooltipUtil.renderItems(itemTooltipEvent.getPoseStack(), EnderDrawerBlock.getFrequencyDisplay(itemTooltipEvent.getItemStack().getOrCreateTag().getString(LinkingToolItem.NBT_ENDER)), itemTooltipEvent.getX() + 14, itemTooltipEvent.getY() + 11);
} }
itemTooltipEvent.getItemStack().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(iItemHandler -> { itemTooltipEvent.getItemStack().getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(iItemHandler -> {
if (iItemHandler instanceof DrawerStackItemHandler) { if (iItemHandler instanceof DrawerStackItemHandler) {
int i = 0; int i = 0;
for (BigInventoryHandler.BigStack storedStack : ((DrawerStackItemHandler) iItemHandler).getStoredStacks()) { for (BigInventoryHandler.BigStack storedStack : ((DrawerStackItemHandler) iItemHandler).getStoredStacks()) {
@ -303,8 +299,8 @@ public class FunctionalStorage extends ModuleController {
} }
}); });
}).subscribe(); }).subscribe();
EventManager.mod(ModelRegistryEvent.class).process(modelRegistryEvent -> { EventManager.mod(ModelEvent.RegisterGeometryLoaders.class).process(modelRegistryEvent -> {
ModelLoaderRegistry.registerLoader(new ResourceLocation(MOD_ID, "framed"), RetexturedModel.Loader.INSTANCE); modelRegistryEvent.register("framed", RetexturedModel.Loader.INSTANCE);
}).subscribe(); }).subscribe();
} }
@ -313,21 +309,21 @@ public class FunctionalStorage extends ModuleController {
NonNullLazy<List<Block>> blocksToProcess = NonNullLazy.of(() -> NonNullLazy<List<Block>> blocksToProcess = NonNullLazy.of(() ->
ForgeRegistries.BLOCKS.getValues() ForgeRegistries.BLOCKS.getValues()
.stream() .stream()
.filter(basicBlock -> Optional.ofNullable(basicBlock.getRegistryName()) .filter(basicBlock -> Optional.ofNullable(ForgeRegistries.BLOCKS.getKey(basicBlock))
.map(ResourceLocation::getNamespace) .map(ResourceLocation::getNamespace)
.filter(MOD_ID::equalsIgnoreCase) .filter(MOD_ID::equalsIgnoreCase)
.isPresent()) .isPresent())
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
if (true) { if (true) {
event.getGenerator().addProvider(new BlockItemModelGeneratorProvider(event.getGenerator(), MOD_ID, blocksToProcess)); event.getGenerator().addProvider(true, new BlockItemModelGeneratorProvider(event.getGenerator(), MOD_ID, blocksToProcess));
event.getGenerator().addProvider(new FunctionalStorageBlockstateProvider(event.getGenerator(), event.getExistingFileHelper(), blocksToProcess)); event.getGenerator().addProvider(true, new FunctionalStorageBlockstateProvider(event.getGenerator(), event.getExistingFileHelper(), blocksToProcess));
event.getGenerator().addProvider(new TitaniumLootTableProvider(event.getGenerator(), blocksToProcess)); event.getGenerator().addProvider(true, new TitaniumLootTableProvider(event.getGenerator(), blocksToProcess));
event.getGenerator().addProvider(new FunctionalStorageItemTagsProvider(event.getGenerator(), new BlockTagsProvider(event.getGenerator()), MOD_ID, event.getExistingFileHelper())); event.getGenerator().addProvider(true, new FunctionalStorageItemTagsProvider(event.getGenerator(), new BlockTagsProvider(event.getGenerator()), MOD_ID, event.getExistingFileHelper()));
event.getGenerator().addProvider(new FunctionalStorageLangProvider(event.getGenerator(), MOD_ID, "en_us")); event.getGenerator().addProvider(true, new FunctionalStorageLangProvider(event.getGenerator(), MOD_ID, "en_us"));
event.getGenerator().addProvider(new FunctionalStorageBlockTagsProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper())); event.getGenerator().addProvider(true, new FunctionalStorageBlockTagsProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()));
event.getGenerator().addProvider(new ItemModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) { event.getGenerator().addProvider(true, new ItemModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) {
@Override @Override
protected void registerModels() { protected void registerModels() {
for (StorageUpgradeItem.StorageTier storageTier : STORAGE_UPGRADES.keySet()) { for (StorageUpgradeItem.StorageTier storageTier : STORAGE_UPGRADES.keySet()) {
@ -342,28 +338,28 @@ public class FunctionalStorage extends ModuleController {
} }
private void item(Item item) { private void item(Item item) {
singleTexture(item.getRegistryName().getPath(), new ResourceLocation("minecraft:item/generated"), "layer0", new ResourceLocation(MOD_ID, "items/" + item.getRegistryName().getPath())); singleTexture(ForgeRegistries.ITEMS.getKey(item).getPath(), new ResourceLocation("minecraft:item/generated"), "layer0", new ResourceLocation(MOD_ID, "items/" + ForgeRegistries.ITEMS.getKey(item).getPath()));
} }
}); });
event.getGenerator().addProvider(new BlockModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) { event.getGenerator().addProvider(true, new BlockModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) {
@Override @Override
protected void registerModels() { protected void registerModels() {
for (DrawerType value : DrawerType.values()) { for (DrawerType value : DrawerType.values()) {
for (RegistryObject<Block> blockRegistryObject : DRAWER_TYPES.get(value).stream().map(Pair::getLeft).collect(Collectors.toList())) { for (RegistryObject<Block> blockRegistryObject : DRAWER_TYPES.get(value).stream().map(Pair::getLeft).collect(Collectors.toList())) {
withExistingParent(blockRegistryObject.get().getRegistryName().getPath() + "_locked", modLoc(blockRegistryObject.get().getRegistryName().getPath())) withExistingParent(ForgeRegistries.BLOCKS.getKey(blockRegistryObject.get()).getPath() + "_locked", modLoc(ForgeRegistries.BLOCKS.getKey(blockRegistryObject.get()).getPath()))
.texture("lock_icon", modLoc("blocks/lock")); .texture("lock_icon", modLoc("blocks/lock"));
} }
} }
withExistingParent(COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath())) withExistingParent(ForgeRegistries.BLOCKS.getKey(COMPACTING_DRAWER.getLeft().get()).getPath() + "_locked", modLoc(ForgeRegistries.BLOCKS.getKey(COMPACTING_DRAWER.getLeft().get()).getPath()))
.texture("lock_icon", modLoc("blocks/lock")); .texture("lock_icon", modLoc("blocks/lock"));
withExistingParent(ENDER_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(ENDER_DRAWER.getLeft().get().getRegistryName().getPath())) withExistingParent(ForgeRegistries.BLOCKS.getKey(ENDER_DRAWER.getLeft().get()).getPath() + "_locked", modLoc(ForgeRegistries.BLOCKS.getKey(ENDER_DRAWER.getLeft().get()).getPath()))
.texture("lock_icon", modLoc("blocks/lock")); .texture("lock_icon", modLoc("blocks/lock"));
withExistingParent(FRAMED_COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath() + "_locked", modLoc(FRAMED_COMPACTING_DRAWER.getLeft().get().getRegistryName().getPath())) withExistingParent(ForgeRegistries.BLOCKS.getKey(FRAMED_COMPACTING_DRAWER.getLeft().get()).getPath() + "_locked", modLoc(ForgeRegistries.BLOCKS.getKey(FRAMED_COMPACTING_DRAWER.getLeft().get()).getPath()))
.texture("lock_icon", modLoc("blocks/lock")); .texture("lock_icon", modLoc("blocks/lock"));
} }
}); });
} }
event.getGenerator().addProvider(new TitaniumRecipeProvider(event.getGenerator()) { event.getGenerator().addProvider(true, new TitaniumRecipeProvider(event.getGenerator()) {
@Override @Override
public void register(Consumer<FinishedRecipe> consumer) { public void register(Consumer<FinishedRecipe> consumer) {
blocksToProcess.get().stream().map(block -> (BasicBlock) block).forEach(basicBlock -> basicBlock.registerRecipe(consumer)); blocksToProcess.get().stream().map(block -> (BasicBlock) block).forEach(basicBlock -> basicBlock.registerRecipe(consumer));
@ -421,7 +417,7 @@ public class FunctionalStorage extends ModuleController {
.save(consumer); .save(consumer);
UpgradeRecipeBuilder.smithing(Ingredient.of(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get()), Ingredient.of(Items.NETHERITE_INGOT), STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get()) UpgradeRecipeBuilder.smithing(Ingredient.of(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get()), Ingredient.of(Items.NETHERITE_INGOT), STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get())
.unlocks("has_netherite_ingot", has(Items.NETHERITE_INGOT)) .unlocks("has_netherite_ingot", has(Items.NETHERITE_INGOT))
.save(consumer, STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get().getRegistryName()); .save(consumer, ForgeRegistries.ITEMS.getKey(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get()));
TitaniumShapedRecipeBuilder.shapedRecipe(DRAWER_CONTROLLER.getLeft().get()) TitaniumShapedRecipeBuilder.shapedRecipe(DRAWER_CONTROLLER.getLeft().get())
.pattern("IBI").pattern("CDC").pattern("IBI") .pattern("IBI").pattern("CDC").pattern("IBI")
.define('I', Tags.Items.STONE) .define('I', Tags.Items.STONE)

View File

@ -11,7 +11,6 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -97,7 +96,7 @@ public class CompactingFramedDrawerBlock extends CompactingDrawerBlock{
} }
@Override @Override
public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List<Component> components, TooltipFlag p_49819_) { public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List<Component> components, TooltipFlag p_49819_) {
components.add(new TranslatableComponent("frameddrawer.use").withStyle(ChatFormatting.GRAY)); components.add(Component.translatable("frameddrawer.use").withStyle(ChatFormatting.GRAY));
super.appendHoverText(p_49816_, p_49817_, components, p_49819_); super.appendHoverText(p_49816_, p_49817_, components, p_49819_);
} }
} }

View File

@ -21,8 +21,8 @@ import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -319,10 +319,10 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List<net.minecraft.network.chat.Component> tooltip, TooltipFlag p_49819_) { public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List<net.minecraft.network.chat.Component> tooltip, TooltipFlag p_49819_) {
super.appendHoverText(p_49816_, p_49817_, tooltip, p_49819_); super.appendHoverText(p_49816_, p_49817_, tooltip, p_49819_);
if (p_49816_.hasTag() && p_49816_.getTag().contains("Tile")) { if (p_49816_.hasTag() && p_49816_.getTag().contains("Tile")) {
TranslatableComponent text = new TranslatableComponent("drawer.block.contents"); MutableComponent text = Component.translatable("drawer.block.contents");
tooltip.add(text.withStyle(ChatFormatting.GRAY)); tooltip.add(text.withStyle(ChatFormatting.GRAY));
tooltip.add(new TextComponent("")); tooltip.add(Component.literal(""));
tooltip.add(new TextComponent("")); tooltip.add(Component.literal(""));
} }
} }

View File

@ -7,7 +7,6 @@ import com.buuz135.functionalstorage.block.tile.EnderDrawerTile;
import com.buuz135.functionalstorage.item.LinkingToolItem; import com.buuz135.functionalstorage.item.LinkingToolItem;
import com.hrznstudio.titanium.block.RotatableBlock; import com.hrznstudio.titanium.block.RotatableBlock;
import com.hrznstudio.titanium.datagenerator.loot.block.BasicBlockLootTables; import com.hrznstudio.titanium.datagenerator.loot.block.BasicBlockLootTables;
import com.hrznstudio.titanium.module.DeferredRegistryHelper;
import com.hrznstudio.titanium.util.RayTraceUtils; import com.hrznstudio.titanium.util.RayTraceUtils;
import com.hrznstudio.titanium.util.TileUtil; import com.hrznstudio.titanium.util.TileUtil;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
@ -16,8 +15,7 @@ import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -64,7 +62,7 @@ public class EnderDrawerBlock extends RotatableBlock<EnderDrawerTile> {
public static List<ItemStack> getFrequencyDisplay(String string){ public static List<ItemStack> getFrequencyDisplay(String string){
return FREQUENCY_LOOK.computeIfAbsent(string, s -> { return FREQUENCY_LOOK.computeIfAbsent(string, s -> {
List<Item> minecraftItems = ForgeRegistries.ITEMS.getValues().stream().filter(item -> item != Items.AIR && item.getRegistryName().getNamespace().equals("minecraft") && !(item instanceof BlockItem)).collect(Collectors.toList()); List<Item> minecraftItems = ForgeRegistries.ITEMS.getValues().stream().filter(item -> item != Items.AIR && ForgeRegistries.ITEMS.getKey(item).getNamespace().equals("minecraft") && !(item instanceof BlockItem)).collect(Collectors.toList());
return Arrays.stream(string.split("-")).map(s1 -> new ItemStack(minecraftItems.get(Math.abs(s1.hashCode()) % minecraftItems.size()))).collect(Collectors.toList()); return Arrays.stream(string.split("-")).map(s1 -> new ItemStack(minecraftItems.get(Math.abs(s1.hashCode()) % minecraftItems.size()))).collect(Collectors.toList());
}); });
} }
@ -176,11 +174,11 @@ public class EnderDrawerBlock extends RotatableBlock<EnderDrawerTile> {
@Override @Override
public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List<Component> tooltip, TooltipFlag p_49819_) { public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List<Component> tooltip, TooltipFlag p_49819_) {
super.appendHoverText(p_49816_, p_49817_, tooltip, p_49819_); super.appendHoverText(p_49816_, p_49817_, tooltip, p_49819_);
if (p_49816_.hasTag()){ if (p_49816_.hasTag()) {
TranslatableComponent text = new TranslatableComponent("linkingtool.ender.frequency"); MutableComponent text = Component.translatable("linkingtool.ender.frequency");
tooltip.add(text.withStyle(ChatFormatting.GRAY)); tooltip.add(text.withStyle(ChatFormatting.GRAY));
tooltip.add(new TextComponent("")); tooltip.add(Component.literal(""));
tooltip.add(new TextComponent("")); tooltip.add(Component.literal(""));
} }
} }

View File

@ -13,7 +13,6 @@ import net.minecraft.core.NonNullList;
import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -76,10 +75,10 @@ public class FramedDrawerBlock extends DrawerBlock{
public static ItemStack fill(ItemStack first, ItemStack second, ItemStack drawer){ public static ItemStack fill(ItemStack first, ItemStack second, ItemStack drawer){
drawer = ItemHandlerHelper.copyStackWithSize(drawer, 1); drawer = ItemHandlerHelper.copyStackWithSize(drawer, 1);
CompoundTag style = drawer.getOrCreateTagElement("Style"); CompoundTag style = drawer.getOrCreateTagElement("Style");
style.putString("particle", first.getItem().getRegistryName().toString()); style.putString("particle", ForgeRegistries.ITEMS.getKey(first.getItem()).toString());
style.putString("side", first.getItem().getRegistryName().toString()); style.putString("side", ForgeRegistries.ITEMS.getKey(first.getItem()).toString());
style.putString("front", second.getItem().getRegistryName().toString()); style.putString("front", ForgeRegistries.ITEMS.getKey(second.getItem()).toString());
style.putString("front_divider", first.getItem().getRegistryName().toString()); style.putString("front_divider", ForgeRegistries.ITEMS.getKey(first.getItem()).toString());
drawer.getOrCreateTag().put("Style", style); drawer.getOrCreateTag().put("Style", style);
return drawer; return drawer;
} }
@ -141,7 +140,7 @@ public class FramedDrawerBlock extends DrawerBlock{
@Override @Override
public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List<Component> components, TooltipFlag p_49819_) { public void appendHoverText(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List<Component> components, TooltipFlag p_49819_) {
components.add(new TranslatableComponent("frameddrawer.use").withStyle(ChatFormatting.GRAY)); components.add(Component.translatable("frameddrawer.use").withStyle(ChatFormatting.GRAY));
super.appendHoverText(p_49816_, p_49817_, components, p_49819_); super.appendHoverText(p_49816_, p_49817_, components, p_49819_);
} }
} }

View File

@ -1,14 +1,12 @@
package com.buuz135.functionalstorage.block.tile; package com.buuz135.functionalstorage.block.tile;
import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.client.model.FramedDrawerModelData; import com.buuz135.functionalstorage.client.model.FramedDrawerModelData;
import com.hrznstudio.titanium.annotation.Save; import com.hrznstudio.titanium.annotation.Save;
import com.hrznstudio.titanium.block.BasicTileBlock; import com.hrznstudio.titanium.block.BasicTileBlock;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
@ -34,7 +32,9 @@ public class CompactingFramedDrawerTile extends CompactingDrawerTile{
@Nonnull @Nonnull
@Override @Override
public IModelData getModelData() { public ModelData getModelData() {
return new ModelDataMap.Builder().withInitial(FramedDrawerModelData.FRAMED_PROPERTY, framedDrawerModelData).build(); return ModelData.builder().with(FramedDrawerModelData.FRAMED_PROPERTY, framedDrawerModelData).build();
} }
} }

View File

@ -17,7 +17,7 @@ import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
@ -32,9 +32,9 @@ import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.HitResult;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -118,20 +118,20 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
addGuiAddonFactory(() -> new TextScreenAddon("Storage", 10, 59, false, ChatFormatting.DARK_GRAY.getColor()) { addGuiAddonFactory(() -> new TextScreenAddon("Storage", 10, 59, false, ChatFormatting.DARK_GRAY.getColor()) {
@Override @Override
public String getText() { public String getText() {
return new TranslatableComponent("key.categories.storage").getString(); return Component.translatable("key.categories.storage").getString();
} }
}); });
} }
addGuiAddonFactory(() -> new TextScreenAddon("Utility", 114, 59, false, ChatFormatting.DARK_GRAY.getColor()) { addGuiAddonFactory(() -> new TextScreenAddon("Utility", 114, 59, false, ChatFormatting.DARK_GRAY.getColor()) {
@Override @Override
public String getText() { public String getText() {
return new TranslatableComponent("key.categories.utility").getString(); return Component.translatable("key.categories.utility").getString();
} }
}); });
addGuiAddonFactory(() -> new TextScreenAddon("key.categories.inventory", 8, 92, false, ChatFormatting.DARK_GRAY.getColor()) { addGuiAddonFactory(() -> new TextScreenAddon("key.categories.inventory", 8, 92, false, ChatFormatting.DARK_GRAY.getColor()) {
@Override @Override
public String getText() { public String getText() {
return new TranslatableComponent("key.categories.inventory").getString(); return Component.translatable("key.categories.inventory").getString();
} }
}); });
} }
@ -159,7 +159,7 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
if (item.equals(FunctionalStorage.PULLING_UPGRADE.get())) { if (item.equals(FunctionalStorage.PULLING_UPGRADE.get())) {
Direction direction = UpgradeItem.getDirection(stack); Direction direction = UpgradeItem.getDirection(stack);
TileUtil.getTileEntity(level, pos.relative(direction)).ifPresent(blockEntity1 -> { TileUtil.getTileEntity(level, pos.relative(direction)).ifPresent(blockEntity1 -> {
blockEntity1.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()).ifPresent(iItemHandler -> { blockEntity1.getCapability(ForgeCapabilities.ITEM_HANDLER, direction.getOpposite()).ifPresent(iItemHandler -> {
for (int otherSlot = 0; otherSlot < iItemHandler.getSlots(); otherSlot++) { for (int otherSlot = 0; otherSlot < iItemHandler.getSlots(); otherSlot++) {
ItemStack pulledStack = iItemHandler.extractItem(otherSlot, 2, true); ItemStack pulledStack = iItemHandler.extractItem(otherSlot, 2, true);
if (pulledStack.isEmpty()) continue; if (pulledStack.isEmpty()) continue;
@ -180,7 +180,7 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
if (item.equals(FunctionalStorage.PUSHING_UPGRADE.get())) { if (item.equals(FunctionalStorage.PUSHING_UPGRADE.get())) {
Direction direction = UpgradeItem.getDirection(stack); Direction direction = UpgradeItem.getDirection(stack);
TileUtil.getTileEntity(level, pos.relative(direction)).ifPresent(blockEntity1 -> { TileUtil.getTileEntity(level, pos.relative(direction)).ifPresent(blockEntity1 -> {
blockEntity1.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()).ifPresent(otherHandler -> { blockEntity1.getCapability(ForgeCapabilities.ITEM_HANDLER, direction.getOpposite()).ifPresent(otherHandler -> {
for (int otherSlot = 0; otherSlot < getStorage().getSlots(); otherSlot++) { for (int otherSlot = 0; otherSlot < getStorage().getSlots(); otherSlot++) {
ItemStack pulledStack = getStorage().extractItem(otherSlot, 2, true); ItemStack pulledStack = getStorage().extractItem(otherSlot, 2, true);
if (pulledStack.isEmpty()) continue; if (pulledStack.isEmpty()) continue;

View File

@ -8,8 +8,7 @@ import com.hrznstudio.titanium.block.BasicTileBlock;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
@ -35,7 +34,7 @@ public class FramedDrawerTile extends DrawerTile{
@Nonnull @Nonnull
@Override @Override
public IModelData getModelData() { public ModelData getModelData() {
return new ModelDataMap.Builder().withInitial(FramedDrawerModelData.FRAMED_PROPERTY, framedDrawerModelData).build(); return ModelData.builder().with(FramedDrawerModelData.FRAMED_PROPERTY, framedDrawerModelData).build();
} }
} }

View File

@ -1,23 +1,15 @@
package com.buuz135.functionalstorage.client; package com.buuz135.functionalstorage.client;
import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.block.tile.CompactingDrawerTile; import com.buuz135.functionalstorage.block.tile.CompactingDrawerTile;
import com.buuz135.functionalstorage.block.tile.DrawerTile;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix3f; import com.mojang.math.Matrix3f;
import com.mojang.math.Quaternion; import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class CompactingDrawerRenderer implements BlockEntityRenderer<CompactingDrawerTile> { public class CompactingDrawerRenderer implements BlockEntityRenderer<CompactingDrawerTile> {

View File

@ -20,7 +20,6 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class DrawerRenderer implements BlockEntityRenderer<DrawerTile> { public class DrawerRenderer implements BlockEntityRenderer<DrawerTile> {
@ -182,7 +181,8 @@ public class DrawerRenderer implements BlockEntityRenderer<DrawerTile> {
} }
if (options.isActive(ConfigurationToolItem.ConfigurationAction.TOGGLE_NUMBERS)) renderText(matrixStack, bufferIn, combinedOverlayIn, new TextComponent(ChatFormatting.WHITE + "" + NumberUtils.getFormatedBigNumber(amount)), Direction.NORTH, scale); if (options.isActive(ConfigurationToolItem.ConfigurationAction.TOGGLE_NUMBERS))
renderText(matrixStack, bufferIn, combinedOverlayIn, Component.literal(ChatFormatting.WHITE + "" + NumberUtils.getFormatedBigNumber(amount)), Direction.NORTH, scale);
} }

View File

@ -2,28 +2,20 @@ package com.buuz135.functionalstorage.client;
import com.buuz135.functionalstorage.FunctionalStorage; import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.block.tile.ControllableDrawerTile; import com.buuz135.functionalstorage.block.tile.ControllableDrawerTile;
import com.buuz135.functionalstorage.block.tile.DrawerTile;
import com.buuz135.functionalstorage.block.tile.EnderDrawerTile; import com.buuz135.functionalstorage.block.tile.EnderDrawerTile;
import com.buuz135.functionalstorage.inventory.BigInventoryHandler;
import com.buuz135.functionalstorage.inventory.EnderInventoryHandler; import com.buuz135.functionalstorage.inventory.EnderInventoryHandler;
import com.buuz135.functionalstorage.item.ConfigurationToolItem; import com.buuz135.functionalstorage.item.ConfigurationToolItem;
import com.buuz135.functionalstorage.util.NumberUtils;
import com.buuz135.functionalstorage.world.EnderSavedData; import com.buuz135.functionalstorage.world.EnderSavedData;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix3f; import com.mojang.math.Matrix3f;
import com.mojang.math.Quaternion; import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
public class EnderDrawerRenderer implements BlockEntityRenderer<EnderDrawerTile> { public class EnderDrawerRenderer implements BlockEntityRenderer<EnderDrawerTile> {

View File

@ -10,8 +10,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -83,13 +81,13 @@ public class DrawerInfoGuiAddon extends BasicScreenAddon {
var componentList = new ArrayList<Component>(); var componentList = new ArrayList<Component>();
var over = slotStack.apply(i); var over = slotStack.apply(i);
if (over.isEmpty()) { if (over.isEmpty()) {
componentList.add(new TranslatableComponent("gui.functionalstorage.item").withStyle(ChatFormatting.GOLD).append(new TextComponent("Empty").withStyle(ChatFormatting.WHITE))); componentList.add(Component.translatable("gui.functionalstorage.item").withStyle(ChatFormatting.GOLD).append(Component.literal("Empty").withStyle(ChatFormatting.WHITE)));
} else { } else {
componentList.add(new TranslatableComponent("gui.functionalstorage.item").withStyle(ChatFormatting.GOLD).append(over.getHoverName().copy().withStyle(ChatFormatting.WHITE))); componentList.add(Component.translatable("gui.functionalstorage.item").withStyle(ChatFormatting.GOLD).append(over.getHoverName().copy().withStyle(ChatFormatting.WHITE)));
var amount = NumberUtils.getFormatedBigNumber(over.getCount()) + "/" + NumberUtils.getFormatedBigNumber(slotMaxAmount.apply(i)); var amount = NumberUtils.getFormatedBigNumber(over.getCount()) + "/" + NumberUtils.getFormatedBigNumber(slotMaxAmount.apply(i));
componentList.add(new TranslatableComponent("gui.functionalstorage.amount").withStyle(ChatFormatting.GOLD).append(new TextComponent(amount).withStyle(ChatFormatting.WHITE))); componentList.add(Component.translatable("gui.functionalstorage.amount").withStyle(ChatFormatting.GOLD).append(Component.literal(amount).withStyle(ChatFormatting.WHITE)));
} }
componentList.add(new TranslatableComponent("gui.functionalstorage.slot").withStyle(ChatFormatting.GOLD).append(new TextComponent(i + "").withStyle(ChatFormatting.WHITE))); componentList.add(Component.translatable("gui.functionalstorage.slot").withStyle(ChatFormatting.GOLD).append(Component.literal(i + "").withStyle(ChatFormatting.WHITE)));
screen.renderTooltip(stack, componentList, Optional.empty(), mouseX - guiX, mouseY - guiY); screen.renderTooltip(stack, componentList, Optional.empty(), mouseX - guiX, mouseY - guiY);
} }
} }

View File

@ -1,23 +1,23 @@
package com.buuz135.functionalstorage.client.loader; package com.buuz135.functionalstorage.client.loader;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.BakedModelWrapper;
import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.ModelData;
import net.minecraftforge.client.model.data.IModelData;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import java.util.Random;
/** /**
* Class from Mantle {@url https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/client/} * Class from Mantle {@url https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/client/}
* <p>
* Used to create a baked model wrapper that has a dynamic {@link #getQuads(BlockState, Direction, RandomSource, ModelData, RenderType)} without worrying about overriding the deprecated variant.
* *
* Cross between {@link BakedModelWrapper} and {@link net.minecraftforge.client.model.data.IDynamicBakedModel}. * @param <T> Baked model parent
* Used to create a baked model wrapper that has a dynamic {@link #getQuads(BlockState, Direction, Random, IModelData)} without worrying about overriding the deprecated variant.
* @param <T> Baked model parent
*/ */
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
public abstract class DynamicBakedWrapper<T extends BakedModel> extends BakedModelWrapper<T> { public abstract class DynamicBakedWrapper<T extends BakedModel> extends BakedModelWrapper<T> {
@ -26,15 +26,9 @@ public abstract class DynamicBakedWrapper<T extends BakedModel> extends BakedMod
super(originalModel); super(originalModel);
} }
/**
* @deprecated use {@link #getQuads(BlockState, Direction, Random, IModelData)}
*/
@Override
@Deprecated
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
return this.getQuads(state, side, rand, EmptyModelData.INSTANCE);
}
@Override @Override
public abstract List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData); public abstract List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, ModelData extraData, RenderType renderType);
} }

View File

@ -1,35 +1,32 @@
package com.buuz135.functionalstorage.client.loader; package com.buuz135.functionalstorage.client.loader;
import net.minecraft.client.resources.model.ModelState; import com.mojang.math.Transformation;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.Material;
import net.minecraftforge.client.model.IModelConfiguration; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.model.geometry.IModelGeometryPart; import net.minecraftforge.client.RenderTypeGroup;
import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
import javax.annotation.Nullable; import org.jetbrains.annotations.Nullable;
/** /**
* Class from Mantle {@url https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/client/} * Class from Mantle {@url https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/client/}
* * <p>
* Wrapper around a {@link IModelConfiguration} instance to allow easier extending, mostly for dynamic textures * Wrapper around a {@link IGeometryBakingContext} instance to allow easier extending, mostly for dynamic textures
*/ */
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
public class ModelConfigurationWrapper implements IModelConfiguration { public class ModelConfigurationWrapper implements IGeometryBakingContext {
private final IModelConfiguration base; private final IGeometryBakingContext base;
/** /**
* Creates a new configuration wrapper * Creates a new configuration wrapper
* @param base Base model configuration * @param base Base model configuration
*/ */
public ModelConfigurationWrapper(IModelConfiguration base) { public ModelConfigurationWrapper(IGeometryBakingContext base) {
this.base = base; this.base = base;
} }
@Nullable public IGeometryBakingContext getOwner() {
@Override return base;
public UnbakedModel getOwnerModel() {
return base.getOwnerModel();
} }
@Override @Override
@ -38,42 +35,54 @@ public class ModelConfigurationWrapper implements IModelConfiguration {
} }
@Override @Override
public boolean isTexturePresent(String name) { public boolean hasMaterial(String name) {
return base.isTexturePresent(name); return base.hasMaterial(name);
} }
@Override @Override
public Material resolveTexture(String name) { public Material getMaterial(String name) {
return base.resolveTexture(name); return base.getMaterial(name);
}
@Override
public RenderTypeGroup getRenderType(ResourceLocation name) {
return IGeometryBakingContext.super.getRenderType(name);
} }
@Override @Override
public boolean isShadedInGui() { public boolean isGui3d() {
return base.isShadedInGui(); return base.isGui3d();
} }
@Override @Override
public boolean isSideLit() { public boolean useBlockLight() {
return base.isSideLit(); return base.useBlockLight();
} }
@Override @Override
public boolean useSmoothLighting() { public boolean useAmbientOcclusion() {
return base.useSmoothLighting(); return base.useAmbientOcclusion();
} }
@Override @Override
public ItemTransforms getCameraTransforms() { public ItemTransforms getTransforms() {
return base.getCameraTransforms(); return base.getTransforms();
} }
@Override @Override
public ModelState getCombinedTransform() { public Transformation getRootTransform() {
return base.getCombinedTransform(); return base.getRootTransform();
} }
@Override @Override
public boolean getPartVisibility(IModelGeometryPart part, boolean fallback) { public @Nullable ResourceLocation getRenderTypeHint() {
return base.getPartVisibility(part, fallback); return base.getRenderTypeHint();
} }
@Override
public boolean isComponentVisible(String component, boolean fallback) {
return base.isComponentVisible(component, fallback);
}
} }

View File

@ -3,23 +3,18 @@ package com.buuz135.functionalstorage.client.loader;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.mojang.blaze3d.vertex.VertexFormatElement;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.MultiPartBakedModel; import net.minecraft.client.resources.model.MultiPartBakedModel;
import net.minecraft.client.resources.model.WeightedBakedModel; import net.minecraft.client.resources.model.WeightedBakedModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
import net.minecraft.util.GsonHelper; import net.minecraft.util.GsonHelper;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
import net.minecraftforge.client.model.pipeline.VertexTransformer;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Map; import java.util.Map;
@ -160,51 +155,11 @@ public class ModelHelper {
throw new JsonParseException("Invalid '" + key + "' " + i + " found, only 0/90/180/270 allowed"); throw new JsonParseException("Invalid '" + key + "' " + i + " found, only 0/90/180/270 allowed");
} }
} }
/*
public static BakedQuad colorQuad(int color, BakedQuad quad) { public static BakedQuad colorQuad(int color, BakedQuad quad) {
ColorTransformer transformer = new ColorTransformer(color, quad); //ColorTransformer transformer = new ColorTransformer(color, quad);
quad.pipe(transformer); //quad.pipe(transformer);
return transformer.build(); return transformer.build();
} }
*/
private static class ColorTransformer extends VertexTransformer {
private final float r, g, b, a;
public ColorTransformer(int color, BakedQuad quad) {
super(new BakedQuadBuilder(quad.getSprite()));
int a = (color >> 24);
if (a == 0) {
a = 255;
}
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color >> 0) & 0xFF;
this.r = (float) r / 255f;
this.g = (float) g / 255f;
this.b = (float) b / 255f;
this.a = (float) a / 255f;
}
@Override
public void put(int element, float... data) {
VertexFormatElement.Usage usage = this.parent.getVertexFormat().getElements().get(element).getUsage();
// transform normals and position
if (usage == VertexFormatElement.Usage.COLOR && data.length >= 4) {
data[0] = this.r;
data[1] = this.g;
data[2] = this.b;
data[3] = this.a;
}
super.put(element, data);
}
public BakedQuad build() {
return ((BakedQuadBuilder) this.parent).build();
}
}
} }

View File

@ -2,9 +2,7 @@ package com.buuz135.functionalstorage.client.loader;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.Material;
import net.minecraftforge.client.model.IModelConfiguration;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Iterator; import java.util.Iterator;
@ -36,16 +34,14 @@ public class ModelTextureIteratable implements Iterable<Map<String,Either<Materi
} }
/** /**
* * @param fallback Fallback in case the owner does not contain a block model
* @param owner Model configuration owner * @return Iteratable over block model texture maps
* @param fallback Fallback in case the owner does not contain a block model
* @return Iteratable over block model texture maps
*/ */
public static ModelTextureIteratable of(IModelConfiguration owner, SimpleBlockModel fallback) { public static ModelTextureIteratable of(SimpleBlockModel fallback) {
UnbakedModel unbaked = owner.getOwnerModel(); //UnbakedModel unbaked = owner.getOwnerModel();
if (unbaked instanceof BlockModel) { //if (unbaked instanceof BlockModel) {
return new ModelTextureIteratable(null, (BlockModel)unbaked); // return new ModelTextureIteratable(null, (BlockModel)unbaked);
} //}
return new ModelTextureIteratable(fallback.getTextures(), fallback.getParent()); return new ModelTextureIteratable(fallback.getTextures(), fallback.getParent());
} }

View File

@ -4,36 +4,30 @@ import com.buuz135.functionalstorage.block.FramedDrawerBlock;
import com.buuz135.functionalstorage.client.model.FramedDrawerModelData; import com.buuz135.functionalstorage.client.model.FramedDrawerModelData;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gson.JsonArray; import com.google.gson.*;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.*;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
import net.minecraft.util.GsonHelper; import net.minecraft.util.GsonHelper;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.data.ModelData;
import net.minecraftforge.client.model.IModelLoader; import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.geometry.IGeometryLoader;
import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.geometry.IUnbakedGeometry;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -43,12 +37,12 @@ import java.util.function.Function;
/** /**
* Class from Mantle {@url https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/client/model/RetexturedModel.java} * Class from Mantle {@url https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/client/model/RetexturedModel.java}
* * <p>
* Model that dynamically retextures a list of textures based on data from {@link RetexturedHelper}. * Model that dynamically retextures a list of textures based on data from {@link RetexturedHelper}.
*/ */
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
public class RetexturedModel implements IModelGeometry<RetexturedModel> { public class RetexturedModel implements IUnbakedGeometry<RetexturedModel> {
private final SimpleBlockModel model; private final SimpleBlockModel model;
private final Set<String> retextured; private final Set<String> retextured;
@ -57,28 +51,16 @@ public class RetexturedModel implements IModelGeometry<RetexturedModel> {
this.retextured = retextured; this.retextured = retextured;
} }
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation,UnbakedModel> modelGetter, Set<Pair<String,String>> missingTextureErrors) {
return model.getTextures(owner, modelGetter, missingTextureErrors);
}
@Override
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material,TextureAtlasSprite> spriteGetter, ModelState transform, ItemOverrides overrides, ResourceLocation location) {
// bake the model and return
BakedModel baked = model.bakeModel(owner, transform, overrides, spriteGetter, location);
return new Baked(baked, owner, model, transform, getAllRetextured(owner, this.model, retextured));
}
/** /**
* Gets a list of all names to retexture based on the block model texture references * Gets a list of all names to retexture based on the block model texture references
* @param owner Model config instance * @param owner Model config instance
* @param model Model fallback * @param model Model fallback
* @param originalSet Original list of names to retexture * @param originalSet Original list of names to retexture
* @return Set of textures including parent textures * @return Set of textures including parent textures
*/ */
public static Set<String> getAllRetextured(IModelConfiguration owner, SimpleBlockModel model, Set<String> originalSet) { public static Set<String> getAllRetextured(IGeometryBakingContext owner, SimpleBlockModel model, Set<String> originalSet) {
Set<String> retextured = Sets.newHashSet(originalSet); Set<String> retextured = Sets.newHashSet(originalSet);
for (Map<String,Either<Material, String>> textures : ModelTextureIteratable.of(owner, model)) { for (Map<String, Either<Material, String>> textures : ModelTextureIteratable.of(model)) {
textures.forEach((name, either) -> textures.forEach((name, either) ->
either.ifRight(parent -> { either.ifRight(parent -> {
if (retextured.contains(parent)) { if (retextured.contains(parent)) {
@ -90,17 +72,31 @@ public class RetexturedModel implements IModelGeometry<RetexturedModel> {
return ImmutableSet.copyOf(retextured); return ImmutableSet.copyOf(retextured);
} }
@Override
public Collection<Material> getMaterials(IGeometryBakingContext owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return model.getMaterials(owner, modelGetter, missingTextureErrors);
}
@Override
public BakedModel bake(IGeometryBakingContext owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState transform, ItemOverrides overrides, ResourceLocation location) {
// bake the model and return
BakedModel baked = model.bakeModel(owner, transform, overrides, spriteGetter, location);
return new Baked(baked, owner, model, transform, getAllRetextured(owner, this.model, retextured), spriteGetter);
}
/** Registered model loader instance registered */ /** Registered model loader instance registered */
public static class Loader implements IModelLoader<RetexturedModel> { public static class Loader implements IGeometryLoader<RetexturedModel>, ResourceManagerReloadListener {
public static final Loader INSTANCE = new Loader(); public static final Loader INSTANCE = new Loader();
private Loader() {}
private Loader() {
}
@Override @Override
public void onResourceManagerReload(ResourceManager resourceManager) {} public void onResourceManagerReload(ResourceManager resourceManager) {
}
@Override @Override
public RetexturedModel read(JsonDeserializationContext context, JsonObject json) { public RetexturedModel read(JsonObject json, JsonDeserializationContext context) {
// get base model // get base model
SimpleBlockModel model = SimpleBlockModel.deserialize(context, json); SimpleBlockModel model = SimpleBlockModel.deserialize(context, json);
@ -143,21 +139,27 @@ public class RetexturedModel implements IModelGeometry<RetexturedModel> {
/** Baked variant of the model, used to swap out quads based on the texture */ /** Baked variant of the model, used to swap out quads based on the texture */
public static class Baked extends DynamicBakedWrapper<BakedModel> { public static class Baked extends DynamicBakedWrapper<BakedModel> {
/** Cache of texture name to baked model */ /**
* Cache of texture name to baked model
*/
private final Map<String, BakedModel> cache = new ConcurrentHashMap<>(); private final Map<String, BakedModel> cache = new ConcurrentHashMap<>();
/* Properties for rebaking */ /* Properties for rebaking */
private final IModelConfiguration owner; private final IGeometryBakingContext owner;
private final SimpleBlockModel model; private final SimpleBlockModel model;
private final ModelState transform; private final ModelState transform;
/** List of texture names that are retextured */ /**
* List of texture names that are retextured
*/
private final Set<String> retextured; private final Set<String> retextured;
private final Function<Material, TextureAtlasSprite> spriteGetter;
public Baked(BakedModel baked, IModelConfiguration owner, SimpleBlockModel model, ModelState transform, Set<String> retextured) { public Baked(BakedModel baked, IGeometryBakingContext owner, SimpleBlockModel model, ModelState transform, Set<String> retextured, Function<Material, TextureAtlasSprite> spriteGetter) {
super(baked); super(baked);
this.model = model; this.model = model;
this.owner = owner; this.owner = owner;
this.transform = transform; this.transform = transform;
this.retextured = retextured; this.retextured = retextured;
this.spriteGetter = spriteGetter;
} }
/** /**
@ -166,7 +168,7 @@ public class RetexturedModel implements IModelGeometry<RetexturedModel> {
* @return Retextured model * @return Retextured model
*/ */
private BakedModel getRetexturedModel(FramedDrawerModelData framedDrawerModelData) { private BakedModel getRetexturedModel(FramedDrawerModelData framedDrawerModelData) {
return model.bakeDynamic(new RetexturedConfiguration(owner, retextured, framedDrawerModelData), transform); return model.bakeDynamic(new RetexturedConfiguration(owner, retextured, framedDrawerModelData), transform, spriteGetter);
} }
/** /**
@ -179,10 +181,10 @@ public class RetexturedModel implements IModelGeometry<RetexturedModel> {
} }
@Override @Override
public TextureAtlasSprite getParticleIcon(IModelData data) { public TextureAtlasSprite getParticleIcon(ModelData data) {
// if particle is retextured, fetch particle from the cached model // if particle is retextured, fetch particle from the cached model
if (retextured.contains("particle")) { if (retextured.contains("particle")) {
FramedDrawerModelData framedDrawerModelData = data.getData(FramedDrawerModelData.FRAMED_PROPERTY); FramedDrawerModelData framedDrawerModelData = data.get(FramedDrawerModelData.FRAMED_PROPERTY);
if (framedDrawerModelData != null) { if (framedDrawerModelData != null) {
return getCachedModel(framedDrawerModelData).getParticleIcon(data); return getCachedModel(framedDrawerModelData).getParticleIcon(data);
} }
@ -192,12 +194,12 @@ public class RetexturedModel implements IModelGeometry<RetexturedModel> {
@Nonnull @Nonnull
@Override @Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction direction, Random random, IModelData data) { public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction direction, RandomSource random, ModelData data, RenderType renderType) {
FramedDrawerModelData framedDrawerModelData = data.getData(FramedDrawerModelData.FRAMED_PROPERTY); FramedDrawerModelData framedDrawerModelData = data.get(FramedDrawerModelData.FRAMED_PROPERTY);
if (framedDrawerModelData == null) { if (framedDrawerModelData == null) {
return originalModel.getQuads(state, direction, random, data); return originalModel.getQuads(state, direction, random, data, renderType);
} }
return getCachedModel(framedDrawerModelData).getQuads(state, direction, random, data); return getCachedModel(framedDrawerModelData).getQuads(state, direction, random, data, renderType);
} }
@Override @Override
@ -217,33 +219,34 @@ public class RetexturedModel implements IModelGeometry<RetexturedModel> {
/** /**
* Creates a new configuration wrapper * Creates a new configuration wrapper
* @param base Original model configuration *
* @param retextured Set of textures that should be retextured * @param base Original model configuration
* @param texture New texture to replace those in the set * @param retextured Set of textures that should be retextured
* @param texture New texture to replace those in the set
*/ */
public RetexturedConfiguration(IModelConfiguration base, Set<String> retextured, FramedDrawerModelData texture) { public RetexturedConfiguration(IGeometryBakingContext base, Set<String> retextured, FramedDrawerModelData texture) {
super(base); super(base);
this.retextured = retextured; this.retextured = retextured;
this.texture = new HashMap<>(); this.texture = new HashMap<>();
texture.getDesign().forEach((s, item) -> { texture.getDesign().forEach((s, item) -> {
this.texture.put(s, ModelLoaderRegistry.blockMaterial(ModelHelper.getParticleTexture(item))); this.texture.put(s, new Material(TextureAtlas.LOCATION_BLOCKS, ModelHelper.getParticleTexture(item)));
}); });
} }
@Override @Override
public boolean isTexturePresent(String name) { public boolean hasMaterial(String name) {
if (retextured.contains(name) && texture.containsKey(name)) { if (retextured.contains(name) && texture.containsKey(name)) {
return !MissingTextureAtlasSprite.getLocation().equals(texture.get(name).texture()); return !MissingTextureAtlasSprite.getLocation().equals(texture.get(name).texture());
} }
return super.isTexturePresent(name); return super.hasMaterial(name);
} }
@Override @Override
public Material resolveTexture(String name) { public Material getMaterial(String name) {
if (retextured.contains(name) && texture.containsKey(name)) { if (retextured.contains(name) && texture.containsKey(name)) {
return texture.get(name); return texture.get(name);
} }
return super.resolveTexture(name); return super.getMaterial(name);
} }
} }

View File

@ -10,49 +10,34 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.block.model.*;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BlockElement;
import net.minecraft.client.renderer.block.model.BlockElementFace;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.*;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.SimpleBakedModel;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
import net.minecraft.util.GsonHelper; import net.minecraft.util.GsonHelper;
import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.inventory.InventoryMenu;
import net.minecraftforge.client.model.ForgeModelBakery; import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
import net.minecraftforge.client.model.IModelConfiguration; import net.minecraftforge.client.model.geometry.IGeometryLoader;
import net.minecraftforge.client.model.IModelLoader; import net.minecraftforge.client.model.geometry.IUnbakedGeometry;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Collection; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* Class from Mantle {@url https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/client/} * Class from Mantle {@url https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/client/}
* * <p>
* Simplier version of {@link BlockModel} for use in an {@link net.minecraftforge.client.model.IModelLoader}, as the owner handles most block model properties * Simplier version of {@link BlockModel} for use in an {@link net.minecraftforge.client.model.IModelLoader}, as the owner handles most block model properties
*/ */
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
public class SimpleBlockModel implements IModelGeometry<SimpleBlockModel> { public class SimpleBlockModel implements IUnbakedGeometry<SimpleBlockModel> {
/** /**
* Model loader for vanilla block model, mainly intended for use in fallback registration * Model loader for vanilla block model, mainly intended for use in fallback registration
*/ */
@ -108,40 +93,27 @@ public class SimpleBlockModel implements IModelGeometry<SimpleBlockModel> {
/* Textures */ /* Textures */
/** /**
* Fetches parent models for this model and its parents * Gets the texture dependencies for a list of elements, allows calling outside a simple block model
* *
* @param modelGetter Model getter function * @param owner Model configuration
* @param elements List of elements to check for textures
* @param missingTextureErrors Missing texture set
* @return Textures dependencies
*/ */
public void fetchParent(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter) { public static Collection<Material> getMaterials(IGeometryBakingContext owner, List<BlockElement> elements, Set<Pair<String, String>> missingTextureErrors) {
// no work if no parent or the parent is fetched already // always need a particle texture
if (parent != null || parentLocation == null) { Set<Material> textures = Sets.newHashSet(owner.getMaterial("particle"));
return; // iterate all elements, fetching needed textures from the material
} for (BlockElement part : elements) {
for (BlockElementFace face : part.faces.values()) {
// iterate through model parents Material material = owner.getMaterial(face.texture);
Set<UnbakedModel> chain = Sets.newLinkedHashSet(); if (Objects.equals(material.texture(), MissingTextureAtlasSprite.getLocation())) {
missingTextureErrors.add(Pair.of(face.texture, owner.getModelName()));
// load the first model directly }
parent = getParent(modelGetter, chain, parentLocation, owner.getModelName()); textures.add(material);
// null means no model, so set missing
if (parent == null) {
parent = getMissing(modelGetter);
parentLocation = ModelBakery.MISSING_MODEL_LOCATION;
}
// loop through each parent, adding in parents
for (BlockModel link = parent; link.parentLocation != null && link.parent == null; link = link.parent) {
chain.add(link);
// fetch model parent
link.parent = getParent(modelGetter, chain, link.parentLocation, link.name);
// null means no model, so set missing
if (link.parent == null) {
link.parent = getMissing(modelGetter);
link.parentLocation = ModelBakery.MISSING_MODEL_LOCATION;
} }
} }
return textures;
} }
/** /**
@ -188,47 +160,6 @@ public class SimpleBlockModel implements IModelGeometry<SimpleBlockModel> {
return (BlockModel) model; return (BlockModel) model;
} }
/**
* Gets the texture dependencies for a list of elements, allows calling outside a simple block model
*
* @param owner Model configuration
* @param elements List of elements to check for textures
* @param missingTextureErrors Missing texture set
* @return Textures dependencies
*/
public static Collection<Material> getTextures(IModelConfiguration owner, List<BlockElement> elements, Set<Pair<String, String>> missingTextureErrors) {
// always need a particle texture
Set<Material> textures = Sets.newHashSet(owner.resolveTexture("particle"));
// iterate all elements, fetching needed textures from the material
for (BlockElement part : elements) {
for (BlockElementFace face : part.faces.values()) {
Material material = owner.resolveTexture(face.texture);
if (Objects.equals(material.texture(), MissingTextureAtlasSprite.getLocation())) {
missingTextureErrors.add(Pair.of(face.texture, owner.getModelName()));
}
textures.add(material);
}
}
return textures;
}
/**
* Gets the texture and model dependencies for a block model
*
* @param owner Model configuration
* @param modelGetter Model getter to fetch parent models
* @param missingTextureErrors Missing texture set
* @return Textures dependencies
*/
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
this.fetchParent(owner, modelGetter);
return getTextures(owner, getElements(), missingTextureErrors);
}
/* Baking */
/** /**
* Bakes a single part of the model into the builder * Bakes a single part of the model into the builder
* *
@ -239,7 +170,7 @@ public class SimpleBlockModel implements IModelGeometry<SimpleBlockModel> {
* @param spriteGetter Sprite getter * @param spriteGetter Sprite getter
* @param location Model location * @param location Model location
*/ */
public static void bakePart(SimpleBakedModel.Builder builder, IModelConfiguration owner, BlockElement part, ModelState transform, Function<Material, TextureAtlasSprite> spriteGetter, ResourceLocation location) { public static void bakePart(SimpleBakedModel.Builder builder, IGeometryBakingContext owner, BlockElement part, ModelState transform, Function<Material, TextureAtlasSprite> spriteGetter, ResourceLocation location) {
for (Direction direction : part.faces.keySet()) { for (Direction direction : part.faces.keySet()) {
BlockElementFace face = part.faces.get(direction); BlockElementFace face = part.faces.get(direction);
// ensure the name is not prefixed (it always is) // ensure the name is not prefixed (it always is)
@ -248,7 +179,7 @@ public class SimpleBlockModel implements IModelGeometry<SimpleBlockModel> {
texture = texture.substring(1); texture = texture.substring(1);
} }
// bake the face // bake the face
TextureAtlasSprite sprite = spriteGetter.apply(owner.resolveTexture(texture)); TextureAtlasSprite sprite = spriteGetter.apply(owner.getMaterial(texture));
BakedQuad bakedQuad = BlockModel.bakeFace(part, face, sprite, direction, transform, location); BakedQuad bakedQuad = BlockModel.bakeFace(part, face, sprite, direction, transform, location);
// apply cull face // apply cull face
if (face.cullForDirection == null) { if (face.cullForDirection == null) {
@ -270,26 +201,81 @@ public class SimpleBlockModel implements IModelGeometry<SimpleBlockModel> {
* @param location Model bake location * @param location Model bake location
* @return Baked model * @return Baked model
*/ */
public static BakedModel bakeModel(IModelConfiguration owner, List<BlockElement> elements, ModelState transform, ItemOverrides overrides, Function<Material, TextureAtlasSprite> spriteGetter, ResourceLocation location) { public static BakedModel bakeModel(IGeometryBakingContext owner, List<BlockElement> elements, ModelState transform, ItemOverrides overrides, Function<Material, TextureAtlasSprite> spriteGetter, ResourceLocation location) {
// iterate parts, adding to the builder // iterate parts, adding to the builder
TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle")); TextureAtlasSprite particle = spriteGetter.apply(owner.getMaterial("particle"));
SimpleBakedModel.Builder builder = new SimpleBakedModel.Builder(owner, overrides).particle(particle); SimpleBakedModel.Builder builder = new SimpleBakedModel.Builder(owner.useAmbientOcclusion(), owner.isGui3d(), true, owner.getTransforms(), overrides).particle(particle);
for (BlockElement part : elements) { for (BlockElement part : elements) {
bakePart(builder, owner, part, transform, spriteGetter, location); bakePart(builder, owner, part, transform, spriteGetter, location);
} }
return builder.build(); return builder.build();
} }
/* Baking */
/** /**
* Same as {@link #bakeModel(IModelConfiguration, List, ModelState, ItemOverrides, Function, ResourceLocation)}, but passes in sensible defaults for values unneeded in dynamic models * Same as {@link #bakeModel(IGeometryBakingContext, List, ModelState, ItemOverrides, Function, ResourceLocation)}, but passes in sensible defaults for values unneeded in dynamic models
* *
* @param owner Model configuration * @param owner Model configuration
* @param elements Elements to bake * @param elements Elements to bake
* @param transform Model transform * @param transform Model transform
* @param spriteGetter
* @return Baked model * @return Baked model
*/ */
public static BakedModel bakeDynamic(IModelConfiguration owner, List<BlockElement> elements, ModelState transform) { public static BakedModel bakeDynamic(IGeometryBakingContext owner, List<BlockElement> elements, ModelState transform, Function<Material, TextureAtlasSprite> spriteGetter) {
return bakeModel(owner, elements, transform, ItemOverrides.EMPTY, ForgeModelBakery.defaultTextureGetter(), BAKE_LOCATION); return bakeModel(owner, elements, transform, ItemOverrides.EMPTY, spriteGetter, BAKE_LOCATION);
}
/**
* Fetches parent models for this model and its parents
*
* @param modelGetter Model getter function
*/
public void fetchParent(IGeometryBakingContext owner, Function<ResourceLocation, UnbakedModel> modelGetter) {
// no work if no parent or the parent is fetched already
if (parent != null || parentLocation == null) {
return;
}
// iterate through model parents
Set<UnbakedModel> chain = Sets.newLinkedHashSet();
// load the first model directly
parent = getParent(modelGetter, chain, parentLocation, owner.getModelName());
// null means no model, so set missing
if (parent == null) {
parent = getMissing(modelGetter);
parentLocation = ModelBakery.MISSING_MODEL_LOCATION;
}
// loop through each parent, adding in parents
for (BlockModel link = parent; link.parentLocation != null && link.parent == null; link = link.parent) {
chain.add(link);
// fetch model parent
link.parent = getParent(modelGetter, chain, link.parentLocation, link.name);
// null means no model, so set missing
if (link.parent == null) {
link.parent = getMissing(modelGetter);
link.parentLocation = ModelBakery.MISSING_MODEL_LOCATION;
}
}
}
/**
* Gets the texture and model dependencies for a block model
*
* @param owner Model configuration
* @param modelGetter Model getter to fetch parent models
* @param missingTextureErrors Missing texture set
* @return Textures dependencies
*/
@Override
public Collection<Material> getMaterials(IGeometryBakingContext owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
this.fetchParent(owner, modelGetter);
return getMaterials(owner, getElements(), missingTextureErrors);
} }
/** /**
@ -302,24 +288,24 @@ public class SimpleBlockModel implements IModelGeometry<SimpleBlockModel> {
* @param location Bake location * @param location Bake location
* @return Baked model * @return Baked model
*/ */
public BakedModel bakeModel(IModelConfiguration owner, ModelState transform, ItemOverrides overrides, Function<Material, TextureAtlasSprite> spriteGetter, ResourceLocation location) { public BakedModel bakeModel(IGeometryBakingContext owner, ModelState transform, ItemOverrides overrides, Function<Material, TextureAtlasSprite> spriteGetter, ResourceLocation location) {
return bakeModel(owner, this.getElements(), transform, overrides, spriteGetter, location); return bakeModel(owner, this.getElements(), transform, overrides, spriteGetter, location);
} }
@Override @Override
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState transform, ItemOverrides overrides, ResourceLocation location) { public BakedModel bake(IGeometryBakingContext owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState transform, ItemOverrides overrides, ResourceLocation location) {
return bakeModel(owner, transform, overrides, spriteGetter, location); return bakeModel(owner, transform, overrides, spriteGetter, location);
} }
/** /**
* Same as {@link #bakeModel(IModelConfiguration, ModelState, ItemOverrides, Function, ResourceLocation)}, but passes in sensible defaults for values unneeded in dynamic models * Same as {@link #bakeModel(IGeometryBakingContext, ModelState, ItemOverrides, Function, ResourceLocation)}, but passes in sensible defaults for values unneeded in dynamic models
* *
* @param owner Model configuration * @param owner Model configuration
* @param transform Transform to apply * @param transform Transform to apply
* @return Baked model * @return Baked model
*/ */
public BakedModel bakeDynamic(IModelConfiguration owner, ModelState transform) { public BakedModel bakeDynamic(IGeometryBakingContext owner, ModelState transform, Function<Material, TextureAtlasSprite> spriteGetter) {
return bakeDynamic(owner, this.getElements(), transform); return bakeDynamic(owner, this.getElements(), transform, spriteGetter);
} }
@ -388,13 +374,13 @@ public class SimpleBlockModel implements IModelGeometry<SimpleBlockModel> {
/** /**
* Logic to implement a vanilla block model * Logic to implement a vanilla block model
*/ */
private static class Loader implements IModelLoader<SimpleBlockModel> { private static class Loader implements IGeometryLoader<SimpleBlockModel>, ResourceManagerReloadListener {
@Override @Override
public void onResourceManagerReload(ResourceManager resourceManager) { public void onResourceManagerReload(ResourceManager resourceManager) {
} }
@Override @Override
public SimpleBlockModel read(JsonDeserializationContext context, JsonObject json) { public SimpleBlockModel read(JsonObject json, JsonDeserializationContext context) {
return deserialize(context, json); return deserialize(context, json);
} }
} }

View File

@ -52,7 +52,7 @@ public class FramedDrawerModelData implements INBTSerializable<CompoundTag> {
@Override @Override
public CompoundTag serializeNBT() { public CompoundTag serializeNBT() {
CompoundTag compoundTag = new CompoundTag(); CompoundTag compoundTag = new CompoundTag();
design.forEach((s, item) -> compoundTag.putString(s, item.getRegistryName().toString())); design.forEach((s, item) -> compoundTag.putString(s, ForgeRegistries.ITEMS.getKey(item).toString()));
return compoundTag; return compoundTag;
} }
@ -68,7 +68,7 @@ public class FramedDrawerModelData implements INBTSerializable<CompoundTag> {
private void generateCode(){ private void generateCode(){
this.code = ""; this.code = "";
this.design.forEach((s, item) -> { this.design.forEach((s, item) -> {
this.code += (s + item.getRegistryName().toString()); this.code += (s + ForgeRegistries.ITEMS.getKey(item).toString());
}); });
} }

View File

@ -13,7 +13,7 @@ import mcjty.theoneprobe.api.*;
import mcjty.theoneprobe.apiimpl.elements.ElementHorizontal; import mcjty.theoneprobe.apiimpl.elements.ElementHorizontal;
import mcjty.theoneprobe.apiimpl.elements.ElementVertical; import mcjty.theoneprobe.apiimpl.elements.ElementVertical;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -94,7 +94,7 @@ public class FunctionalDrawerProvider implements IProbeInfoProvider {
if (abstractElementPanel.getElements().size() > 0) vertical.element(abstractElementPanel); if (abstractElementPanel.getElements().size() > 0) vertical.element(abstractElementPanel);
ElementVertical elementVertical = new ElementVertical(iProbeInfo.defaultLayoutStyle()); ElementVertical elementVertical = new ElementVertical(iProbeInfo.defaultLayoutStyle());
elementVertical.getStyle().borderColor(Color.CYAN.darker().getRGB()); elementVertical.getStyle().borderColor(Color.CYAN.darker().getRGB());
elementVertical.text(new TranslatableComponent("linkingtool.ender.frequency")); elementVertical.text(Component.translatable("linkingtool.ender.frequency"));
vertical.element(new ElementVertical(iProbeInfo.defaultLayoutStyle().topPadding(4))); vertical.element(new ElementVertical(iProbeInfo.defaultLayoutStyle().topPadding(4)));
abstractElementPanel = new ElementHorizontal(iProbeInfo.defaultLayoutStyle().leftPadding(4).topPadding(2).rightPadding(4)); abstractElementPanel = new ElementHorizontal(iProbeInfo.defaultLayoutStyle().leftPadding(4).topPadding(2).rightPadding(4));
for (ItemStack stack : EnderDrawerBlock.getFrequencyDisplay(((EnderDrawerTile) blockEntity).getFrequency())) { for (ItemStack stack : EnderDrawerBlock.getFrequencyDisplay(((EnderDrawerTile) blockEntity).getFrequency())) {

View File

@ -3,9 +3,7 @@ package com.buuz135.functionalstorage.data;
import com.buuz135.functionalstorage.FunctionalStorage; import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.block.CompactingDrawerBlock; import com.buuz135.functionalstorage.block.CompactingDrawerBlock;
import com.buuz135.functionalstorage.block.DrawerBlock; import com.buuz135.functionalstorage.block.DrawerBlock;
import com.buuz135.functionalstorage.block.DrawerControllerBlock;
import com.buuz135.functionalstorage.block.EnderDrawerBlock; import com.buuz135.functionalstorage.block.EnderDrawerBlock;
import com.buuz135.functionalstorage.block.tile.ControllableDrawerTile;
import com.hrznstudio.titanium.block.RotatableBlock; import com.hrznstudio.titanium.block.RotatableBlock;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
@ -18,6 +16,7 @@ import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.client.model.generators.VariantBlockStateBuilder; import net.minecraftforge.client.model.generators.VariantBlockStateBuilder;
import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.common.util.NonNullLazy; import net.minecraftforge.common.util.NonNullLazy;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.List; import java.util.List;
@ -32,11 +31,11 @@ public class FunctionalStorageBlockstateProvider extends BlockStateProvider {
} }
public static ResourceLocation getModel(Block block) { public static ResourceLocation getModel(Block block) {
return new ResourceLocation(block.getRegistryName().getNamespace(), "block/" + block.getRegistryName().getPath()); return new ResourceLocation(ForgeRegistries.BLOCKS.getKey(block).getNamespace(), "block/" + ForgeRegistries.BLOCKS.getKey(block).getPath());
} }
public static ResourceLocation getModelLocked(Block block) { public static ResourceLocation getModelLocked(Block block) {
return new ResourceLocation(block.getRegistryName().getNamespace(), "block/" + block.getRegistryName().getPath() + "_locked"); return new ResourceLocation(ForgeRegistries.BLOCKS.getKey(block).getNamespace(), "block/" + ForgeRegistries.BLOCKS.getKey(block).getPath() + "_locked");
} }
@Override @Override

View File

@ -6,6 +6,7 @@ import com.buuz135.functionalstorage.item.StorageUpgradeItem;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.data.LanguageProvider; import net.minecraftforge.common.data.LanguageProvider;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.RegistryObject;
import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.lang3.text.WordUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -48,12 +49,12 @@ public class FunctionalStorageLangProvider extends LanguageProvider {
for (StorageUpgradeItem.StorageTier storageTier : FunctionalStorage.STORAGE_UPGRADES.keySet()) { for (StorageUpgradeItem.StorageTier storageTier : FunctionalStorage.STORAGE_UPGRADES.keySet()) {
this.add(FunctionalStorage.STORAGE_UPGRADES.get(storageTier).get(), WordUtils.capitalize(storageTier.name().toLowerCase()) + (storageTier == StorageUpgradeItem.StorageTier.IRON ? " Downgrade" : " Upgrade")); this.add(FunctionalStorage.STORAGE_UPGRADES.get(storageTier).get(), WordUtils.capitalize(storageTier.name().toLowerCase()) + (storageTier == StorageUpgradeItem.StorageTier.IRON ? " Downgrade" : " Upgrade"));
} }
this.add(FunctionalStorage.COLLECTOR_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.COLLECTOR_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); this.add(FunctionalStorage.COLLECTOR_UPGRADE.get(), WordUtils.capitalize(ForgeRegistries.ITEMS.getKey(FunctionalStorage.COLLECTOR_UPGRADE.get()).getPath().replace('_', ' ').toLowerCase()));
this.add(FunctionalStorage.PULLING_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.PULLING_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); this.add(FunctionalStorage.PULLING_UPGRADE.get(), WordUtils.capitalize(ForgeRegistries.ITEMS.getKey(FunctionalStorage.PULLING_UPGRADE.get()).getPath().replace('_', ' ').toLowerCase()));
this.add(FunctionalStorage.PUSHING_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.PUSHING_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); this.add(FunctionalStorage.PUSHING_UPGRADE.get(), WordUtils.capitalize(ForgeRegistries.ITEMS.getKey(FunctionalStorage.PUSHING_UPGRADE.get()).getPath().replace('_', ' ').toLowerCase()));
this.add(FunctionalStorage.VOID_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.VOID_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); this.add(FunctionalStorage.VOID_UPGRADE.get(), WordUtils.capitalize(ForgeRegistries.ITEMS.getKey(FunctionalStorage.VOID_UPGRADE.get()).getPath().replace('_', ' ').toLowerCase()));
this.add(FunctionalStorage.REDSTONE_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.REDSTONE_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase())); this.add(FunctionalStorage.REDSTONE_UPGRADE.get(), WordUtils.capitalize(ForgeRegistries.ITEMS.getKey(FunctionalStorage.REDSTONE_UPGRADE.get()).getPath().replace('_', ' ').toLowerCase()));
this.add(FunctionalStorage.CREATIVE_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.CREATIVE_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase())); this.add(FunctionalStorage.CREATIVE_UPGRADE.get(), WordUtils.capitalize(ForgeRegistries.ITEMS.getKey(FunctionalStorage.CREATIVE_UPGRADE.get()).getPath().replace('_', ' ').toLowerCase()));
this.add(FunctionalStorage.ARMORY_CABINET.getLeft().get(), "Armory Cabinet"); this.add(FunctionalStorage.ARMORY_CABINET.getLeft().get(), "Armory Cabinet");
this.add(FunctionalStorage.CONFIGURATION_TOOL.get(), "Configuration Tool"); this.add(FunctionalStorage.CONFIGURATION_TOOL.get(), "Configuration Tool");
this.add("item.utility.downgrade", "Downgrades the slots to a max of 64 items"); this.add("item.utility.downgrade", "Downgrades the slots to a max of 64 items");

View File

@ -7,8 +7,8 @@ import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.*; import net.minecraft.network.chat.TextColor;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -54,7 +54,7 @@ public class ConfigurationToolItem extends BasicItem {
@Override @Override
public void fillItemCategory(CreativeModeTab group, NonNullList<ItemStack> items) { public void fillItemCategory(CreativeModeTab group, NonNullList<ItemStack> items) {
if (allowdedIn(group)) { if (this.allowedIn(group)) {
items.add(initNbt(new ItemStack(this))); items.add(initNbt(new ItemStack(this)));
} }
} }
@ -85,8 +85,8 @@ public class ConfigurationToolItem extends BasicItem {
ConfigurationAction action = getAction(stack); ConfigurationAction action = getAction(stack);
ConfigurationAction newAction = ConfigurationAction.values()[(Arrays.asList(ConfigurationAction.values()).indexOf(action) + 1) % ConfigurationAction.values().length]; ConfigurationAction newAction = ConfigurationAction.values()[(Arrays.asList(ConfigurationAction.values()).indexOf(action) + 1) % ConfigurationAction.values().length];
stack.getOrCreateTag().putString(NBT_MODE, newAction.name()); stack.getOrCreateTag().putString(NBT_MODE, newAction.name());
player.displayClientMessage(new TextComponent("Swapped mode to ").setStyle(Style.EMPTY.withColor(newAction.getColor())) player.displayClientMessage(Component.literal("Swapped mode to ").setStyle(Style.EMPTY.withColor(newAction.getColor()))
.append(new TranslatableComponent("configurationtool.configmode." + newAction.name().toLowerCase(Locale.ROOT))), true); .append(Component.translatable("configurationtool.configmode." + newAction.name().toLowerCase(Locale.ROOT))), true);
player.playSound(SoundEvents.ITEM_FRAME_REMOVE_ITEM, 0.5f, 1); player.playSound(SoundEvents.ITEM_FRAME_REMOVE_ITEM, 0.5f, 1);
return InteractionResultHolder.success(stack); return InteractionResultHolder.success(stack);
} }
@ -99,10 +99,10 @@ public class ConfigurationToolItem extends BasicItem {
super.addTooltipDetails(key, stack, tooltip, advanced); super.addTooltipDetails(key, stack, tooltip, advanced);
ConfigurationAction linkingMode = getAction(stack); ConfigurationAction linkingMode = getAction(stack);
if (key == null) { if (key == null) {
tooltip.add(new TranslatableComponent("configurationtool.configmode").withStyle(ChatFormatting.YELLOW) tooltip.add(Component.translatable("configurationtool.configmode").withStyle(ChatFormatting.YELLOW)
.append(new TranslatableComponent("configurationtool.configmode." + linkingMode.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingMode.getColor())))); .append(Component.translatable("configurationtool.configmode." + linkingMode.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingMode.getColor()))));
tooltip.add(new TextComponent("").withStyle(ChatFormatting.GRAY)); tooltip.add(Component.literal("").withStyle(ChatFormatting.GRAY));
tooltip.add(new TranslatableComponent("configurationtool.use").withStyle(ChatFormatting.GRAY)); tooltip.add(Component.translatable("configurationtool.use").withStyle(ChatFormatting.GRAY));
} }
} }

View File

@ -13,8 +13,9 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.*; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
@ -62,10 +63,10 @@ public class LinkingToolItem extends BasicItem {
static { static {
EventManager.forge(PlayerInteractEvent.LeftClickBlock.class).filter(leftClickBlock -> leftClickBlock.getSide() == LogicalSide.SERVER && leftClickBlock.getItemStack().is(FunctionalStorage.LINKING_TOOL.get())).process(leftClickBlock -> { EventManager.forge(PlayerInteractEvent.LeftClickBlock.class).filter(leftClickBlock -> leftClickBlock.getSide() == LogicalSide.SERVER && leftClickBlock.getItemStack().is(FunctionalStorage.LINKING_TOOL.get())).process(leftClickBlock -> {
ItemStack stack = leftClickBlock.getItemStack(); ItemStack stack = leftClickBlock.getItemStack();
BlockEntity blockEntity = leftClickBlock.getWorld().getBlockEntity(leftClickBlock.getPos()); BlockEntity blockEntity = leftClickBlock.getLevel().getBlockEntity(leftClickBlock.getPos());
if (blockEntity instanceof EnderDrawerTile){ if (blockEntity instanceof EnderDrawerTile){
stack.getOrCreateTag().putString(NBT_ENDER, ((EnderDrawerTile) blockEntity).getFrequency()); stack.getOrCreateTag().putString(NBT_ENDER, ((EnderDrawerTile) blockEntity).getFrequency());
leftClickBlock.getPlayer().displayClientMessage(new TextComponent("Stored frequency in the tool").setStyle(Style.EMPTY.withColor(LinkingMode.SINGLE.color)), true); leftClickBlock.getEntity().displayClientMessage(Component.literal("Stored frequency in the tool").setStyle(Style.EMPTY.withColor(LinkingMode.SINGLE.color)), true);
leftClickBlock.setCanceled(true); leftClickBlock.setCanceled(true);
} }
}).subscribe(); }).subscribe();
@ -89,7 +90,7 @@ public class LinkingToolItem extends BasicItem {
@Override @Override
public void fillItemCategory(CreativeModeTab group, NonNullList<ItemStack> items) { public void fillItemCategory(CreativeModeTab group, NonNullList<ItemStack> items) {
if (allowdedIn(group)) { if (this.allowedIn(group)) {
items.add(initNbt(new ItemStack(this))); items.add(initNbt(new ItemStack(this)));
} }
} }
@ -105,7 +106,7 @@ public class LinkingToolItem extends BasicItem {
BlockEntity blockEntity = level.getBlockEntity(pos); BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof EnderDrawerTile){ if (blockEntity instanceof EnderDrawerTile){
stack.getOrCreateTag().putString(NBT_ENDER, ((EnderDrawerTile) blockEntity).getFrequency()); stack.getOrCreateTag().putString(NBT_ENDER, ((EnderDrawerTile) blockEntity).getFrequency());
player.displayClientMessage(new TextComponent("Stored frequency in the tool").setStyle(Style.EMPTY.withColor(LinkingMode.SINGLE.color)), true); player.displayClientMessage(Component.literal("Stored frequency in the tool").setStyle(Style.EMPTY.withColor(LinkingMode.SINGLE.color)), true);
return false; return false;
} }
return super.canAttackBlock(state,level, pos, player); return super.canAttackBlock(state,level, pos, player);
@ -125,10 +126,10 @@ public class LinkingToolItem extends BasicItem {
EnderInventoryHandler inventory = EnderSavedData.getInstance(context.getLevel()).getFrequency(((EnderDrawerTile) blockEntity).getFrequency()); EnderInventoryHandler inventory = EnderSavedData.getInstance(context.getLevel()).getFrequency(((EnderDrawerTile) blockEntity).getFrequency());
if (inventory.getStackInSlot(0).isEmpty() || (context.getPlayer().isShiftKeyDown() && stack.getOrCreateTag().contains(NBT_ENDER))){ if (inventory.getStackInSlot(0).isEmpty() || (context.getPlayer().isShiftKeyDown() && stack.getOrCreateTag().contains(NBT_ENDER))){
((EnderDrawerTile) blockEntity).setFrequency(frequency); ((EnderDrawerTile) blockEntity).setFrequency(frequency);
context.getPlayer().displayClientMessage(new TextComponent("Changed drawer frequency").setStyle(Style.EMPTY.withColor(linkingMode.color)), true); context.getPlayer().displayClientMessage(Component.literal("Changed drawer frequency").setStyle(Style.EMPTY.withColor(linkingMode.color)), true);
stack.getOrCreateTag().remove(NBT_ENDER_SAFETY); stack.getOrCreateTag().remove(NBT_ENDER_SAFETY);
} else { } else {
context.getPlayer().displayClientMessage(new TextComponent("Cannot change frequency, there are items in the drawer. Sneak + Right Click again to ignore this safety").withStyle(ChatFormatting.RED), true); context.getPlayer().displayClientMessage(Component.literal("Cannot change frequency, there are items in the drawer. Sneak + Right Click again to ignore this safety").withStyle(ChatFormatting.RED), true);
stack.getOrCreateTag().putBoolean(NBT_ENDER_SAFETY, true); stack.getOrCreateTag().putBoolean(NBT_ENDER_SAFETY, true);
} }
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
@ -141,7 +142,7 @@ public class LinkingToolItem extends BasicItem {
controller.putInt("Z", pos.getZ()); controller.putInt("Z", pos.getZ());
stack.getOrCreateTag().put(NBT_CONTROLLER, controller); stack.getOrCreateTag().put(NBT_CONTROLLER, controller);
context.getPlayer().playSound(SoundEvents.ITEM_FRAME_ADD_ITEM, 0.5f, 1); context.getPlayer().playSound(SoundEvents.ITEM_FRAME_ADD_ITEM, 0.5f, 1);
context.getPlayer().displayClientMessage(new TextComponent("Controller configured to the tool").withStyle(ChatFormatting.GREEN), true); context.getPlayer().displayClientMessage(Component.literal("Controller configured to the tool").withStyle(ChatFormatting.GREEN), true);
stack.getOrCreateTag().remove(NBT_ENDER); stack.getOrCreateTag().remove(NBT_ENDER);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} else if (blockEntity instanceof ControllableDrawerTile && stack.getOrCreateTag().contains(NBT_CONTROLLER)) { } else if (blockEntity instanceof ControllableDrawerTile && stack.getOrCreateTag().contains(NBT_CONTROLLER)) {
@ -151,9 +152,9 @@ public class LinkingToolItem extends BasicItem {
if (linkingMode == LinkingMode.SINGLE) { if (linkingMode == LinkingMode.SINGLE) {
((DrawerControllerTile) controller).addConnectedDrawers(linkingAction, pos); ((DrawerControllerTile) controller).addConnectedDrawers(linkingAction, pos);
if (linkingAction == ActionMode.ADD){ if (linkingAction == ActionMode.ADD){
context.getPlayer().displayClientMessage(new TextComponent("Linked drawer to the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true); context.getPlayer().displayClientMessage(Component.literal("Linked drawer to the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true);
}else { }else {
context.getPlayer().displayClientMessage(new TextComponent("Removed drawer from the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true); context.getPlayer().displayClientMessage(Component.literal("Removed drawer from the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true);
} }
} else { } else {
if (stack.getOrCreateTag().contains(NBT_FIRST)) { if (stack.getOrCreateTag().contains(NBT_FIRST)) {
@ -163,9 +164,9 @@ public class LinkingToolItem extends BasicItem {
((DrawerControllerTile) controller).addConnectedDrawers(linkingAction, getBlockPosInAABB(aabb).toArray(BlockPos[]::new)); ((DrawerControllerTile) controller).addConnectedDrawers(linkingAction, getBlockPosInAABB(aabb).toArray(BlockPos[]::new));
stack.getOrCreateTag().remove(NBT_FIRST); stack.getOrCreateTag().remove(NBT_FIRST);
if (linkingAction == ActionMode.ADD){ if (linkingAction == ActionMode.ADD){
context.getPlayer().displayClientMessage(new TextComponent("Linked drawers to the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true); context.getPlayer().displayClientMessage(Component.literal("Linked drawers to the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true);
}else { }else {
context.getPlayer().displayClientMessage(new TextComponent("Removed drawers from the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true); context.getPlayer().displayClientMessage(Component.literal("Removed drawers from the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true);
} }
} else { } else {
CompoundTag firstPos = new CompoundTag(); CompoundTag firstPos = new CompoundTag();
@ -189,27 +190,27 @@ public class LinkingToolItem extends BasicItem {
if (stack.getOrCreateTag().contains(NBT_ENDER)){ if (stack.getOrCreateTag().contains(NBT_ENDER)){
if (player.isShiftKeyDown()){ if (player.isShiftKeyDown()){
stack.getOrCreateTag().remove(NBT_ENDER); stack.getOrCreateTag().remove(NBT_ENDER);
player.displayClientMessage(new TextComponent("Cleared drawer frequency").setStyle(Style.EMPTY.withColor(ActionMode.ADD.getColor())), true); player.displayClientMessage(Component.literal("Cleared drawer frequency").setStyle(Style.EMPTY.withColor(ActionMode.ADD.getColor())), true);
} }
} else { } else {
if (player.isShiftKeyDown()) { if (player.isShiftKeyDown()) {
LinkingMode linkingMode = getLinkingMode(stack); LinkingMode linkingMode = getLinkingMode(stack);
if (linkingMode == LinkingMode.SINGLE) { if (linkingMode == LinkingMode.SINGLE) {
stack.getOrCreateTag().putString(NBT_MODE, LinkingMode.MULTIPLE.name()); stack.getOrCreateTag().putString(NBT_MODE, LinkingMode.MULTIPLE.name());
player.displayClientMessage(new TextComponent("Swapped mode to " + LinkingMode.MULTIPLE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(LinkingMode.MULTIPLE.getColor())), true); player.displayClientMessage(Component.literal("Swapped mode to " + LinkingMode.MULTIPLE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(LinkingMode.MULTIPLE.getColor())), true);
} else { } else {
stack.getOrCreateTag().putString(NBT_MODE, LinkingMode.SINGLE.name()); stack.getOrCreateTag().putString(NBT_MODE, LinkingMode.SINGLE.name());
player.displayClientMessage(new TextComponent("Swapped mode to " + LinkingMode.SINGLE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(LinkingMode.SINGLE.getColor())), true); player.displayClientMessage(Component.literal("Swapped mode to " + LinkingMode.SINGLE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(LinkingMode.SINGLE.getColor())), true);
} }
stack.getOrCreateTag().remove(NBT_FIRST); stack.getOrCreateTag().remove(NBT_FIRST);
} else { } else {
ActionMode linkingMode = getActionMode(stack); ActionMode linkingMode = getActionMode(stack);
if (linkingMode == ActionMode.ADD) { if (linkingMode == ActionMode.ADD) {
stack.getOrCreateTag().putString(NBT_ACTION, ActionMode.REMOVE.name()); stack.getOrCreateTag().putString(NBT_ACTION, ActionMode.REMOVE.name());
player.displayClientMessage(new TextComponent("Swapped action to " + ActionMode.REMOVE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(ActionMode.REMOVE.getColor())), true); player.displayClientMessage(Component.literal("Swapped action to " + ActionMode.REMOVE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(ActionMode.REMOVE.getColor())), true);
} else { } else {
stack.getOrCreateTag().putString(NBT_ACTION, ActionMode.ADD.name()); stack.getOrCreateTag().putString(NBT_ACTION, ActionMode.ADD.name());
player.displayClientMessage(new TextComponent("Swapped action to " + ActionMode.ADD.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(ActionMode.ADD.getColor())), true); player.displayClientMessage(Component.literal("Swapped action to " + ActionMode.ADD.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(ActionMode.ADD.getColor())), true);
} }
} }
} }
@ -225,27 +226,27 @@ public class LinkingToolItem extends BasicItem {
LinkingMode linkingMode = getLinkingMode(stack); LinkingMode linkingMode = getLinkingMode(stack);
ActionMode linkingAction = getActionMode(stack); ActionMode linkingAction = getActionMode(stack);
if (key == null) { if (key == null) {
if (stack.getOrCreateTag().contains(NBT_ENDER)){ if (stack.getOrCreateTag().contains(NBT_ENDER)) {
TranslatableComponent text = new TranslatableComponent("linkingtool.ender.frequency"); MutableComponent text = Component.translatable("linkingtool.ender.frequency");
//frequencyDisplay.forEach(item -> text.append(item.getName(new ItemStack(item)))); //frequencyDisplay.forEach(item -> text.append(item.getName(new ItemStack(item))));
tooltip.add(text.withStyle(ChatFormatting.GRAY)); tooltip.add(text.withStyle(ChatFormatting.GRAY));
tooltip.add(new TextComponent("")); tooltip.add(Component.literal(""));
tooltip.add(new TextComponent("")); tooltip.add(Component.literal(""));
tooltip.add(new TranslatableComponent("linkingtool.ender.clear").withStyle(ChatFormatting.GRAY)); tooltip.add(Component.translatable("linkingtool.ender.clear").withStyle(ChatFormatting.GRAY));
} else { } else {
tooltip.add(new TranslatableComponent("linkingtool.linkingmode").withStyle(ChatFormatting.YELLOW) tooltip.add(Component.translatable("linkingtool.linkingmode").withStyle(ChatFormatting.YELLOW)
.append(new TranslatableComponent("linkingtool.linkingmode." + linkingMode.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingMode.getColor())))); .append(Component.translatable("linkingtool.linkingmode." + linkingMode.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingMode.getColor()))));
tooltip.add(new TranslatableComponent("linkingtool.linkingaction").withStyle(ChatFormatting.YELLOW) tooltip.add(Component.translatable("linkingtool.linkingaction").withStyle(ChatFormatting.YELLOW)
.append(new TranslatableComponent("linkingtool.linkingaction." + linkingAction.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingAction.getColor())))); .append(Component.translatable("linkingtool.linkingaction." + linkingAction.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingAction.getColor()))));
if (stack.getOrCreateTag().contains(NBT_CONTROLLER)) { if (stack.getOrCreateTag().contains(NBT_CONTROLLER)) {
tooltip.add(new TranslatableComponent("linkingtool.controller").withStyle(ChatFormatting.YELLOW) tooltip.add(Component.translatable("linkingtool.controller").withStyle(ChatFormatting.YELLOW)
.append(new TextComponent(stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("X") + "" + ChatFormatting.WHITE + ", " + ChatFormatting.DARK_AQUA + stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("Y") + ChatFormatting.WHITE + ", " + ChatFormatting.DARK_AQUA + stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("Z")).withStyle(ChatFormatting.DARK_AQUA))); .append(Component.literal(stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("X") + "" + ChatFormatting.WHITE + ", " + ChatFormatting.DARK_AQUA + stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("Y") + ChatFormatting.WHITE + ", " + ChatFormatting.DARK_AQUA + stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("Z")).withStyle(ChatFormatting.DARK_AQUA)));
} else { } else {
tooltip.add(new TranslatableComponent("linkingtool.controller").withStyle(ChatFormatting.YELLOW).append(new TextComponent("???").withStyle(ChatFormatting.DARK_AQUA))); tooltip.add(Component.translatable("linkingtool.controller").withStyle(ChatFormatting.YELLOW).append(Component.literal("???").withStyle(ChatFormatting.DARK_AQUA)));
} }
tooltip.add(new TextComponent("")); tooltip.add(Component.literal(""));
tooltip.add(new TranslatableComponent("linkingtool.linkingmode." + linkingMode.name().toLowerCase(Locale.ROOT) + ".desc").withStyle(ChatFormatting.GRAY)); tooltip.add(Component.translatable("linkingtool.linkingmode." + linkingMode.name().toLowerCase(Locale.ROOT) + ".desc").withStyle(ChatFormatting.GRAY));
tooltip.add(new TranslatableComponent("linkingtool.use").withStyle(ChatFormatting.GRAY)); tooltip.add(Component.translatable("linkingtool.use").withStyle(ChatFormatting.GRAY));
} }
} }
} }

View File

@ -4,8 +4,8 @@ import com.hrznstudio.titanium.item.BasicItem;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -35,9 +35,9 @@ public class StorageUpgradeItem extends UpgradeItem{
public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List<Component> tooltip, boolean advanced) { public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List<Component> tooltip, boolean advanced) {
super.addTooltipDetails(key, stack, tooltip, advanced); super.addTooltipDetails(key, stack, tooltip, advanced);
if (storageTier == StorageTier.IRON){ if (storageTier == StorageTier.IRON){
tooltip.add(new TranslatableComponent("item.utility.downgrade").withStyle(ChatFormatting.GRAY)); tooltip.add(Component.translatable("item.utility.downgrade").withStyle(ChatFormatting.GRAY));
} else { } else {
tooltip.add(new TranslatableComponent("storageupgrade.desc").withStyle(ChatFormatting.GRAY).append(this.storageTier.getStorageMultiplier() + "")); tooltip.add(Component.translatable("storageupgrade.desc").withStyle(ChatFormatting.GRAY).append(this.storageTier.getStorageMultiplier() + ""));
} }
} }
@ -51,8 +51,8 @@ public class StorageUpgradeItem extends UpgradeItem{
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public Component getName(ItemStack p_41458_) { public Component getName(ItemStack p_41458_) {
Component component = super.getName(p_41458_); Component component = super.getName(p_41458_);
if (component instanceof TranslatableComponent){ if (component instanceof MutableComponent) {
((TranslatableComponent) component).setStyle(Style.EMPTY.withColor(storageTier == StorageTier.NETHERITE && Minecraft.getInstance().level != null ? Color.HSBtoRGB((Minecraft.getInstance().level.getGameTime() % 360) / 360f , 1, 1) : storageTier.getColor())); ((MutableComponent) component).setStyle(Style.EMPTY.withColor(storageTier == StorageTier.NETHERITE && Minecraft.getInstance().level != null ? Color.HSBtoRGB((Minecraft.getInstance().level.getGameTime() % 360) / 360f, 1, 1) : storageTier.getColor()));
} }
return component; return component;
} }

View File

@ -6,8 +6,6 @@ import net.minecraft.ChatFormatting;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.SlotAccess; import net.minecraft.world.entity.SlotAccess;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -64,7 +62,7 @@ public class UpgradeItem extends BasicItem {
@Override @Override
public void fillItemCategory(CreativeModeTab group, NonNullList<ItemStack> items) { public void fillItemCategory(CreativeModeTab group, NonNullList<ItemStack> items) {
if (allowdedIn(group)) { if (this.allowedIn(group)) {
items.add(initNbt(new ItemStack(this))); items.add(initNbt(new ItemStack(this)));
} }
} }
@ -98,17 +96,19 @@ public class UpgradeItem extends BasicItem {
@Override @Override
public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List<Component> tooltip, boolean advanced) { public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List<Component> tooltip, boolean advanced) {
super.addTooltipDetails(key, stack, tooltip, advanced); super.addTooltipDetails(key, stack, tooltip, advanced);
tooltip.add(new TranslatableComponent("upgrade.type").withStyle(ChatFormatting.YELLOW).append(new TranslatableComponent("upgrade.type." + getType().name().toLowerCase(Locale.ROOT)).withStyle(ChatFormatting.WHITE))); tooltip.add(Component.translatable("upgrade.type").withStyle(ChatFormatting.YELLOW).append(Component.translatable("upgrade.type." + getType().name().toLowerCase(Locale.ROOT)).withStyle(ChatFormatting.WHITE)));
Item item = stack.getItem(); Item item = stack.getItem();
if (item.equals(FunctionalStorage.PULLING_UPGRADE.get()) || item.equals(FunctionalStorage.PUSHING_UPGRADE.get()) || item.equals(FunctionalStorage.COLLECTOR_UPGRADE.get())){ if (stack.hasTag()) {
tooltip.add(new TranslatableComponent("item.utility.direction").withStyle(ChatFormatting.YELLOW).append(new TranslatableComponent(WordUtils.capitalize(getDirection(stack).name().toLowerCase(Locale.ROOT))).withStyle(ChatFormatting.WHITE))); if (item.equals(FunctionalStorage.PULLING_UPGRADE.get()) || item.equals(FunctionalStorage.PUSHING_UPGRADE.get()) || item.equals(FunctionalStorage.COLLECTOR_UPGRADE.get())) {
tooltip.add(new TextComponent("")); tooltip.add(Component.translatable("item.utility.direction").withStyle(ChatFormatting.YELLOW).append(Component.translatable(WordUtils.capitalize(getDirection(stack).name().toLowerCase(Locale.ROOT))).withStyle(ChatFormatting.WHITE)));
tooltip.add(new TranslatableComponent("item.utility.direction.desc").withStyle(ChatFormatting.GRAY)); tooltip.add(Component.literal(""));
} tooltip.add(Component.translatable("item.utility.direction.desc").withStyle(ChatFormatting.GRAY));
if (item.equals(FunctionalStorage.REDSTONE_UPGRADE.get()) ){ }
tooltip.add(new TranslatableComponent("item.utility.slot").withStyle(ChatFormatting.YELLOW).append(new TextComponent(stack.getOrCreateTag().getInt("Slot") + "").withStyle(ChatFormatting.WHITE))); if (item.equals(FunctionalStorage.REDSTONE_UPGRADE.get())) {
tooltip.add(new TextComponent("")); tooltip.add(Component.translatable("item.utility.slot").withStyle(ChatFormatting.YELLOW).append(Component.literal(stack.getOrCreateTag().getInt("Slot") + "").withStyle(ChatFormatting.WHITE)));
tooltip.add(new TranslatableComponent("item.utility.direction.desc").withStyle(ChatFormatting.GRAY)); tooltip.add(Component.literal(""));
tooltip.add(Component.translatable("item.utility.direction.desc").withStyle(ChatFormatting.GRAY));
}
} }
} }

View File

@ -14,7 +14,6 @@ import net.minecraftforge.common.crafting.IIngredientSerializer;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Array;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -49,7 +48,7 @@ public class DrawerlessWoodIngredient extends Ingredient {
private List<Item> getWoods(){ private List<Item> getWoods(){
if (woodless == null){ if (woodless == null){
woodless = TagUtil.getAllEntries(ForgeRegistries.ITEMS, ItemTags.PLANKS).stream().filter(item -> !item.getRegistryName().getNamespace().equalsIgnoreCase("minecraft")).collect(Collectors.toList()); woodless = TagUtil.getAllEntries(ForgeRegistries.ITEMS, ItemTags.PLANKS).stream().filter(item -> !ForgeRegistries.ITEMS.getKey(item).getNamespace().equalsIgnoreCase("minecraft")).collect(Collectors.toList());
if (woodless.isEmpty()){ if (woodless.isEmpty()){
woodless.add(Items.OAK_PLANKS); woodless.add(Items.OAK_PLANKS);
} }

View File

@ -10,6 +10,7 @@ import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.*; import java.util.*;
@ -149,10 +150,10 @@ public class CompactingUtil {
} }
private ItemStack findSimilar(ItemStack reference, List<ItemStack> candidates) { private ItemStack findSimilar(ItemStack reference, List<ItemStack> candidates) {
ResourceLocation referenceName = reference.getItem().getRegistryName(); ResourceLocation referenceName = ForgeRegistries.ITEMS.getKey(reference.getItem());
if (referenceName != null) { if (referenceName != null) {
for (ItemStack candidate : candidates) { for (ItemStack candidate : candidates) {
ResourceLocation matchName = candidate.getItem().getRegistryName(); ResourceLocation matchName = ForgeRegistries.ITEMS.getKey(candidate.getItem());
if (matchName != null) { if (matchName != null) {
if (referenceName.getNamespace().equals(matchName.getNamespace())) if (referenceName.getNamespace().equals(matchName.getNamespace()))
return candidate; return candidate;
@ -196,6 +197,11 @@ public class CompactingUtil {
private CraftingContainer createContainerAndFill(int size, ItemStack stack){ private CraftingContainer createContainerAndFill(int size, ItemStack stack){
CraftingContainer inventoryCrafting = new CraftingContainer(new AbstractContainerMenu(null, 0) { CraftingContainer inventoryCrafting = new CraftingContainer(new AbstractContainerMenu(null, 0) {
@Override
public ItemStack quickMoveStack(Player p_38941_, int p_38942_) {
return null;
}
@Override @Override
public boolean stillValid(Player playerIn) { public boolean stillValid(Player playerIn) {
return false; return false;

View File

@ -53,7 +53,7 @@ side = "BOTH"
modId = "minecraft" modId = "minecraft"
mandatory = true mandatory = true
# This version range declares a minimum of the current minecraft version up to but not including the next major version # This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange = "[1.18.1,1.19)" versionRange = "[1.19.1,)"
ordering = "NONE" ordering = "NONE"
side = "BOTH" side = "BOTH"
[[dependencies.functionalstorage]] [[dependencies.functionalstorage]]