From 5cc37fdf2beacb6ca1df4de7518ab4dce0a704ce Mon Sep 17 00:00:00 2001 From: UselessBullets <80850784+UselessBullets@users.noreply.github.com> Date: Tue, 10 Dec 2024 02:23:24 -0600 Subject: [PATCH] Fixed enough issues to get it to build --- build.gradle | 10 +- gradle.properties | 3 +- .../java/turniplabs/halplibe/HalpLibe.java | 1 + .../halplibe/helper/BlockBuilder.java | 156 +++++++++--------- .../halplibe/helper/EntityHelper.java | 87 +++++++--- .../halplibe/helper/ItemBuilder.java | 14 +- .../halplibe/helper/ParticleHelper.java | 11 +- .../mixin/accessors/BlockEntityAccessor.java | 13 -- .../mixin/accessors/BlocksAccessor.java | 20 +++ .../accessors/EntityFireflyFXAccessor.java | 4 +- ...r.java => TileEntityRendererAccessor.java} | 8 +- src/main/resources/halplibe.mixins.json | 4 +- 12 files changed, 189 insertions(+), 142 deletions(-) delete mode 100644 src/main/java/turniplabs/halplibe/mixin/accessors/BlockEntityAccessor.java create mode 100644 src/main/java/turniplabs/halplibe/mixin/accessors/BlocksAccessor.java rename src/main/java/turniplabs/halplibe/mixin/accessors/{BlockEntityRendererAccessor.java => TileEntityRendererAccessor.java} (55%) diff --git a/build.gradle b/build.gradle index e01427c..27fea88 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ version = project.mod_version loom { noIntermediateMappings() - customMinecraftMetadata.set("https://nightly.betterthanadventure.net/bta-${project.bta_version}-manifest.json") + customMinecraftMetadata.set("https://github.com/Turnip-Labs/bta-manifest-repo/releases/download/v${project.bta_version}/${project.bta_version}.json") } repositories { @@ -44,17 +44,17 @@ repositories { url = 'https://maven.thesignalumproject.net/infrastructure' } ivy { - url = "https://github.com/Better-than-Adventure" + url = "https://downloads.betterthanadventure.net/bta-client/${project.bta_channel}/" patternLayout { - artifact "[organisation]/releases/download/v[revision]/[module].jar" + artifact "/v[revision]/client.jar" m2compatible = true } metadataSources { artifact() } } ivy { - url = "https://nightly.betterthanadventure.net" + url = "https://downloads.betterthanadventure.net/bta-server/${project.bta_channel}/" patternLayout { - artifact "/bta-[revision]-client.jar" + artifact "/v[revision]/server.jar" m2compatible = true } metadataSources { artifact() } diff --git a/gradle.properties b/gradle.properties index 2eefebf..9037c8f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,8 @@ org.gradle.jvmargs=-Xmx2G # BTA -bta_version=nightly-2024-10-04 +bta_version=7.3-pre1 +bta_channel=prerelease # Loader loader_version=0.15.6-babric.6-bta diff --git a/src/main/java/turniplabs/halplibe/HalpLibe.java b/src/main/java/turniplabs/halplibe/HalpLibe.java index fb48f10..04ec1f8 100644 --- a/src/main/java/turniplabs/halplibe/HalpLibe.java +++ b/src/main/java/turniplabs/halplibe/HalpLibe.java @@ -15,6 +15,7 @@ public class HalpLibe implements ModInitializer, PreLaunchEntrypoint{ public static final String MOD_ID = "halplibe"; + public static final String LEGACY_NAMESPACE = "halplibe_legacy"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); public static final boolean isClient = FabricLoader.getInstance().getEnvironmentType().equals(EnvType.CLIENT); public static final TomlConfigHandler CONFIG; diff --git a/src/main/java/turniplabs/halplibe/helper/BlockBuilder.java b/src/main/java/turniplabs/halplibe/helper/BlockBuilder.java index 9bddaf1..3cb078e 100644 --- a/src/main/java/turniplabs/halplibe/helper/BlockBuilder.java +++ b/src/main/java/turniplabs/halplibe/helper/BlockBuilder.java @@ -4,26 +4,27 @@ import net.minecraft.client.render.block.color.BlockColorDispatcher; import net.minecraft.client.render.block.model.BlockModel; import net.minecraft.client.render.block.model.BlockModelDispatcher; -import net.minecraft.client.render.block.model.StandardBlockModel; -import net.minecraft.client.render.item.model.BlockItemModel; +import net.minecraft.client.render.block.model.BlockModelStandard; import net.minecraft.client.render.item.model.ItemModel; -import net.minecraft.client.render.item.model.StandardItemModel; -import net.minecraft.client.render.texture.stitcher.IconCoordinate; -import net.minecraft.client.render.texture.stitcher.TextureRegistry; +import net.minecraft.client.render.item.model.ItemModelBlock; +import net.minecraft.client.render.item.model.ItemModelStandard; import net.minecraft.core.block.Block; -import net.minecraft.core.block.FireBlock; +import net.minecraft.core.block.BlockLogic; +import net.minecraft.core.block.BlockLogicFire; +import net.minecraft.core.block.BlockLogicSupplier; +import net.minecraft.core.block.Blocks; import net.minecraft.core.block.tag.BlockTags; import net.minecraft.core.data.tag.Tag; import net.minecraft.core.item.Item; -import net.minecraft.core.item.block.BlockItem; +import net.minecraft.core.item.block.ItemBlock; import net.minecraft.core.sound.BlockSound; import net.minecraft.core.util.helper.Side; import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import turniplabs.halplibe.HalpLibe; +import turniplabs.halplibe.mixin.accessors.BlocksAccessor; import turniplabs.halplibe.util.registry.IdSupplier; import turniplabs.halplibe.util.registry.RunLengthConfig; import turniplabs.halplibe.util.registry.RunReserves; @@ -32,11 +33,13 @@ import java.util.*; import java.util.function.Consumer; import java.util.function.Function; -import java.util.stream.Collectors; public final class BlockBuilder implements Cloneable { - private final String MOD_ID; + private final String modId; + private final String key; + private final String namespaceId; + private final int id; private Float hardness = null; private Float resistance = null; private Integer luminance = null; @@ -48,22 +51,31 @@ public final class BlockBuilder implements Cloneable { private Boolean tickOnLoad = null; private boolean infiniburn = false; private int[] flammability = null; - private Block blockDrop = null; private BlockSound blockSound = null; - private Function blockColor = null; + private Function, BlockColor> blockColor = null; @NotNull - private Function> blockModelSupplier = StandardBlockModel::new; + private Function, BlockModel> blockModelSupplier = BlockModelStandard::new; @NotNull - private Function customItemModelSupplier = BlockItemModel::new; - private BlockLambda customBlockItem = null; - private Tag[] tags = null; + private Function, ItemModel> customItemModelSupplier = ItemModelBlock::new; + private BlockLambda> customBlockItem = null; + private Tag>[] tags = null; @NotNull private String[] textures = new String[6]; @Nullable private String itemIcon = null; - public BlockBuilder(String modId) { - MOD_ID = modId; + public BlockBuilder(String modId, String name, int id) { + this.modId = modId; + this.key = String.format("tile.%s.%s", modId, name.replace("_", ".")); + this.namespaceId = String.format("%s:block/%s", modId, name); + this.id = id; + } + + public BlockBuilder(String modId, String translationKey, String namespacedId, int id) { + this.modId = modId; + this.key = translationKey; + this.namespaceId = namespacedId; + this.id = id; } @Override @@ -80,7 +92,7 @@ public BlockBuilder clone() { } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -92,7 +104,7 @@ public BlockBuilder setTopTexture(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -104,7 +116,7 @@ public BlockBuilder setBottomTexture(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -116,7 +128,7 @@ public BlockBuilder setNorthTexture(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -128,7 +140,7 @@ public BlockBuilder setSouthTexture(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -140,7 +152,7 @@ public BlockBuilder setWestTexture(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -152,7 +164,7 @@ public BlockBuilder setEastTexture(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -169,7 +181,7 @@ public BlockBuilder setTextures(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -184,7 +196,7 @@ public BlockBuilder setSideTextures(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -197,7 +209,7 @@ public BlockBuilder setTopBottomTextures(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -210,7 +222,7 @@ public BlockBuilder setNorthSouthTextures(String texture){ } /** - * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link StandardBlockModel} + * Sets the texture on the side of the block model. Only applies if assigned block model extends {@link BlockModelStandard} * @param texture Texture key * @return Copy of the {@link BlockBuilder} */ @@ -223,7 +235,7 @@ public BlockBuilder setEastWestTextures(String texture){ } /** - * Sets the icon for the {@link Item}'s {@link ItemModel}, only works if the ItemModel used extends {@link StandardItemModel} and the {@link BlockModel} renders as 2D + * Sets the icon for the {@link Item}'s {@link ItemModel}, only works if the ItemModel used extends {@link ItemModelStandard} and the {@link BlockModel} renders as 2D * @param iconKey texture key for the icon for the item to use. Example "minecraft:item/stick" * @return @return Copy of {@link ItemBuilder} */ @@ -377,16 +389,6 @@ public BlockBuilder setTicking(boolean ticking) { return blockBuilder; } - /** - * Makes a block drop a different block than itself upon breaking. - */ - @SuppressWarnings({"unused"}) - public BlockBuilder setBlockDrop(Block droppedBlock) { - BlockBuilder blockBuilder = this.clone(); - blockBuilder.blockDrop = droppedBlock; - return blockBuilder; - } - /** * Sets the block's sound when walking over and breaking it.
* Example code: @@ -413,7 +415,7 @@ public BlockBuilder setBlockSound(BlockSound blockSound) { * } */ @SuppressWarnings({"unused"}) - public BlockBuilder setBlockColor(Function blockColorSupplier) { + public BlockBuilder setBlockColor(Function, BlockColor> blockColorSupplier) { BlockBuilder blockBuilder = this.clone(); blockBuilder.blockColor = blockColorSupplier; return blockBuilder; @@ -429,7 +431,7 @@ public BlockBuilder setBlockColor(Function blockColorSupplier * } */ @SuppressWarnings({"unused"}) - public BlockBuilder setBlockModel(@NotNull Function> blockModelSupplier) { + public BlockBuilder setBlockModel(@NotNull Function, BlockModel> blockModelSupplier) { BlockBuilder blockBuilder = this.clone(); blockBuilder.blockModelSupplier = blockModelSupplier; return blockBuilder; @@ -445,7 +447,7 @@ public BlockBuilder setBlockModel(@NotNull Function> blockM * } */ @SuppressWarnings({"unused"}) - public BlockBuilder setItemModel(@NotNull Function itemModelSupplier) { + public BlockBuilder setItemModel(@NotNull Function, ItemModel> itemModelSupplier) { BlockBuilder blockBuilder = this.clone(); blockBuilder.customItemModelSupplier = itemModelSupplier; return blockBuilder; @@ -461,7 +463,7 @@ public BlockBuilder setItemModel(@NotNull Function itemMod * } */ @SuppressWarnings({"unused"}) - public BlockBuilder setBlockItem(BlockLambda customBlockItem) { + public BlockBuilder setBlockItem(BlockLambda> customBlockItem) { BlockBuilder blockBuilder = this.clone(); blockBuilder.customBlockItem = customBlockItem; return blockBuilder; @@ -472,7 +474,7 @@ public BlockBuilder setBlockItem(BlockLambda customBlockItem) { */ @SafeVarargs @SuppressWarnings({"unused"}) - public final BlockBuilder setTags(Tag... tags) { + public final BlockBuilder setTags(Tag>... tags) { BlockBuilder blockBuilder = this.clone(); blockBuilder.tags = tags; return blockBuilder; @@ -483,7 +485,7 @@ public final BlockBuilder setTags(Tag... tags) { */ @SafeVarargs @SuppressWarnings({"unused"}) - public final BlockBuilder addTags(Tag... tags) { + public final BlockBuilder addTags(Tag>... tags) { BlockBuilder blockBuilder = this.clone(); blockBuilder.tags = ArrayUtils.addAll(this.tags, tags); return blockBuilder; @@ -491,11 +493,13 @@ public final BlockBuilder addTags(Tag... tags) { /** * Applies the builder configuration to the supplied block. - * @param block Input block object + * @param blockLogicSupplier Input block object * @return Returns the input block after builder settings are applied to it. */ @SuppressWarnings({"unused"}) - public T build(T block) { + public Block build(BlockLogicSupplier blockLogicSupplier) { + // TODO add tile entity supplier build arg + Block block = Blocks.register(key, namespaceId, id, blockLogicSupplier); if (hardness != null) { block.withHardness(hardness); } @@ -523,7 +527,7 @@ public T build(T block) { } if (flammability != null) { - FireBlock.setFlammable(block.id, flammability[0], flammability[1]); + BlockLogicFire.setFlammable(block, flammability[0], flammability[1]); } if (infiniburn) { @@ -538,47 +542,40 @@ public T build(T block) { block.setTicking(tickOnLoad); } - if (blockDrop != null) { - block.setDropOverride(blockDrop.id); - } - if (blockSound != null) { block.withSound(blockSound); } Assignment.queueBlockColor(block, blockColor); - BlockItem BlockItem; - - if (customBlockItem != null) { - Item.itemsList[block.id] = BlockItem = customBlockItem.run(block); - } else { - Item.itemsList[block.id] = BlockItem = new BlockItem(block); - } + ItemBlock BlockItem; if (tags != null) { block.withTags(tags); } - Assignment.queueBlockModel(block, blockModelSupplier, textures); - ItemBuilder.Assignment.queueItemModel(BlockItem, customItemModelSupplier, itemIcon); + if (BlocksAccessor.hasInit()) { + block.init(); - List tokens = Arrays.stream(block.getKey().split("\\.")) - .filter(token -> !token.equals(MOD_ID)) - .collect(Collectors.toList()); + if (customBlockItem != null) { + Item.itemsList[block.id()] = BlockItem = customBlockItem.run(block); + } else { + Item.itemsList[block.id()] = BlockItem = new ItemBlock<>(block); + } - List newTokens = new ArrayList<>(); - newTokens.add(MOD_ID); - newTokens.addAll(tokens.subList(1, tokens.size())); + block.getLogic().initializeBlock(); + BlocksAccessor.cacheBlock(block); + } - block.setKey(StringUtils.join(newTokens, '.')); + Assignment.queueBlockModel(block, blockModelSupplier, textures); +// ItemBuilder.Assignment.queueItemModel(BlockItem, customItemModelSupplier, itemIcon); // TODO reimpl item model return block; } @FunctionalInterface public interface BlockLambda { - T run(Block block); + T run(Block block); } public static class Registry{ public static int highestVanilla; @@ -595,8 +592,8 @@ public static class Registry{ */ public static int findOpenIds(int count) { int run = 0; - for (int i = highestVanilla; i < Block.blocksList.length; i++) { - if (Block.blocksList[i] == null && !reserves.isReserved(i)) { + for (int i = highestVanilla; i < Blocks.blocksList.length; i++) { + if (Blocks.blocksList[i] == null && !reserves.isReserved(i)) { if (run >= count) return (i - run); run++; @@ -609,8 +606,8 @@ public static int findOpenIds(int count) { public static int findLength(int id, int terminate) { int run = 0; - for (int i = id; i < Block.blocksList.length; i++) { - if (Block.blocksList[i] == null && !reserves.isReserved(i)) { + for (int i = id; i < Blocks.blocksList.length; i++) { + if (Blocks.blocksList[i] == null && !reserves.isReserved(i)) { run++; if (run >= terminate) return terminate; } else { @@ -671,11 +668,10 @@ public BlockAssignmentEntry(@NotNull T block, @NotNull Function public BlockModel getModel(){ BlockModel model = modelFunction.apply(block); - if (model instanceof StandardBlockModel && textures != null){ - IconCoordinate[] atlasIndices = ((StandardBlockModel) model).atlasIndices; - for (int i = 0; i < atlasIndices.length; i++) { + if (model instanceof BlockModelStandard && textures != null){ + for (int i = 0; i < textures.length; i++) { if (textures[i] != null){ - atlasIndices[i] = TextureRegistry.getTexture(textures[i]); + ((BlockModelStandard) model).setTex(BlockModelStandard.BLOCK_TEXTURES, textures[i], Side.getSideById(i)); } } } @@ -683,11 +679,11 @@ public BlockModel getModel(){ } } public static boolean blockColorDispatcherInitialized = false; - public static final Map> queuedBlockColors = new LinkedHashMap<>(); + public static final Map, Function, BlockColor>> queuedBlockColors = new LinkedHashMap<>(); /** * Queues a BlockColor assignment until the game is ready to do so */ - public static void queueBlockColor(@NotNull Block block, Function blockColorSupplier){ + public static void queueBlockColor(@NotNull Block block, Function, BlockColor> blockColorSupplier){ if (!HalpLibe.isClient) return; if (blockColorSupplier == null) return; diff --git a/src/main/java/turniplabs/halplibe/helper/EntityHelper.java b/src/main/java/turniplabs/halplibe/helper/EntityHelper.java index ec4593b..9cc1bda 100644 --- a/src/main/java/turniplabs/halplibe/helper/EntityHelper.java +++ b/src/main/java/turniplabs/halplibe/helper/EntityHelper.java @@ -1,36 +1,79 @@ package turniplabs.halplibe.helper; -import net.minecraft.client.render.EntityRenderDispatcher; import net.minecraft.client.render.BlockEntityRenderDispatcher; -import net.minecraft.client.render.blockentity.BlockEntityRenderer; +import net.minecraft.client.render.EntityRenderDispatcher; +import net.minecraft.client.render.blockentity.TileEntityRenderer; import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.core.block.entity.BlockEntity; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.block.entity.TileEntityDispatcher; import net.minecraft.core.entity.Entity; import net.minecraft.core.entity.EntityDispatcher; +import net.minecraft.core.util.collection.NamespaceID; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import turniplabs.halplibe.HalpLibe; import turniplabs.halplibe.mixin.accessors.RenderManagerAccessor; -import turniplabs.halplibe.mixin.accessors.BlockEntityAccessor; -import turniplabs.halplibe.mixin.accessors.BlockEntityRendererAccessor; +import turniplabs.halplibe.mixin.accessors.TileEntityRendererAccessor; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Objects; import java.util.function.Supplier; public final class EntityHelper { - public static void createEntity(Class clazz, int id, String name, @NotNull Supplier> rendererSupplier) { - EntityDispatcher.addMapping(clazz, name, id); + + @SuppressWarnings("unused") + public static void createEntity(@NotNull Class clazz, @NotNull NamespaceID namespaceID, @Nullable String nameTranslationKey, @NotNull Supplier> rendererSupplier) { + EntityDispatcher.addMapping(clazz, namespaceID, nameTranslationKey); Assignment.queueEntityRenderer(clazz, rendererSupplier); } - public static void createBlockEntity(Class clazz, String name) { - BlockEntityAccessor.callAddMapping(clazz, name); + @SuppressWarnings({"unused", "deprecation"}) + public static void createEntity(@NotNull Class clazz, @NotNull NamespaceID namespaceID, @Nullable String nameTranslationKey, @NotNull Supplier> rendererSupplier, @NotNull String legacyName, int legacyId) { + EntityDispatcher.addMapping(clazz, namespaceID, nameTranslationKey); + EntityDispatcher.Legacy.addMapping(clazz, legacyName, legacyId); + Assignment.queueEntityRenderer(clazz, rendererSupplier); } - public static void createSpecialBlockEntity(Class clazz, String name, Supplier> rendererSupplier) { - BlockEntityAccessor.callAddMapping(clazz, name); - Assignment.queueBlockEntityRenderer(clazz, rendererSupplier); + @Deprecated + public static void createEntity(@NotNull Class clazz, int id, String name, @NotNull Supplier> rendererSupplier) { + createEntity(clazz, new NamespaceID(HalpLibe.LEGACY_NAMESPACE, name), null, rendererSupplier, name, id); } + + @SuppressWarnings("unused") + public static void createTileEntity(@NotNull Class clazz, @NotNull NamespaceID name) { + TileEntityDispatcher.addMapping(clazz, name); + } + + @SuppressWarnings({"unused", "deprecation"}) + public static void createTileEntity(@NotNull Class clazz, @NotNull NamespaceID name, @NotNull String legacyId) { + TileEntityDispatcher.addMapping(clazz, name); + TileEntityDispatcher.Legacy.addMapping(clazz, legacyId); + } + + @Deprecated + public static void createBlockEntity(Class clazz, String name) { + createTileEntity(clazz, new NamespaceID(HalpLibe.LEGACY_NAMESPACE, name), name); + } + + @SuppressWarnings("unused") + public static void createSpecialTileEntity(@NotNull Class clazz, @NotNull NamespaceID name, @NotNull Supplier> rendererSupplier) { + TileEntityDispatcher.addMapping(clazz, name); + Assignment.queueTileEntityRenderer(clazz, rendererSupplier); + } + + @SuppressWarnings({"unused", "deprecation"}) + public static void createSpecialTileEntity(@NotNull Class clazz, @NotNull NamespaceID name, @NotNull Supplier> rendererSupplier, @NotNull String legacyId) { + TileEntityDispatcher.addMapping(clazz, name); + TileEntityDispatcher.Legacy.addMapping(clazz, legacyId); + Assignment.queueTileEntityRenderer(clazz, rendererSupplier); + } + + @Deprecated + public static void createSpecialBlockEntity(Class clazz, String name, Supplier> rendererSupplier) { + createSpecialTileEntity(clazz, new NamespaceID(HalpLibe.LEGACY_NAMESPACE, name), rendererSupplier, name); + } + public static class Assignment { public static boolean entityRendererDispatcherInitialized = false; public static final Map , Supplier>> queuedEntityRenderer = new LinkedHashMap<>(); @@ -39,7 +82,7 @@ public static class Assignment { */ public static void queueEntityRenderer(@NotNull Class clazz, @NotNull Supplier> rendererSupplier){ if (!HalpLibe.isClient) return; - if (rendererSupplier == null) return; + Objects.requireNonNull(rendererSupplier, "Renderer Supplier must not be null!"); if (entityRendererDispatcherInitialized){ Map, EntityRenderer> entityRenderMap = ((RenderManagerAccessor) EntityRenderDispatcher.instance).getEntityRenderMap(); @@ -50,23 +93,23 @@ public static void queueEntityRenderer(@NotNull Class clazz, @ } queuedEntityRenderer.put(clazz, rendererSupplier); } - public static boolean BlockEntityRendererDispatcherInitialized = false; - public static final Map , Supplier>> queuedBlockEntityRenderer = new LinkedHashMap<>(); + public static boolean TileEntityRendererDispatcherInitialized = false; + public static final Map , Supplier>> queuedTileEntityRenderer = new LinkedHashMap<>(); /** - * Queues a BlockEntityRenderer assignment until the game is ready to do so + * Queues a TileEntityRenderer assignment until the game is ready to do so */ - public static void queueBlockEntityRenderer(@NotNull Class clazz, @NotNull Supplier> rendererSupplier){ + public static void queueTileEntityRenderer(@NotNull Class clazz, @NotNull Supplier> rendererSupplier){ if (!HalpLibe.isClient) return; - if (rendererSupplier == null) return; + Objects.requireNonNull(rendererSupplier, "Renderer Supplier must not be null!"); - if (BlockEntityRendererDispatcherInitialized){ - Map, BlockEntityRenderer> specialRendererMap = ((BlockEntityRendererAccessor) BlockEntityRenderDispatcher.instance).getSpecialRendererMap(); - BlockEntityRenderer renderer = rendererSupplier.get(); + if (TileEntityRendererDispatcherInitialized){ + Map, TileEntityRenderer> specialRendererMap = ((TileEntityRendererAccessor) BlockEntityRenderDispatcher.instance).getSpecialRendererMap(); + TileEntityRenderer renderer = rendererSupplier.get(); specialRendererMap.put(clazz, renderer); renderer.setRenderDispatcher(BlockEntityRenderDispatcher.instance); return; } - queuedBlockEntityRenderer.put(clazz, rendererSupplier); + queuedTileEntityRenderer.put(clazz, rendererSupplier); } } } diff --git a/src/main/java/turniplabs/halplibe/helper/ItemBuilder.java b/src/main/java/turniplabs/halplibe/helper/ItemBuilder.java index 1c66f64..a8f94a7 100644 --- a/src/main/java/turniplabs/halplibe/helper/ItemBuilder.java +++ b/src/main/java/turniplabs/halplibe/helper/ItemBuilder.java @@ -2,7 +2,7 @@ import net.minecraft.client.render.item.model.ItemModel; import net.minecraft.client.render.item.model.ItemModelDispatcher; -import net.minecraft.client.render.item.model.StandardItemModel; +import net.minecraft.client.render.item.model.ItemModelStandard; import net.minecraft.client.render.texture.stitcher.TextureRegistry; import net.minecraft.core.data.tag.Tag; import net.minecraft.core.item.Item; @@ -36,7 +36,7 @@ public final class ItemBuilder implements Cloneable { private Function customItemModelSupplier; public ItemBuilder(String modId){ this.modId = modId; - customItemModelSupplier = (item -> new StandardItemModel(item, null)); + customItemModelSupplier = (item -> new ItemModelStandard(item, null)); } @Override public ItemBuilder clone() { @@ -60,7 +60,7 @@ public ItemBuilder setItemModel(Function modelSupplier){ return builder; } /** - * Sets the icon for the {@link Item}'s {@link ItemModel}, only works if the ItemModel used extends {@link StandardItemModel} + * Sets the icon for the {@link Item}'s {@link ItemModel}, only works if the ItemModel used extends {@link ItemModelStandard} * @param iconKey texture key for the icon for the item to use. Example "minecraft:item/stick" * @return @return Copy of {@link ItemBuilder} */ @@ -216,14 +216,14 @@ public ItemAssignmentEntry(T item, Function modelFunction, String public ItemModel getModel(){ ItemModel model = modelFunction.apply(item); - if (model instanceof StandardItemModel && iconKey != null){ - ((StandardItemModel) model).icon = TextureRegistry.getTexture(iconKey); + if (model instanceof ItemModelStandard && iconKey != null){ + ((ItemModelStandard) model).icon = TextureRegistry.getTexture(iconKey); return model; } - if (model instanceof StandardItemModel && ((StandardItemModel) model).icon == StandardItemModel.ITEM_TEXTURE_UNASSIGNED){ + if (model instanceof ItemModelStandard && ((ItemModelStandard) model).icon == ItemModelStandard.ITEM_TEXTURE_UNASSIGNED){ String namespace = item.getKey().split("\\.")[1]; // Unholy string fuckery - ((StandardItemModel) model).icon = TextureRegistry.getTexture(String.format("%s:item/%s", namespace, + ((ItemModelStandard) model).icon = TextureRegistry.getTexture(String.format("%s:item/%s", namespace, item.getKey().replaceFirst("item." + namespace + ".", "").replace(".", "_"))); return model; } diff --git a/src/main/java/turniplabs/halplibe/helper/ParticleHelper.java b/src/main/java/turniplabs/halplibe/helper/ParticleHelper.java index a50ec95..363fcc3 100644 --- a/src/main/java/turniplabs/halplibe/helper/ParticleHelper.java +++ b/src/main/java/turniplabs/halplibe/helper/ParticleHelper.java @@ -1,8 +1,7 @@ package turniplabs.halplibe.helper; - -import net.minecraft.client.entity.particle.FireflyParticle; import net.minecraft.client.entity.particle.ParticleDispatcher; +import net.minecraft.client.entity.particle.ParticleFirefly; import net.minecraft.client.entity.particle.ParticleLambda; import net.minecraft.core.util.helper.MathHelper; import turniplabs.halplibe.HalpLibe; @@ -23,7 +22,7 @@ public static void createParticle(String name, ParticleLambda lambda) { * Set the firefly particle's color using the vanilla scheme, * which only takes in mid RGB colors and interpolates the rest. */ - public static void setFireflyColor(FireflyParticle particle, float r, float g, float b) { + public static void setFireflyColor(ParticleFirefly particle, float r, float g, float b) { ((EntityFireflyFXAccessor) particle).setMidR(r); ((EntityFireflyFXAccessor) particle).setMidG(g); ((EntityFireflyFXAccessor) particle).setMidB(b); @@ -35,13 +34,13 @@ public static void setFireflyColor(FireflyParticle particle, float r, float g, f ((EntityFireflyFXAccessor) particle).setMaxB(MathHelper.clamp(b + 0.25F, 0.0F, 1.0F)); } - public static void setFireflyColorMin(FireflyParticle particle, float r, float g, float b) { + public static void setFireflyColorMin(ParticleFirefly particle, float r, float g, float b) { ((EntityFireflyFXAccessor) particle).setMinR(r); ((EntityFireflyFXAccessor) particle).setMinG(g); ((EntityFireflyFXAccessor) particle).setMinB(b); } - public static void setFireflyColorMid(FireflyParticle particle, float r, float g, float b) { + public static void setFireflyColorMid(ParticleFirefly particle, float r, float g, float b) { ((EntityFireflyFXAccessor) particle).setMidR(r); ((EntityFireflyFXAccessor) particle).setMidG(g); ((EntityFireflyFXAccessor) particle).setMidB(b); @@ -50,7 +49,7 @@ public static void setFireflyColorMid(FireflyParticle particle, float r, float g ((EntityFXAccessor) particle).setBCol(b); } - public static void setFireflyColorMax(FireflyParticle particle, float r, float g, float b) { + public static void setFireflyColorMax(ParticleFirefly particle, float r, float g, float b) { ((EntityFireflyFXAccessor) particle).setMaxR(r); ((EntityFireflyFXAccessor) particle).setMaxG(g); ((EntityFireflyFXAccessor) particle).setMaxB(b); diff --git a/src/main/java/turniplabs/halplibe/mixin/accessors/BlockEntityAccessor.java b/src/main/java/turniplabs/halplibe/mixin/accessors/BlockEntityAccessor.java deleted file mode 100644 index fedfa83..0000000 --- a/src/main/java/turniplabs/halplibe/mixin/accessors/BlockEntityAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package turniplabs.halplibe.mixin.accessors; - -import net.minecraft.core.block.entity.BlockEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(value = BlockEntity.class, remap = false) -public interface BlockEntityAccessor { - @Invoker("addMapping") - static void callAddMapping(Class clazz, String s) { - throw new AssertionError(); - } -} diff --git a/src/main/java/turniplabs/halplibe/mixin/accessors/BlocksAccessor.java b/src/main/java/turniplabs/halplibe/mixin/accessors/BlocksAccessor.java new file mode 100644 index 0000000..497acd0 --- /dev/null +++ b/src/main/java/turniplabs/halplibe/mixin/accessors/BlocksAccessor.java @@ -0,0 +1,20 @@ +package turniplabs.halplibe.mixin.accessors; + +import net.minecraft.core.block.Block; +import net.minecraft.core.block.Blocks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(value = Blocks.class, remap = false) +public interface BlocksAccessor { + @Accessor("hasInit") + static boolean hasInit() { + throw new AssertionError(); + } + + @Invoker("cacheBlock") + static void cacheBlock(Block container) { + throw new AssertionError(); + } +} diff --git a/src/main/java/turniplabs/halplibe/mixin/accessors/EntityFireflyFXAccessor.java b/src/main/java/turniplabs/halplibe/mixin/accessors/EntityFireflyFXAccessor.java index bb73be6..8cf588f 100644 --- a/src/main/java/turniplabs/halplibe/mixin/accessors/EntityFireflyFXAccessor.java +++ b/src/main/java/turniplabs/halplibe/mixin/accessors/EntityFireflyFXAccessor.java @@ -1,11 +1,11 @@ package turniplabs.halplibe.mixin.accessors; -import net.minecraft.client.entity.particle.FireflyParticle; +import net.minecraft.client.entity.particle.ParticleFirefly; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(value = FireflyParticle.class, remap = false) +@Mixin(value = ParticleFirefly.class, remap = false) public interface EntityFireflyFXAccessor { @Accessor void setMidR(float midR); diff --git a/src/main/java/turniplabs/halplibe/mixin/accessors/BlockEntityRendererAccessor.java b/src/main/java/turniplabs/halplibe/mixin/accessors/TileEntityRendererAccessor.java similarity index 55% rename from src/main/java/turniplabs/halplibe/mixin/accessors/BlockEntityRendererAccessor.java rename to src/main/java/turniplabs/halplibe/mixin/accessors/TileEntityRendererAccessor.java index a9d1857..fbfbd3f 100644 --- a/src/main/java/turniplabs/halplibe/mixin/accessors/BlockEntityRendererAccessor.java +++ b/src/main/java/turniplabs/halplibe/mixin/accessors/TileEntityRendererAccessor.java @@ -1,16 +1,16 @@ package turniplabs.halplibe.mixin.accessors; import net.minecraft.client.render.BlockEntityRenderDispatcher; -import net.minecraft.client.render.blockentity.BlockEntityRenderer; -import net.minecraft.core.block.entity.BlockEntity; +import net.minecraft.client.render.blockentity.TileEntityRenderer; +import net.minecraft.core.block.entity.TileEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import java.util.Map; @Mixin(value = BlockEntityRenderDispatcher.class, remap = false) -public interface BlockEntityRendererAccessor { +public interface TileEntityRendererAccessor { @Accessor("renderers") - Map, BlockEntityRenderer> getSpecialRendererMap(); + Map, TileEntityRenderer> getSpecialRendererMap(); } diff --git a/src/main/resources/halplibe.mixins.json b/src/main/resources/halplibe.mixins.json index 0890b45..78f716c 100644 --- a/src/main/resources/halplibe.mixins.json +++ b/src/main/resources/halplibe.mixins.json @@ -7,14 +7,14 @@ "I18nMixin", "MinecraftMixin", "MinecraftServerMixin", - "accessors.BlockEntityAccessor", - "accessors.BlockEntityRendererAccessor", + "accessors.BlocksAccessor", "accessors.EntityFireflyFXAccessor", "accessors.EntityFXAccessor", "accessors.LanguageAccessor", "accessors.RenderManagerAccessor" ], "client": [ + "accessors.TileEntityRendererAccessor" ], "server": [ ],