From 42d59a6f720ce807048b6481c1b353327055900b Mon Sep 17 00:00:00 2001 From: MrTJP Date: Mon, 10 Jul 2023 13:19:00 -0400 Subject: [PATCH] Port to 1.19.2 --- build.properties | 8 +- .../microblock/api/BlockMicroMaterial.java | 17 +- .../microblock/api/MicroMaterial.java | 13 +- .../microblock/api/MicroMaterialClient.java | 2 +- .../client/MicroBlockPartRenderer.java | 5 +- .../client/MicroblockItemRenderer.java | 6 +- .../microblock/client/MicroblockRender.java | 36 +- .../init/CBMicroblockModContent.java | 648 +++++++++--------- .../microblock/init/DataGenerators.java | 12 +- .../microblock/init/MicroMaterialConfig.java | 7 +- .../microblock/item/ItemMicroBlock.java | 10 +- .../codechicken/microblock/item/SawItem.java | 4 +- .../microblock/part/MicroblockPart.java | 2 +- .../part/MicroblockPartFactory.java | 7 +- .../util/MicroMaterialRegistry.java | 4 +- .../multipart/api/ItemMultipart.java | 11 +- .../api/MultipartClientRegistry.java | 2 +- .../multipart/api/MultipartType.java | 10 +- .../multipart/api/PartConverter.java | 8 +- .../multipart/api/part/AnimateTickPart.java | 5 +- .../multipart/api/part/ModelRenderPart.java | 11 +- .../part/render/PartBakedModelRenderer.java | 18 +- .../api/part/render/PartRenderer.java | 8 +- .../multipart/block/BlockMultipart.java | 10 +- .../multipart/block/TileMultipart.java | 4 +- .../multipart/client/ClientEventHandler.java | 6 +- .../client/MultipartBlockRenderer.java | 56 +- .../multipart/handler/ControlKeyHandler.java | 9 +- .../handler/PlacementConversionHandler.java | 4 +- .../multipart/init/DataGenerators.java | 8 +- .../multipart/init/MultiPartRegistries.java | 13 +- .../internal/mixin/TileEntityMixin.java | 2 +- .../multipart/minecraft/McStatePart.java | 14 - .../multipart/minecraft/ModContent.java | 130 ++-- .../minecraft/RedstoneTorchPart.java | 5 +- .../multipart/minecraft/TorchPart.java | 5 +- .../multipart/trait/TAnimateTickTile.java | 4 +- .../multipart/util/MultipartLoadHandler.java | 4 +- .../multipart/util/OffsetUseOnContext.java | 23 - .../multipart/util/TickScheduler.java | 10 +- src/main/resources/META-INF/mods.toml | 6 +- 41 files changed, 565 insertions(+), 602 deletions(-) delete mode 100644 src/main/java/codechicken/multipart/util/OffsetUseOnContext.java diff --git a/build.properties b/build.properties index 3edfe22..9fd445b 100644 --- a/build.properties +++ b/build.properties @@ -1,8 +1,8 @@ -mc_version=1.18.2 -forge_version=40.0.19 -mod_version=3.1.1 +mc_version=1.19.2 +forge_version=43.2.0 +mod_version=3.2.0 -ccl_version=4.1.4.+ +ccl_version=4.3.2.+ ccl_version_max=5.0.0 mixin_version=2.0.0.20 diff --git a/src/main/java/codechicken/microblock/api/BlockMicroMaterial.java b/src/main/java/codechicken/microblock/api/BlockMicroMaterial.java index 38c31ac..94e8bf6 100644 --- a/src/main/java/codechicken/microblock/api/BlockMicroMaterial.java +++ b/src/main/java/codechicken/microblock/api/BlockMicroMaterial.java @@ -29,6 +29,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.Property; import net.minecraftforge.common.TierSortingRegistry; +import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -50,11 +51,6 @@ public BlockMicroMaterial(Block block) { public BlockMicroMaterial(BlockState state) { this.state = state; - setRegistryName(); - } - - protected void setRegistryName() { - setRegistryName(makeMaterialKey(state)); } @Override @@ -113,11 +109,8 @@ public RenderType getItemRenderLayer() { } @Override - public boolean renderCuboids(CCRenderState ccrs, @Nullable RenderType layer, Iterable cuboids) { - if (layer == null || ItemBlockRenderTypes.canRenderInLayer(state, layer)) { - return MicroblockRender.renderCuboids(ccrs, state, layer, cuboids); - } - return false; + public void renderCuboids(CCRenderState ccrs, @Nullable RenderType layer, Iterable cuboids) { + MicroblockRender.renderCuboids(ccrs, state, layer, cuboids); } @Override @@ -186,7 +179,7 @@ private TextureAtlasSprite getSprite(Level level, BlockPos pos) { */ public static ResourceLocation makeMaterialKey(BlockState state) { Block block = state.getBlock(); - StringBuilder path = new StringBuilder(block.getRegistryName().getPath()); + StringBuilder path = new StringBuilder(ForgeRegistries.BLOCKS.getKey(block).getPath()); if (!state.getProperties().isEmpty()) { path.append("//"); @@ -198,6 +191,6 @@ public static ResourceLocation makeMaterialKey(BlockState state) { path.append(property.getName()).append('.').append(property.getName(unsafeCast(entry.getValue()))); } } - return new ResourceLocation(block.getRegistryName().getNamespace(), path.toString()); + return new ResourceLocation(ForgeRegistries.BLOCKS.getKey(block).getNamespace(), path.toString()); } } diff --git a/src/main/java/codechicken/microblock/api/MicroMaterial.java b/src/main/java/codechicken/microblock/api/MicroMaterial.java index 664b30e..06077f3 100644 --- a/src/main/java/codechicken/microblock/api/MicroMaterial.java +++ b/src/main/java/codechicken/microblock/api/MicroMaterial.java @@ -1,7 +1,9 @@ package codechicken.microblock.api; +import codechicken.microblock.util.MicroMaterialRegistry; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; @@ -11,15 +13,15 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.fml.loading.FMLLoader; -import net.minecraftforge.registries.ForgeRegistryEntry.UncheckedRegistryEntry; import org.jetbrains.annotations.Nullable; +import java.util.Objects; import java.util.function.Consumer; /** * Created by covers1624 on 26/6/22. */ -public abstract class MicroMaterial extends UncheckedRegistryEntry { +public abstract class MicroMaterial { @Nullable Object renderProperties; @@ -28,6 +30,13 @@ public MicroMaterial() { initClient(); } + /** + * @return Key this material is registered under + */ + public ResourceLocation getRegistryName() { + return Objects.requireNonNull(MicroMaterialRegistry.MICRO_MATERIALS.getKey(this)); + } + /** * @return If this material is not opaque. (Glass, Ice, etc.) */ diff --git a/src/main/java/codechicken/microblock/api/MicroMaterialClient.java b/src/main/java/codechicken/microblock/api/MicroMaterialClient.java index ac98f46..ec79077 100644 --- a/src/main/java/codechicken/microblock/api/MicroMaterialClient.java +++ b/src/main/java/codechicken/microblock/api/MicroMaterialClient.java @@ -25,7 +25,7 @@ public static MicroMaterialClient get(MicroMaterial material) { public abstract RenderType getItemRenderLayer(); - public abstract boolean renderCuboids(CCRenderState ccrs, @Nullable RenderType layer, Iterable cuboids); + public abstract void renderCuboids(CCRenderState ccrs, @Nullable RenderType layer, Iterable cuboids); public void renderDynamic(MicroblockPart part, @Nullable ItemTransforms.TransformType transformType, PoseStack pStack, MultiBufferSource buffers, int packedLight, int packedOverlay, float partialTicks) { } diff --git a/src/main/java/codechicken/microblock/client/MicroBlockPartRenderer.java b/src/main/java/codechicken/microblock/client/MicroBlockPartRenderer.java index 4f0afae..449def5 100644 --- a/src/main/java/codechicken/microblock/client/MicroBlockPartRenderer.java +++ b/src/main/java/codechicken/microblock/client/MicroBlockPartRenderer.java @@ -17,12 +17,11 @@ public class MicroBlockPartRenderer implements PartRenderer { public static final MicroBlockPartRenderer INSTANCE = new MicroBlockPartRenderer(); @Override - public boolean renderStatic(MicroblockPart part, @Nullable RenderType layer, CCRenderState ccrs) { + public void renderStatic(MicroblockPart part, @Nullable RenderType layer, CCRenderState ccrs) { MicroMaterialClient clientMaterial = MicroMaterialClient.get(part.material); if (clientMaterial != null) { - return clientMaterial.renderCuboids(ccrs, layer, part.getRenderCuboids(false)); + clientMaterial.renderCuboids(ccrs, layer, part.getRenderCuboids(false)); } - return false; } @Override diff --git a/src/main/java/codechicken/microblock/client/MicroblockItemRenderer.java b/src/main/java/codechicken/microblock/client/MicroblockItemRenderer.java index 1d18b4d..6044ca1 100644 --- a/src/main/java/codechicken/microblock/client/MicroblockItemRenderer.java +++ b/src/main/java/codechicken/microblock/client/MicroblockItemRenderer.java @@ -1,19 +1,19 @@ package codechicken.microblock.client; +import codechicken.lib.model.PerspectiveModelState; import codechicken.lib.render.CCRenderState; import codechicken.lib.render.item.IItemRenderer; import codechicken.lib.util.TransformUtils; import codechicken.lib.vec.Vector3; import codechicken.microblock.api.MicroMaterial; import codechicken.microblock.api.MicroMaterialClient; -import codechicken.microblock.part.StandardMicroFactory; import codechicken.microblock.item.ItemMicroBlock; import codechicken.microblock.part.MicroblockPart; +import codechicken.microblock.part.StandardMicroFactory; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.client.resources.model.ModelState; import net.minecraft.world.item.ItemStack; /** @@ -53,7 +53,7 @@ public void renderItem(ItemStack stack, ItemTransforms.TransformType transformTy } @Override - public ModelState getModelTransform() { + public PerspectiveModelState getModelState() { return TransformUtils.DEFAULT_BLOCK; } diff --git a/src/main/java/codechicken/microblock/client/MicroblockRender.java b/src/main/java/codechicken/microblock/client/MicroblockRender.java index d0d42ef..c1c57a5 100644 --- a/src/main/java/codechicken/microblock/client/MicroblockRender.java +++ b/src/main/java/codechicken/microblock/client/MicroblockRender.java @@ -35,6 +35,7 @@ import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -45,15 +46,13 @@ import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.client.event.DrawSelectionEvent; -import net.minecraftforge.client.model.data.EmptyModelData; -import net.minecraftforge.client.model.data.IModelData; +import net.minecraftforge.client.event.RenderHighlightEvent; +import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.EventPriority; import org.jetbrains.annotations.Nullable; import java.util.OptionalDouble; -import java.util.Random; import static codechicken.microblock.CBMicroblock.MOD_ID; @@ -89,7 +88,7 @@ public static void init() { MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, MicroblockRender::onDrawHighlight); } - private static void onDrawHighlight(DrawSelectionEvent.HighlightBlock event) { + private static void onDrawHighlight(RenderHighlightEvent.Block event) { Camera camera = event.getCamera(); if (camera.getEntity() instanceof Player player) { ItemStack stack = player.getMainHandItem(); @@ -101,7 +100,7 @@ private static void onDrawHighlight(DrawSelectionEvent.HighlightBlock event) { PoseStack pStack = event.getPoseStack(); pStack.pushPose(); pStack.translate(-camera.getPosition().x, -camera.getPosition().y, -camera.getPosition().z); - if (renderHighlight(player, InteractionHand.MAIN_HAND, stack, event.getTarget(), pStack, event.getMultiBufferSource(), event.getPartialTicks())) { + if (renderHighlight(player, InteractionHand.MAIN_HAND, stack, event.getTarget(), pStack, event.getMultiBufferSource(), event.getPartialTick())) { event.setCanceled(true); } @@ -168,10 +167,10 @@ private static void transformFace(Vector3 hit, int side, Matrix4 mat) { mat.translate(0, rHit.y - 0.002, 0); } - public static boolean renderCuboids(CCRenderState ccrs, BlockState state, @Nullable RenderType layer, Iterable cuboids) { + public static void renderCuboids(CCRenderState ccrs, BlockState state, @Nullable RenderType layer, Iterable cuboids) { PipelineState pipeState = PIPELINES.get(); BakedVertexSource vertexSource = BakedVertexSource.instance(); - Random randy = new Random(); + RandomSource randy = RandomSource.create(); BlockRenderDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer(); BlockColors blockColors = Minecraft.getInstance().getBlockColors(); @@ -180,29 +179,29 @@ public static boolean renderCuboids(CCRenderState ccrs, BlockState state, @Nulla BlockPos pos = null; long seed = 42L; BlockAndTintGetter level = null; - IModelData modelData = EmptyModelData.INSTANCE; + ModelData modelData = ModelData.EMPTY; if (layer != null) { pos = ccrs.lightMatrix.pos; seed = state.getSeed(pos); level = new MicroblockLevelProxy(ccrs.lightMatrix.access, pos, state); modelData = model.getModelData(level, pos, state, modelData); + + if (!model.getRenderTypes(state, randy, modelData).contains(layer)) return; } - boolean ret = false; for (Direction face : Direction.BY_3D_DATA) { randy.setSeed(seed); - for (BakedQuad quad : model.getQuads(state, face, randy, modelData)) { - ret |= renderQuad(ccrs, vertexSource, pipeState, blockColors, layer, quad, state, level, pos, cuboids); + for (BakedQuad quad : model.getQuads(state, face, randy, modelData, layer)) { + renderQuad(ccrs, vertexSource, pipeState, blockColors, layer, quad, state, level, pos, cuboids); } } randy.setSeed(seed); - for (BakedQuad quad : model.getQuads(state, null, randy, modelData)) { - ret |= renderQuad(ccrs, vertexSource, pipeState, blockColors, layer, quad, state, level, pos, cuboids); + for (BakedQuad quad : model.getQuads(state, null, randy, modelData, layer)) { + renderQuad(ccrs, vertexSource, pipeState, blockColors, layer, quad, state, level, pos, cuboids); } - return ret; } - private static boolean renderQuad(CCRenderState ccrs, BakedVertexSource vs, PipelineState pipeState, BlockColors blockColors, @Nullable RenderType layer, BakedQuad quad, BlockState state, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos, Iterable cuboids) { + private static void renderQuad(CCRenderState ccrs, BakedVertexSource vs, PipelineState pipeState, BlockColors blockColors, @Nullable RenderType layer, BakedQuad quad, BlockState state, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos, Iterable cuboids) { BakedPipeline pipeline = pipeState.pipeline; QuadClamper clamper = pipeState.clamper; QuadFaceStripper faceStripper = pipeState.faceStripper; @@ -223,10 +222,10 @@ private static boolean renderQuad(CCRenderState ccrs, BakedVertexSource vs, Pipe pipeline.setElementState("tinter", quad.isTinted()); pipeline.prepare(vs); - quad.pipe(pipeline); + pipeline.put(quad); } - if (vs.getVertexCount() <= 0) return false; + if (vs.getVertexCount() <= 0) return; ccrs.setModel(vs); if (layer != null) { @@ -234,7 +233,6 @@ private static boolean renderQuad(CCRenderState ccrs, BakedVertexSource vs, Pipe } else { ccrs.render(); } - return true; } // Exists as a mixin target for mods which change the vertex formats. diff --git a/src/main/java/codechicken/microblock/init/CBMicroblockModContent.java b/src/main/java/codechicken/microblock/init/CBMicroblockModContent.java index 0595fe2..4b154f1 100644 --- a/src/main/java/codechicken/microblock/init/CBMicroblockModContent.java +++ b/src/main/java/codechicken/microblock/init/CBMicroblockModContent.java @@ -6,7 +6,6 @@ import codechicken.microblock.api.MicroMaterial; import codechicken.microblock.item.ItemMicroBlock; import codechicken.microblock.item.SawItem; -import codechicken.microblock.part.MicroblockPartFactory; import codechicken.microblock.part.corner.CornerMicroFactory; import codechicken.microblock.part.edge.EdgeMicroFactory; import codechicken.microblock.part.edge.PostMicroblockFactory; @@ -19,14 +18,16 @@ import net.covers1624.quack.util.CrashLock; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.*; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.Tiers; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.SimpleRecipeSerializer; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RedstoneLampBlock; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; @@ -34,6 +35,7 @@ import net.minecraftforge.registries.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import java.nio.file.Paths; @@ -41,6 +43,7 @@ /** * Created by covers1624 on 26/6/22. */ +@ApiStatus.Internal public class CBMicroblockModContent { private static final Logger LOGGER = LogManager.getLogger(); @@ -82,7 +85,7 @@ public static void init() { ITEMS.register(bus); MULTIPART_TYPES.register(bus); RECIPE_SERIALIZERS.register(bus); - bus.addGenericListener(MicroMaterial.class, CBMicroblockModContent::onRegisterMicroMaterials); + bus.addListener(CBMicroblockModContent::onRegisterMicroMaterials); bus.addListener(CBMicroblockModContent::onCommonSetup); bus.addListener(CBMicroblockModContent::onProcessIMC); } @@ -105,311 +108,331 @@ private static void onProcessIMC(InterModProcessEvent event) { MicroMaterialConfig.parse(Paths.get("config", "custom-micromaterials.cfg")); } - private static void onRegisterMicroMaterials(RegistryEvent.Register event) { + private static void onRegisterMicroMaterials(RegisterEvent event) { // Note: Intentionally kept in same order as Blocks class - IForgeRegistry r = event.getRegistry(); - r.register(new BlockMicroMaterial(Blocks.STONE)); - r.register(new BlockMicroMaterial(Blocks.GRANITE)); - r.register(new BlockMicroMaterial(Blocks.POLISHED_GRANITE)); - r.register(new BlockMicroMaterial(Blocks.DIORITE)); - r.register(new BlockMicroMaterial(Blocks.POLISHED_DIORITE)); - r.register(new BlockMicroMaterial(Blocks.ANDESITE)); - r.register(new BlockMicroMaterial(Blocks.POLISHED_ANDESITE)); - r.register(new BlockMicroMaterial(Blocks.GRASS_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.DIRT)); - r.register(new BlockMicroMaterial(Blocks.COARSE_DIRT)); - r.register(new BlockMicroMaterial(Blocks.PODZOL)); - r.register(new BlockMicroMaterial(Blocks.COBBLESTONE)); - r.register(new BlockMicroMaterial(Blocks.OAK_PLANKS)); - r.register(new BlockMicroMaterial(Blocks.SPRUCE_PLANKS)); - r.register(new BlockMicroMaterial(Blocks.BIRCH_PLANKS)); - r.register(new BlockMicroMaterial(Blocks.JUNGLE_PLANKS)); - r.register(new BlockMicroMaterial(Blocks.ACACIA_PLANKS)); - r.register(new BlockMicroMaterial(Blocks.DARK_OAK_PLANKS)); - r.register(new BlockMicroMaterial(Blocks.SAND)); //TODO Gravity? - r.register(new BlockMicroMaterial(Blocks.RED_SAND)); //TODO Gravity? - r.register(new BlockMicroMaterial(Blocks.GRAVEL)); - r.register(new BlockMicroMaterial(Blocks.GOLD_ORE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_GOLD_ORE)); - r.register(new BlockMicroMaterial(Blocks.IRON_ORE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_IRON_ORE)); - r.register(new BlockMicroMaterial(Blocks.COAL_ORE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_COAL_ORE)); - r.register(new BlockMicroMaterial(Blocks.NETHER_GOLD_ORE)); - r.register(new BlockMicroMaterial(Blocks.OAK_LOG)); - r.register(new BlockMicroMaterial(Blocks.SPRUCE_LOG)); - r.register(new BlockMicroMaterial(Blocks.BIRCH_LOG)); - r.register(new BlockMicroMaterial(Blocks.JUNGLE_LOG)); - r.register(new BlockMicroMaterial(Blocks.ACACIA_LOG)); - r.register(new BlockMicroMaterial(Blocks.DARK_OAK_LOG)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_SPRUCE_LOG)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_BIRCH_LOG)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_JUNGLE_LOG)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_ACACIA_LOG)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_DARK_OAK_LOG)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_OAK_LOG)); - r.register(new BlockMicroMaterial(Blocks.OAK_WOOD)); - r.register(new BlockMicroMaterial(Blocks.SPRUCE_WOOD)); - r.register(new BlockMicroMaterial(Blocks.BIRCH_WOOD)); - r.register(new BlockMicroMaterial(Blocks.JUNGLE_WOOD)); - r.register(new BlockMicroMaterial(Blocks.ACACIA_WOOD)); - r.register(new BlockMicroMaterial(Blocks.DARK_OAK_WOOD)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_OAK_WOOD)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_SPRUCE_WOOD)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_BIRCH_WOOD)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_JUNGLE_WOOD)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_ACACIA_WOOD)); - r.register(new BlockMicroMaterial(Blocks.STRIPPED_DARK_OAK_WOOD)); - r.register(new BlockMicroMaterial(Blocks.OAK_LEAVES)); - r.register(new BlockMicroMaterial(Blocks.SPRUCE_LEAVES)); - r.register(new BlockMicroMaterial(Blocks.BIRCH_LEAVES)); - r.register(new BlockMicroMaterial(Blocks.JUNGLE_LEAVES)); - r.register(new BlockMicroMaterial(Blocks.ACACIA_LEAVES)); - r.register(new BlockMicroMaterial(Blocks.DARK_OAK_LEAVES)); - r.register(new BlockMicroMaterial(Blocks.AZALEA_LEAVES)); - r.register(new BlockMicroMaterial(Blocks.FLOWERING_AZALEA_LEAVES)); - r.register(new BlockMicroMaterial(Blocks.SPONGE)); - r.register(new BlockMicroMaterial(Blocks.WET_SPONGE)); - r.register(new BlockMicroMaterial(Blocks.GLASS)); - r.register(new BlockMicroMaterial(Blocks.LAPIS_ORE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_LAPIS_ORE)); - r.register(new BlockMicroMaterial(Blocks.LAPIS_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.SANDSTONE)); - r.register(new BlockMicroMaterial(Blocks.CHISELED_SANDSTONE)); - r.register(new BlockMicroMaterial(Blocks.CUT_SANDSTONE)); - r.register(new BlockMicroMaterial(Blocks.WHITE_WOOL)); - r.register(new BlockMicroMaterial(Blocks.ORANGE_WOOL)); - r.register(new BlockMicroMaterial(Blocks.MAGENTA_WOOL)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_BLUE_WOOL)); - r.register(new BlockMicroMaterial(Blocks.YELLOW_WOOL)); - r.register(new BlockMicroMaterial(Blocks.LIME_WOOL)); - r.register(new BlockMicroMaterial(Blocks.PINK_WOOL)); - r.register(new BlockMicroMaterial(Blocks.GRAY_WOOL)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_GRAY_WOOL)); - r.register(new BlockMicroMaterial(Blocks.CYAN_WOOL)); - r.register(new BlockMicroMaterial(Blocks.PURPLE_WOOL)); - r.register(new BlockMicroMaterial(Blocks.BLUE_WOOL)); - r.register(new BlockMicroMaterial(Blocks.BROWN_WOOL)); - r.register(new BlockMicroMaterial(Blocks.GREEN_WOOL)); - r.register(new BlockMicroMaterial(Blocks.RED_WOOL)); - r.register(new BlockMicroMaterial(Blocks.BLACK_WOOL)); - r.register(new BlockMicroMaterial(Blocks.GOLD_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.IRON_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.BRICKS)); - r.register(new BlockMicroMaterial(Blocks.TNT)); //TODO, make explode? - r.register(new BlockMicroMaterial(Blocks.BOOKSHELF)); - r.register(new BlockMicroMaterial(Blocks.MOSSY_COBBLESTONE)); - r.register(new BlockMicroMaterial(Blocks.OBSIDIAN)); - r.register(new BlockMicroMaterial(Blocks.DIAMOND_ORE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_DIAMOND_ORE)); - r.register(new BlockMicroMaterial(Blocks.DIAMOND_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.CRAFTING_TABLE)); //TODO Actually function? - r.register(new BlockMicroMaterial(Blocks.REDSTONE_ORE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_REDSTONE_ORE)); - r.register(new BlockMicroMaterial(Blocks.ICE)); - r.register(new BlockMicroMaterial(Blocks.SNOW_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.CLAY)); - r.register(new BlockMicroMaterial(Blocks.PUMPKIN)); - r.register(new BlockMicroMaterial(Blocks.NETHERRACK)); - r.register(new BlockMicroMaterial(Blocks.SOUL_SAND)); - r.register(new BlockMicroMaterial(Blocks.SOUL_SOIL)); - r.register(new BlockMicroMaterial(Blocks.BASALT)); - r.register(new BlockMicroMaterial(Blocks.POLISHED_BASALT)); - r.register(new BlockMicroMaterial(Blocks.GLOWSTONE)); - r.register(new BlockMicroMaterial(Blocks.CARVED_PUMPKIN)); - r.register(new BlockMicroMaterial(Blocks.JACK_O_LANTERN)); - r.register(new BlockMicroMaterial(Blocks.WHITE_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.ORANGE_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.MAGENTA_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_BLUE_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.YELLOW_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.LIME_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.PINK_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.GRAY_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_GRAY_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.CYAN_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.PURPLE_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.BLUE_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.BROWN_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.GREEN_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.RED_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.BLACK_STAINED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.STONE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.MOSSY_STONE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.CRACKED_STONE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.CHISELED_STONE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.BROWN_MUSHROOM_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.RED_MUSHROOM_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.MUSHROOM_STEM)); - r.register(new BlockMicroMaterial(Blocks.MELON)); - r.register(new BlockMicroMaterial(Blocks.MYCELIUM)); - r.register(new BlockMicroMaterial(Blocks.NETHER_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.END_STONE)); - r.register(new BlockMicroMaterial(Blocks.REDSTONE_LAMP.defaultBlockState().setValue(RedstoneLampBlock.LIT, true))); - r.register(new BlockMicroMaterial(Blocks.EMERALD_ORE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_EMERALD_ORE)); - r.register(new BlockMicroMaterial(Blocks.EMERALD_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.REDSTONE_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.NETHER_QUARTZ_ORE)); - r.register(new BlockMicroMaterial(Blocks.QUARTZ_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.CHISELED_QUARTZ_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.QUARTZ_PILLAR)); - r.register(new BlockMicroMaterial(Blocks.WHITE_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.ORANGE_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.MAGENTA_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_BLUE_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.YELLOW_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.LIME_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.PINK_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.GRAY_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_GRAY_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.CYAN_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.PURPLE_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.BLUE_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.BROWN_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.GREEN_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.RED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.BLACK_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.SLIME_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.PRISMARINE)); - r.register(new BlockMicroMaterial(Blocks.PRISMARINE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.DARK_PRISMARINE)); - r.register(new BlockMicroMaterial(Blocks.SEA_LANTERN)); - r.register(new BlockMicroMaterial(Blocks.HAY_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.COAL_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.PACKED_ICE)); - r.register(new BlockMicroMaterial(Blocks.RED_SANDSTONE)); - r.register(new BlockMicroMaterial(Blocks.CHISELED_RED_SANDSTONE)); - r.register(new BlockMicroMaterial(Blocks.CUT_RED_SANDSTONE)); - r.register(new BlockMicroMaterial(Blocks.SMOOTH_STONE)); - r.register(new BlockMicroMaterial(Blocks.SMOOTH_SANDSTONE)); - r.register(new BlockMicroMaterial(Blocks.SMOOTH_QUARTZ)); - r.register(new BlockMicroMaterial(Blocks.SMOOTH_RED_SANDSTONE)); - r.register(new BlockMicroMaterial(Blocks.PURPUR_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.PURPUR_PILLAR)); - r.register(new BlockMicroMaterial(Blocks.END_STONE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.DIRT_PATH)); - r.register(new BlockMicroMaterial(Blocks.MAGMA_BLOCK)); //TODO Burn? - r.register(new BlockMicroMaterial(Blocks.NETHER_WART_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.RED_NETHER_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.BONE_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.WHITE_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.ORANGE_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.MAGENTA_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.YELLOW_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.LIME_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.PINK_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.GRAY_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.CYAN_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.PURPLE_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.BLUE_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.BROWN_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.GREEN_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.RED_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.BLACK_GLAZED_TERRACOTTA)); - r.register(new BlockMicroMaterial(Blocks.WHITE_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.ORANGE_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.MAGENTA_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_BLUE_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.YELLOW_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.LIME_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.PINK_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.GRAY_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.LIGHT_GRAY_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.CYAN_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.PURPLE_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.BLUE_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.BROWN_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.GREEN_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.RED_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.BLACK_CONCRETE)); - r.register(new BlockMicroMaterial(Blocks.WHITE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.ORANGE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.MAGENTA_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.LIGHT_BLUE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.YELLOW_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.LIME_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.PINK_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.GRAY_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.LIGHT_GRAY_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.CYAN_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.PURPLE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.BLUE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.BROWN_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.GREEN_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.RED_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.BLACK_CONCRETE_POWDER)); //TODO Gravity -> Concrete? - r.register(new BlockMicroMaterial(Blocks.DRIED_KELP_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.DEAD_TUBE_CORAL_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.DEAD_BRAIN_CORAL_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.DEAD_BUBBLE_CORAL_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.DEAD_FIRE_CORAL_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.DEAD_HORN_CORAL_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.TUBE_CORAL_BLOCK)); //TODO Dies out of water - r.register(new BlockMicroMaterial(Blocks.BRAIN_CORAL_BLOCK)); //TODO Dies out of water - r.register(new BlockMicroMaterial(Blocks.BUBBLE_CORAL_BLOCK)); //TODO Dies out of water - r.register(new BlockMicroMaterial(Blocks.FIRE_CORAL_BLOCK)); //TODO Dies out of water - r.register(new BlockMicroMaterial(Blocks.HORN_CORAL_BLOCK)); //TODO Dies out of water - r.register(new BlockMicroMaterial(Blocks.BLUE_ICE)); //TODO speed - r.register(new BlockMicroMaterial(Blocks.WARPED_NYLIUM)); - r.register(new BlockMicroMaterial(Blocks.WARPED_WART_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.CRIMSON_NYLIUM)); - r.register(new BlockMicroMaterial(Blocks.CRIMSON_PLANKS)); - r.register(new BlockMicroMaterial(Blocks.WARPED_PLANKS)); - r.register(new BlockMicroMaterial(Blocks.HONEY_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.HONEYCOMB_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.NETHERITE_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.ANCIENT_DEBRIS)); - r.register(new BlockMicroMaterial(Blocks.CRYING_OBSIDIAN)); - r.register(new BlockMicroMaterial(Blocks.LODESTONE)); - r.register(new BlockMicroMaterial(Blocks.BLACKSTONE)); - r.register(new BlockMicroMaterial(Blocks.POLISHED_BLACKSTONE)); - r.register(new BlockMicroMaterial(Blocks.POLISHED_BLACKSTONE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.CRACKED_POLISHED_BLACKSTONE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.CHISELED_POLISHED_BLACKSTONE)); - r.register(new BlockMicroMaterial(Blocks.GILDED_BLACKSTONE)); - r.register(new BlockMicroMaterial(Blocks.CHISELED_NETHER_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.CRACKED_NETHER_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.QUARTZ_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.AMETHYST_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.TUFF)); - r.register(new BlockMicroMaterial(Blocks.CALCITE)); - r.register(new BlockMicroMaterial(Blocks.TINTED_GLASS)); - r.register(new BlockMicroMaterial(Blocks.OXIDIZED_COPPER)); - r.register(new BlockMicroMaterial(Blocks.WEATHERED_COPPER)); - r.register(new BlockMicroMaterial(Blocks.EXPOSED_COPPER)); - r.register(new BlockMicroMaterial(Blocks.COPPER_BLOCK)); //TODO Oxidization (normal -> exposed -> weathered -> oxidized) - r.register(new BlockMicroMaterial(Blocks.COPPER_ORE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_COPPER_ORE)); - r.register(new BlockMicroMaterial(Blocks.OXIDIZED_CUT_COPPER)); - r.register(new BlockMicroMaterial(Blocks.WEATHERED_CUT_COPPER)); - r.register(new BlockMicroMaterial(Blocks.EXPOSED_CUT_COPPER)); - r.register(new BlockMicroMaterial(Blocks.CUT_COPPER)); //TODO Oxidization (normal -> exposed -> weathered -> oxidized) - r.register(new BlockMicroMaterial(Blocks.WAXED_COPPER_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.WAXED_WEATHERED_COPPER)); - r.register(new BlockMicroMaterial(Blocks.WAXED_EXPOSED_COPPER)); - r.register(new BlockMicroMaterial(Blocks.WAXED_OXIDIZED_COPPER)); - r.register(new BlockMicroMaterial(Blocks.WAXED_OXIDIZED_CUT_COPPER)); - r.register(new BlockMicroMaterial(Blocks.WAXED_WEATHERED_CUT_COPPER)); - r.register(new BlockMicroMaterial(Blocks.WAXED_EXPOSED_CUT_COPPER)); - r.register(new BlockMicroMaterial(Blocks.WAXED_CUT_COPPER)); - r.register(new BlockMicroMaterial(Blocks.DRIPSTONE_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.ROOTED_DIRT)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE)); - r.register(new BlockMicroMaterial(Blocks.COBBLED_DEEPSLATE)); - r.register(new BlockMicroMaterial(Blocks.POLISHED_DEEPSLATE)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_TILES)); - r.register(new BlockMicroMaterial(Blocks.DEEPSLATE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.CHISELED_DEEPSLATE)); - r.register(new BlockMicroMaterial(Blocks.CRACKED_DEEPSLATE_BRICKS)); - r.register(new BlockMicroMaterial(Blocks.CRACKED_DEEPSLATE_TILES)); - r.register(new BlockMicroMaterial(Blocks.SMOOTH_BASALT)); - r.register(new BlockMicroMaterial(Blocks.RAW_IRON_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.RAW_COPPER_BLOCK)); - r.register(new BlockMicroMaterial(Blocks.RAW_GOLD_BLOCK)); + event.register(MicroMaterialRegistry.MICRO_MATERIALS.getRegistryKey(), r -> { + registerMaterial(r, new BlockMicroMaterial(Blocks.STONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GRANITE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.POLISHED_GRANITE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DIORITE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.POLISHED_DIORITE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ANDESITE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.POLISHED_ANDESITE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GRASS_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DIRT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.COARSE_DIRT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PODZOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.COBBLESTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.OAK_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SPRUCE_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BIRCH_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.JUNGLE_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ACACIA_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DARK_OAK_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MANGROVE_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SAND)); //TODO Gravity? + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_SAND)); //TODO Gravity? + registerMaterial(r, new BlockMicroMaterial(Blocks.GRAVEL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GOLD_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_GOLD_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.IRON_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_IRON_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.COAL_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_COAL_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.NETHER_GOLD_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.OAK_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SPRUCE_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BIRCH_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.JUNGLE_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ACACIA_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DARK_OAK_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MANGROVE_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MANGROVE_ROOTS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MUDDY_MANGROVE_ROOTS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_SPRUCE_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_BIRCH_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_JUNGLE_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_ACACIA_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_DARK_OAK_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_OAK_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_MANGROVE_LOG)); + registerMaterial(r, new BlockMicroMaterial(Blocks.OAK_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SPRUCE_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BIRCH_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.JUNGLE_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ACACIA_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DARK_OAK_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MANGROVE_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_OAK_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_SPRUCE_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_BIRCH_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_JUNGLE_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_ACACIA_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_DARK_OAK_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STRIPPED_MANGROVE_WOOD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.OAK_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SPRUCE_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BIRCH_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.JUNGLE_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ACACIA_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DARK_OAK_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MANGROVE_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.AZALEA_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.FLOWERING_AZALEA_LEAVES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SPONGE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WET_SPONGE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LAPIS_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_LAPIS_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LAPIS_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SANDSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CHISELED_SANDSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CUT_SANDSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WHITE_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ORANGE_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MAGENTA_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_BLUE_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.YELLOW_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIME_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PINK_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GRAY_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_GRAY_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CYAN_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PURPLE_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLUE_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BROWN_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GREEN_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLACK_WOOL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GOLD_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.IRON_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.TNT)); //TODO, make explode? + registerMaterial(r, new BlockMicroMaterial(Blocks.BOOKSHELF)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MOSSY_COBBLESTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.OBSIDIAN)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DIAMOND_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_DIAMOND_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DIAMOND_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRAFTING_TABLE)); //TODO Actually function? + registerMaterial(r, new BlockMicroMaterial(Blocks.REDSTONE_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_REDSTONE_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ICE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SNOW_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CLAY)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PUMPKIN)); + registerMaterial(r, new BlockMicroMaterial(Blocks.NETHERRACK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SOUL_SAND)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SOUL_SOIL)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BASALT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.POLISHED_BASALT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GLOWSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CARVED_PUMPKIN)); + registerMaterial(r, new BlockMicroMaterial(Blocks.JACK_O_LANTERN)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WHITE_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ORANGE_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MAGENTA_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_BLUE_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.YELLOW_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIME_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PINK_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GRAY_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_GRAY_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CYAN_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PURPLE_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLUE_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BROWN_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GREEN_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLACK_STAINED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.STONE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MOSSY_STONE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRACKED_STONE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CHISELED_STONE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PACKED_MUD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MUD_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BROWN_MUSHROOM_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_MUSHROOM_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MUSHROOM_STEM)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MELON)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MYCELIUM)); + registerMaterial(r, new BlockMicroMaterial(Blocks.NETHER_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.END_STONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.REDSTONE_LAMP.defaultBlockState().setValue(RedstoneLampBlock.LIT, true))); //? + registerMaterial(r, new BlockMicroMaterial(Blocks.EMERALD_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_EMERALD_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.EMERALD_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.REDSTONE_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.NETHER_QUARTZ_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.QUARTZ_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CHISELED_QUARTZ_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.QUARTZ_PILLAR)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WHITE_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ORANGE_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MAGENTA_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_BLUE_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.YELLOW_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIME_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PINK_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GRAY_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_GRAY_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CYAN_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PURPLE_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLUE_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BROWN_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GREEN_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLACK_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SLIME_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PRISMARINE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PRISMARINE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DARK_PRISMARINE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SEA_LANTERN)); + registerMaterial(r, new BlockMicroMaterial(Blocks.HAY_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.COAL_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PACKED_ICE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_SANDSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CHISELED_RED_SANDSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CUT_RED_SANDSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SMOOTH_STONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SMOOTH_SANDSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SMOOTH_QUARTZ)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SMOOTH_RED_SANDSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PURPUR_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PURPUR_PILLAR)); + registerMaterial(r, new BlockMicroMaterial(Blocks.END_STONE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DIRT_PATH)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MAGMA_BLOCK)); //TODO Burn? + registerMaterial(r, new BlockMicroMaterial(Blocks.NETHER_WART_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_NETHER_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BONE_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WHITE_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ORANGE_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MAGENTA_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.YELLOW_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIME_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PINK_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GRAY_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CYAN_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PURPLE_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLUE_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BROWN_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GREEN_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLACK_GLAZED_TERRACOTTA)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WHITE_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ORANGE_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MAGENTA_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_BLUE_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.YELLOW_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIME_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PINK_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GRAY_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_GRAY_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CYAN_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PURPLE_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLUE_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BROWN_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GREEN_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLACK_CONCRETE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WHITE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.ORANGE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.MAGENTA_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_BLUE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.YELLOW_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.LIME_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.PINK_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.GRAY_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.LIGHT_GRAY_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.CYAN_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.PURPLE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.BLUE_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.BROWN_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.GREEN_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.RED_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.BLACK_CONCRETE_POWDER)); //TODO Gravity -> Concrete? + registerMaterial(r, new BlockMicroMaterial(Blocks.DRIED_KELP_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEAD_TUBE_CORAL_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEAD_BRAIN_CORAL_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEAD_BUBBLE_CORAL_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEAD_FIRE_CORAL_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEAD_HORN_CORAL_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.TUBE_CORAL_BLOCK)); //TODO Dies out of water + registerMaterial(r, new BlockMicroMaterial(Blocks.BRAIN_CORAL_BLOCK)); //TODO Dies out of water + registerMaterial(r, new BlockMicroMaterial(Blocks.BUBBLE_CORAL_BLOCK)); //TODO Dies out of water + registerMaterial(r, new BlockMicroMaterial(Blocks.FIRE_CORAL_BLOCK)); //TODO Dies out of water + registerMaterial(r, new BlockMicroMaterial(Blocks.HORN_CORAL_BLOCK)); //TODO Dies out of water + registerMaterial(r, new BlockMicroMaterial(Blocks.BLUE_ICE)); //TODO speed + registerMaterial(r, new BlockMicroMaterial(Blocks.WARPED_NYLIUM)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WARPED_WART_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRIMSON_NYLIUM)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRIMSON_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WARPED_PLANKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.HONEY_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.HONEYCOMB_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.NETHERITE_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ANCIENT_DEBRIS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRYING_OBSIDIAN)); + registerMaterial(r, new BlockMicroMaterial(Blocks.LODESTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.BLACKSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.POLISHED_BLACKSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.POLISHED_BLACKSTONE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRACKED_POLISHED_BLACKSTONE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CHISELED_POLISHED_BLACKSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.GILDED_BLACKSTONE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CHISELED_NETHER_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRACKED_NETHER_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.QUARTZ_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.AMETHYST_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.TUFF)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CALCITE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.TINTED_GLASS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.OXIDIZED_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WEATHERED_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.EXPOSED_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.COPPER_BLOCK)); //TODO Oxidization (normal -> exposed -> weathered -> oxidized) + registerMaterial(r, new BlockMicroMaterial(Blocks.COPPER_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_COPPER_ORE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.OXIDIZED_CUT_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WEATHERED_CUT_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.EXPOSED_CUT_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CUT_COPPER)); //TODO Oxidization (normal -> exposed -> weathered -> oxidized) + registerMaterial(r, new BlockMicroMaterial(Blocks.WAXED_COPPER_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WAXED_WEATHERED_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WAXED_EXPOSED_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WAXED_OXIDIZED_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WAXED_OXIDIZED_CUT_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WAXED_WEATHERED_CUT_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WAXED_EXPOSED_CUT_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.WAXED_CUT_COPPER)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DRIPSTONE_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.ROOTED_DIRT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.MUD)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.COBBLED_DEEPSLATE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.POLISHED_DEEPSLATE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_TILES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.DEEPSLATE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CHISELED_DEEPSLATE)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRACKED_DEEPSLATE_BRICKS)); + registerMaterial(r, new BlockMicroMaterial(Blocks.CRACKED_DEEPSLATE_TILES)); + registerMaterial(r, new BlockMicroMaterial(Blocks.SMOOTH_BASALT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RAW_IRON_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RAW_COPPER_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.RAW_GOLD_BLOCK)); + registerMaterial(r, new BlockMicroMaterial(Blocks.OCHRE_FROGLIGHT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.VERDANT_FROGLIGHT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.PEARLESCENT_FROGLIGHT)); + registerMaterial(r, new BlockMicroMaterial(Blocks.REINFORCED_DEEPSLATE)); + }); + } + + private static void registerMaterial(RegisterEvent.RegisterHelper r, BlockMicroMaterial material) { + r.register(BlockMicroMaterial.makeMaterialKey(material.state), material); } private static void processIMC(InterModProcessEvent event) { @@ -420,7 +443,7 @@ private static void processIMC(InterModProcessEvent event) { String sender = e.senderModId(); Object sent = e.messageSupplier().get(); - MicroMaterial material; + BlockMicroMaterial material; if (sent instanceof Block b) { material = new BlockMicroMaterial(b); } else if (sent instanceof BlockState s) { @@ -435,11 +458,12 @@ private static void processIMC(InterModProcessEvent event) { return; } - if (registry.containsKey(material.getRegistryName())) { - LOGGER.warn("Mod '{}' tried to register a duplicate MicroMaterial. '{}'. Ignoring.", sender, material.getRegistryName()); + ResourceLocation key = BlockMicroMaterial.makeMaterialKey(material.state); + if (registry.containsKey(key)) { + LOGGER.warn("Mod '{}' tried to register a duplicate MicroMaterial. '{}'. Ignoring.", sender, key); return; } - registry.register(material); + registry.register(key, material); }); registry.freeze(); diff --git a/src/main/java/codechicken/microblock/init/DataGenerators.java b/src/main/java/codechicken/microblock/init/DataGenerators.java index 5aac0e2..359014b 100644 --- a/src/main/java/codechicken/microblock/init/DataGenerators.java +++ b/src/main/java/codechicken/microblock/init/DataGenerators.java @@ -10,8 +10,8 @@ import net.minecraft.world.item.Items; import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import org.jetbrains.annotations.Nullable; import static codechicken.microblock.CBMicroblock.MOD_ID; @@ -36,14 +36,10 @@ private static void registerDataGens(GatherDataEvent event) { DataGenerator gen = event.getGenerator(); ExistingFileHelper files = event.getExistingFileHelper(); - if (event.includeClient()) { - gen.addProvider(new ItemModels(gen, files)); - } + gen.addProvider(event.includeClient(), new ItemModels(gen, files)); - if (event.includeServer()) { - gen.addProvider(new ItemTagGen(gen, new BlockTagsProvider(gen), files)); - gen.addProvider(new Recipes(gen)); - } + gen.addProvider(event.includeServer(), new ItemTagGen(gen, new BlockTagsProvider(gen), files)); + gen.addProvider(event.includeServer(), new Recipes(gen)); } private static class ItemTagGen extends ItemTagsProvider { diff --git a/src/main/java/codechicken/microblock/init/MicroMaterialConfig.java b/src/main/java/codechicken/microblock/init/MicroMaterialConfig.java index 526539f..059719d 100644 --- a/src/main/java/codechicken/microblock/init/MicroMaterialConfig.java +++ b/src/main/java/codechicken/microblock/init/MicroMaterialConfig.java @@ -113,10 +113,13 @@ private static void parseLine(String line, int lineNumber, IForgeRegistry items) { - if (!allowdedIn(tab)) return; + if (!allowedIn(tab)) return; for (StandardMicroFactory factory : StandardMicroFactory.FACTORIES.values()) { for (int size : new int[] { 1, 2, 4 }) { diff --git a/src/main/java/codechicken/microblock/item/SawItem.java b/src/main/java/codechicken/microblock/item/SawItem.java index 7c6dd3e..dab3d45 100644 --- a/src/main/java/codechicken/microblock/item/SawItem.java +++ b/src/main/java/codechicken/microblock/item/SawItem.java @@ -18,12 +18,12 @@ public SawItem(Tier tier, Properties properties) { } @Override - public boolean hasContainerItem(ItemStack stack) { + public boolean hasCraftingRemainingItem(ItemStack stack) { return true; } @Override - public ItemStack getContainerItem(ItemStack stack) { + public ItemStack getCraftingRemainingItem(ItemStack stack) { if (canBeDepleted()) { if (stack.getDamageValue() + 1 >= stack.getMaxDamage()) { return ItemStack.EMPTY; diff --git a/src/main/java/codechicken/microblock/part/MicroblockPart.java b/src/main/java/codechicken/microblock/part/MicroblockPart.java index 9e72097..6b4dbb4 100644 --- a/src/main/java/codechicken/microblock/part/MicroblockPart.java +++ b/src/main/java/codechicken/microblock/part/MicroblockPart.java @@ -63,7 +63,7 @@ public void setShape(int size, int slot) { @Override public void writeDesc(MCDataOutput packet) { - packet.writeRegistryIdUnsafe(MicroMaterialRegistry.MICRO_MATERIALS, material); + packet.writeRegistryIdDirect(MicroMaterialRegistry.MICRO_MATERIALS, material); packet.writeByte(shape); } diff --git a/src/main/java/codechicken/microblock/part/MicroblockPartFactory.java b/src/main/java/codechicken/microblock/part/MicroblockPartFactory.java index 9b44f4a..18b7b44 100644 --- a/src/main/java/codechicken/microblock/part/MicroblockPartFactory.java +++ b/src/main/java/codechicken/microblock/part/MicroblockPartFactory.java @@ -18,13 +18,16 @@ public abstract class MicroblockPartFactory extends MultipartType() .setName(new ResourceLocation(MOD_ID, "micro_material")) - .setType(MicroMaterial.class) .disableSaving() .allowModification(), e -> MICRO_MATERIALS = e ); } + @Nullable public static MicroMaterial getMaterial(String name) { return getMaterial(new ResourceLocation(name)); } + @Nullable public static MicroMaterial getMaterial(ResourceLocation name) { return MICRO_MATERIALS.getValue(name); } diff --git a/src/main/java/codechicken/multipart/api/ItemMultipart.java b/src/main/java/codechicken/multipart/api/ItemMultipart.java index 84e7c0d..45fc3b3 100644 --- a/src/main/java/codechicken/multipart/api/ItemMultipart.java +++ b/src/main/java/codechicken/multipart/api/ItemMultipart.java @@ -10,7 +10,6 @@ import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; -import org.apache.commons.lang3.NotImplementedException; import org.jetbrains.annotations.Nullable; /** @@ -23,15 +22,7 @@ public ItemMultipart(Properties properties) { } @Nullable - @Deprecated(since = "1.18.2", forRemoval = true) // Override newPart(MultipartPlaceContext) instead - public MultiPart newPart(UseOnContext context) { - throw new NotImplementedException(); - } - - @Nullable - public MultiPart newPart(MultipartPlaceContext context) { - return newPart((UseOnContext) context); - } + public abstract MultiPart newPart(MultipartPlaceContext context); @Override public InteractionResult useOn(UseOnContext context) { diff --git a/src/main/java/codechicken/multipart/api/MultipartClientRegistry.java b/src/main/java/codechicken/multipart/api/MultipartClientRegistry.java index 0907e7b..acb91b6 100644 --- a/src/main/java/codechicken/multipart/api/MultipartClientRegistry.java +++ b/src/main/java/codechicken/multipart/api/MultipartClientRegistry.java @@ -23,7 +23,7 @@ public static synchronized void register(MultipartType extends ForgeRegistryEntry> { +public abstract class MultipartType { /** * The Forge registry name used by MultipartType. @@ -47,4 +49,8 @@ public MultipartType() { * @return The client-side part. */ public abstract T createPartClient(MCDataInput packet); + + public ResourceLocation getRegistryName() { + return Objects.requireNonNull(MultiPartRegistries.MULTIPART_TYPES.getKey(this)); + } } diff --git a/src/main/java/codechicken/multipart/api/PartConverter.java b/src/main/java/codechicken/multipart/api/PartConverter.java index 1f5d218..404ff68 100644 --- a/src/main/java/codechicken/multipart/api/PartConverter.java +++ b/src/main/java/codechicken/multipart/api/PartConverter.java @@ -9,7 +9,6 @@ import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.registries.ForgeRegistryEntry; import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -18,7 +17,7 @@ /** * Created by covers1624 on 4/17/20. */ -public abstract class PartConverter extends ForgeRegistryEntry { +public abstract class PartConverter { /** * The Forge registry name used by PartConverter. @@ -52,11 +51,6 @@ public ConversionResult> convert(LevelAccessor world, Bloc * was successful. */ public ConversionResult convert(MultipartPlaceContext context) { - return convert((UseOnContext) context); - } - - @Deprecated(since = "1.18.2", forRemoval = true) // Use convert(MultipartPlaceContext) - public ConversionResult convert(UseOnContext context) { return emptyResult(); } diff --git a/src/main/java/codechicken/multipart/api/part/AnimateTickPart.java b/src/main/java/codechicken/multipart/api/part/AnimateTickPart.java index 894a89f..0d74c5d 100644 --- a/src/main/java/codechicken/multipart/api/part/AnimateTickPart.java +++ b/src/main/java/codechicken/multipart/api/part/AnimateTickPart.java @@ -2,10 +2,9 @@ import codechicken.multipart.api.annotation.MultiPartMarker; import codechicken.multipart.trait.TAnimateTickTile; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.block.Block; -import java.util.Random; - /** * Parts that need to do random animation ticks can implement this. * This is passed from {@link Block#animateTick}. @@ -15,5 +14,5 @@ @MultiPartMarker (TAnimateTickTile.class) public interface AnimateTickPart extends MultiPart { - void animateTick(Random random); + void animateTick(RandomSource random); } diff --git a/src/main/java/codechicken/multipart/api/part/ModelRenderPart.java b/src/main/java/codechicken/multipart/api/part/ModelRenderPart.java index 6b16e82..217c38e 100644 --- a/src/main/java/codechicken/multipart/api/part/ModelRenderPart.java +++ b/src/main/java/codechicken/multipart/api/part/ModelRenderPart.java @@ -1,22 +1,17 @@ package codechicken.multipart.api.part; import codechicken.multipart.api.part.render.PartBakedModelRenderer; -import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.data.EmptyModelData; -import net.minecraftforge.client.model.data.IModelData; -import org.jetbrains.annotations.Nullable; +import net.minecraftforge.client.model.data.ModelData; /** * Companion to {@link PartBakedModelRenderer} */ public interface ModelRenderPart extends MultiPart { - boolean canRenderInLayer(@Nullable RenderType layer); - BlockState getCurrentState(); - default IModelData getModelData() { - return EmptyModelData.INSTANCE; + default ModelData getModelData() { + return ModelData.EMPTY; } } diff --git a/src/main/java/codechicken/multipart/api/part/render/PartBakedModelRenderer.java b/src/main/java/codechicken/multipart/api/part/render/PartBakedModelRenderer.java index beabfcc..effd5cd 100644 --- a/src/main/java/codechicken/multipart/api/part/render/PartBakedModelRenderer.java +++ b/src/main/java/codechicken/multipart/api/part/render/PartBakedModelRenderer.java @@ -7,10 +7,10 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.block.state.BlockState; import javax.annotation.Nullable; -import java.util.Random; /** * A simple {@link PartRenderer} partial implementation to render a {@link BlockState}'s {@link BakedModel}. @@ -32,12 +32,16 @@ static PartBakedModelRenderer simple() { } @Override - default boolean renderStatic(T part, @Nullable RenderType layer, CCRenderState ccrs) { - if (!part.canRenderInLayer(layer)) return false; + @SuppressWarnings("ConstantConditions") + default void renderStatic(T part, @Nullable RenderType layer, CCRenderState ccrs) { BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer(); - Random randy = new Random(); - return blockRenderer.renderBatched( + BlockState state = part.getCurrentState(); + RandomSource randy = RandomSource.create(); + + if (layer != null && !blockRenderer.getBlockModel(state).getRenderTypes(state, randy, part.getModelData()).contains(layer)) return; + + blockRenderer.renderBatched( part.getCurrentState(), part.pos(), ccrs.lightMatrix.access, @@ -45,7 +49,7 @@ default boolean renderStatic(T part, @Nullable RenderType layer, CCRenderState c ccrs.getConsumer(), true, randy, - part.getModelData() - ); + part.getModelData(), + layer); // Suppressed warning: Was not marked as nullable } } diff --git a/src/main/java/codechicken/multipart/api/part/render/PartRenderer.java b/src/main/java/codechicken/multipart/api/part/render/PartRenderer.java index 3badd1a..1925401 100644 --- a/src/main/java/codechicken/multipart/api/part/render/PartRenderer.java +++ b/src/main/java/codechicken/multipart/api/part/render/PartRenderer.java @@ -14,7 +14,7 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.world.phys.shapes.VoxelShape; -import net.minecraftforge.client.event.DrawSelectionEvent; +import net.minecraftforge.client.event.RenderHighlightEvent; import javax.annotation.Nullable; @@ -52,10 +52,8 @@ public interface PartRenderer { * @param part The {@link MultiPart} being rendered. * @param layer The block {@link RenderType} layer being rendered. null for {@link #renderBreaking} * @param ccrs The {@link CCRenderState} instance to render with. - * @return If any vertices were drawn. */ - default boolean renderStatic(T part, @Nullable RenderType layer, CCRenderState ccrs) { - return false; + default void renderStatic(T part, @Nullable RenderType layer, CCRenderState ccrs) { } /** @@ -103,7 +101,7 @@ default void renderDynamic(T part, PoseStack pStack, MultiBufferSource buffers, /** * Override the drawing of the selection box around this part. *

- * This is called with the context of {@link DrawSelectionEvent.HighlightBlock}. + * This is called with the context of {@link RenderHighlightEvent.Block}. * * @param part The {@link MultiPart} being rendered. * @param hit The {@link PartRayTraceResult}. diff --git a/src/main/java/codechicken/multipart/block/BlockMultipart.java b/src/main/java/codechicken/multipart/block/BlockMultipart.java index 722d5fa..3e8b424 100644 --- a/src/main/java/codechicken/multipart/block/BlockMultipart.java +++ b/src/main/java/codechicken/multipart/block/BlockMultipart.java @@ -14,6 +14,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; @@ -41,12 +42,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.IBlockRenderProperties; +import net.minecraftforge.client.extensions.common.IClientBlockExtensions; import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; -import java.util.Random; import java.util.function.Consumer; /** @@ -62,8 +62,8 @@ public BlockMultipart() { } @Override - public void initializeClient(Consumer consumer) { - consumer.accept(new IBlockRenderProperties() { + public void initializeClient(Consumer consumer) { + consumer.accept(new IClientBlockExtensions() { @Override public boolean addHitEffects(BlockState state, Level level, HitResult target, ParticleEngine manager) { if (target instanceof PartRayTraceResult hit) { @@ -305,7 +305,7 @@ public int getSignal(BlockState state, BlockGetter world, BlockPos pos, Directio @Override @OnlyIn (Dist.CLIENT) - public void animateTick(BlockState state, Level world, BlockPos pos, Random rand) { + public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource rand) { TileMultipart tile = getTile(world, pos); if (tile != null) { tile.animateTick(rand); diff --git a/src/main/java/codechicken/multipart/block/TileMultipart.java b/src/main/java/codechicken/multipart/block/TileMultipart.java index fe8820e..044b322 100644 --- a/src/main/java/codechicken/multipart/block/TileMultipart.java +++ b/src/main/java/codechicken/multipart/block/TileMultipart.java @@ -21,6 +21,7 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; +import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; @@ -46,7 +47,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Random; import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -466,7 +466,7 @@ public AABB getRenderBoundingBox() { return c.add(worldPosition).aabb(); } - public void animateTick(Random random) { } + public void animateTick(RandomSource random) { } public boolean isClientTile() { return false; } diff --git a/src/main/java/codechicken/multipart/client/ClientEventHandler.java b/src/main/java/codechicken/multipart/client/ClientEventHandler.java index 8b18b09..b140849 100644 --- a/src/main/java/codechicken/multipart/client/ClientEventHandler.java +++ b/src/main/java/codechicken/multipart/client/ClientEventHandler.java @@ -13,7 +13,7 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraftforge.client.event.DrawSelectionEvent; +import net.minecraftforge.client.event.RenderHighlightEvent; import net.minecraftforge.common.MinecraftForge; import static net.covers1624.quack.util.SneakyUtils.unsafeCast; @@ -27,11 +27,11 @@ public static void init() { MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::onDrawBlockHighlight); } - private static void onDrawBlockHighlight(DrawSelectionEvent.HighlightBlock event) { + private static void onDrawBlockHighlight(RenderHighlightEvent.Block event) { Camera camera = event.getCamera(); PoseStack mStack = event.getPoseStack(); MultiBufferSource buffers = event.getMultiBufferSource(); - float partialTicks = event.getPartialTicks(); + float partialTicks = event.getPartialTick(); BlockHitResult target = event.getTarget(); if (!(target instanceof PartRayTraceResult hit)) return; diff --git a/src/main/java/codechicken/multipart/client/MultipartBlockRenderer.java b/src/main/java/codechicken/multipart/client/MultipartBlockRenderer.java index b043c37..54af2dc 100644 --- a/src/main/java/codechicken/multipart/client/MultipartBlockRenderer.java +++ b/src/main/java/codechicken/multipart/client/MultipartBlockRenderer.java @@ -18,12 +18,11 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.MinecraftForgeClient; -import net.minecraftforge.client.model.data.IModelData; - -import java.util.Random; +import net.minecraftforge.client.model.data.ModelData; +import org.jetbrains.annotations.Nullable; import static net.covers1624.quack.util.SneakyUtils.unsafeCast; @@ -33,48 +32,45 @@ public class MultipartBlockRenderer implements ICCBlockRenderer { @Override - public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState blockState) { + public boolean canHandleBlock(BlockAndTintGetter world, BlockPos pos, BlockState blockState, @Nullable RenderType renderType) { return blockState.getBlock() == CBMultipartModContent.MULTIPART_BLOCK.get(); } @Override - public boolean renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, Random random, IModelData data) { + public void renderBlock(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, RandomSource random, ModelData data, @Nullable RenderType renderType) { TileMultipart tile = BlockMultipart.getTile(world, pos); - if (tile != null) { - CCRenderState ccrs = CCRenderState.instance(); - ccrs.reset(); - ccrs.bind(new TransformingVertexConsumer(builder, mStack), DefaultVertexFormat.BLOCK); - ccrs.lightMatrix.locate(world, pos); - return renderStatic(tile, MinecraftForgeClient.getRenderType(), ccrs); - } - return false; + if (tile == null) return; + + CCRenderState ccrs = CCRenderState.instance(); + ccrs.reset(); + ccrs.bind(new TransformingVertexConsumer(builder, mStack), DefaultVertexFormat.BLOCK); + ccrs.lightMatrix.locate(world, pos); + renderStatic(tile, renderType, ccrs); } @Override - public void renderBreaking(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, IModelData data) { + public void renderBreaking(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack mStack, VertexConsumer builder, ModelData data) { TileMultipart tile = BlockMultipart.getTile(world, pos); - if (tile != null) { - CCRenderState ccrs = CCRenderState.instance(); - ccrs.reset(); - mStack.pushPose(); - ccrs.bind(new TransformingVertexConsumer(builder, mStack), DefaultVertexFormat.BLOCK); - ccrs.overlay = OverlayTexture.NO_OVERLAY; - ccrs.brightness = LevelRenderer.getLightColor(world, state, pos); - ccrs.lightMatrix.locate(world, pos); - renderBreaking(tile, ccrs); - mStack.popPose(); - } + if (tile == null) return; + + CCRenderState ccrs = CCRenderState.instance(); + ccrs.reset(); + mStack.pushPose(); + ccrs.bind(new TransformingVertexConsumer(builder, mStack), DefaultVertexFormat.BLOCK); + ccrs.overlay = OverlayTexture.NO_OVERLAY; + ccrs.brightness = LevelRenderer.getLightColor(world, state, pos); + ccrs.lightMatrix.locate(world, pos); + renderBreaking(tile, ccrs); + mStack.popPose(); } - private boolean renderStatic(TileMultipart tile, RenderType type, CCRenderState ccrs) { - boolean ret = false; + private void renderStatic(TileMultipart tile, @Nullable RenderType type, CCRenderState ccrs) { for (MultiPart part : tile.getPartList()) { PartRenderer renderer = MultipartClientRegistry.getRenderer(part.getType()); if (renderer != null) { - ret |= renderer.renderStatic(unsafeCast(part), type, ccrs); + renderer.renderStatic(unsafeCast(part), type, ccrs); } } - return ret; } private void renderBreaking(TileMultipart tile, CCRenderState ccrs) { diff --git a/src/main/java/codechicken/multipart/handler/ControlKeyHandler.java b/src/main/java/codechicken/multipart/handler/ControlKeyHandler.java index de4e496..8cef9b2 100644 --- a/src/main/java/codechicken/multipart/handler/ControlKeyHandler.java +++ b/src/main/java/codechicken/multipart/handler/ControlKeyHandler.java @@ -6,10 +6,9 @@ import net.covers1624.quack.util.CrashLock; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; -import net.minecraftforge.client.ClientRegistry; +import net.minecraftforge.client.event.RegisterKeyMappingsEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TickEvent; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.lwjgl.glfw.GLFW; @@ -26,11 +25,11 @@ public class ControlKeyHandler { public static void init() { LOCK.lock(); MinecraftForge.EVENT_BUS.addListener(ControlKeyHandler::tick); - FMLJavaModLoadingContext.get().getModEventBus().addListener(ControlKeyHandler::setup); + FMLJavaModLoadingContext.get().getModEventBus().addListener(ControlKeyHandler::register); } - private static void setup(FMLClientSetupEvent event) { - ClientRegistry.registerKeyBinding(KEY); + private static void register(RegisterKeyMappingsEvent event) { + event.register(KEY); } private static void tick(TickEvent.ClientTickEvent event) { diff --git a/src/main/java/codechicken/multipart/handler/PlacementConversionHandler.java b/src/main/java/codechicken/multipart/handler/PlacementConversionHandler.java index 9e2305a..a464584 100644 --- a/src/main/java/codechicken/multipart/handler/PlacementConversionHandler.java +++ b/src/main/java/codechicken/multipart/handler/PlacementConversionHandler.java @@ -35,9 +35,9 @@ public static void init() { } private static void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) { - Level world = event.getWorld(); + Level world = event.getLevel(); - if (place(event.getPlayer(), event.getHand())) { + if (place(event.getEntity(), event.getHand())) { event.setCanceled(true); event.setCancellationResult(InteractionResult.sidedSuccess(world.isClientSide)); } diff --git a/src/main/java/codechicken/multipart/init/DataGenerators.java b/src/main/java/codechicken/multipart/init/DataGenerators.java index 41f1504..5a2c24e 100644 --- a/src/main/java/codechicken/multipart/init/DataGenerators.java +++ b/src/main/java/codechicken/multipart/init/DataGenerators.java @@ -5,9 +5,8 @@ import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.data.ExistingFileHelper; -import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.data.event.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import static codechicken.multipart.CBMultipart.MOD_ID; @@ -26,9 +25,8 @@ public static void init() { public static void gatherDataGenerators(GatherDataEvent event) { DataGenerator gen = event.getGenerator(); ExistingFileHelper files = event.getExistingFileHelper(); - if (event.includeClient()) { - gen.addProvider(new BlockStates(gen, files)); - } + + gen.addProvider(event.includeClient(), new BlockStates(gen, files)); } private static class BlockStates extends BlockStateProvider { diff --git a/src/main/java/codechicken/multipart/init/MultiPartRegistries.java b/src/main/java/codechicken/multipart/init/MultiPartRegistries.java index 34be77a..8ee5069 100644 --- a/src/main/java/codechicken/multipart/init/MultiPartRegistries.java +++ b/src/main/java/codechicken/multipart/init/MultiPartRegistries.java @@ -14,7 +14,6 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.NewRegistryEvent; import net.minecraftforge.registries.RegistryBuilder; @@ -26,8 +25,6 @@ import java.util.List; import java.util.Objects; -import static net.covers1624.quack.util.SneakyUtils.unsafeCast; - /** * Created by covers1624 on 3/16/20. */ @@ -37,7 +34,7 @@ public class MultiPartRegistries { private static final CrashLock LOCK = new CrashLock("Already initialized."); public static IForgeRegistry> MULTIPART_TYPES; - private static IForgeRegistry PART_CONVERTERS; + public static IForgeRegistry PART_CONVERTERS; public static void init() { LOCK.lock(); @@ -47,11 +44,9 @@ public static void init() { private static void createRegistries(NewRegistryEvent event) { event.create(new RegistryBuilder>() .setName(MultipartType.MULTIPART_TYPES) - .setType(unsafeCast(MultipartType.class)) - .disableSaving(), e -> MULTIPART_TYPES = (ForgeRegistry>) e); + .disableSaving(), e -> MULTIPART_TYPES = e); event.create(new RegistryBuilder() .setName(PartConverter.PART_CONVERTERS) - .setType(PartConverter.class) .disableOverrides() .disableSaving() .disableSync(), @@ -76,7 +71,7 @@ public static void writePart(MCDataOutput data, MultiPart part) { if (!MULTIPART_TYPES.containsKey(name)) { throw new RuntimeException("MultiPartType with name '" + name + "' is not registered."); } - data.writeRegistryIdUnsafe(MULTIPART_TYPES, type); + data.writeRegistryIdDirect(MULTIPART_TYPES, type); part.writeDesc(data); } @@ -93,7 +88,7 @@ public static void writePart(MCDataOutput data, MultiPart part) { * @return The TMultiPart. */ public static MultiPart readPart(MCDataInput data) { - MultipartType type = data.readRegistryIdUnsafe(MULTIPART_TYPES); + MultipartType type = data.readRegistryIdDirect(MULTIPART_TYPES); MultiPart part = type.createPartClient(data); part.readDesc(data); return part; diff --git a/src/main/java/codechicken/multipart/internal/mixin/TileEntityMixin.java b/src/main/java/codechicken/multipart/internal/mixin/TileEntityMixin.java index ced1929..ece5b8b 100644 --- a/src/main/java/codechicken/multipart/internal/mixin/TileEntityMixin.java +++ b/src/main/java/codechicken/multipart/internal/mixin/TileEntityMixin.java @@ -24,7 +24,7 @@ public class TileEntityMixin { ) private static void onLoadStatic(BlockPos pos, BlockState state, CompoundTag tag, CallbackInfoReturnable cir) { String s = tag.getString("id"); - if (CBMultipartModContent.MULTIPART_TILE_TYPE.get().getRegistryName().toString().equals(s)) { + if (CBMultipartModContent.MULTIPART_TILE_TYPE.getId().toString().equals(s)) { cir.setReturnValue(TileMultipart.fromNBT(tag, pos)); } } diff --git a/src/main/java/codechicken/multipart/minecraft/McStatePart.java b/src/main/java/codechicken/multipart/minecraft/McStatePart.java index 76f38da..6b63be9 100644 --- a/src/main/java/codechicken/multipart/minecraft/McStatePart.java +++ b/src/main/java/codechicken/multipart/minecraft/McStatePart.java @@ -7,8 +7,6 @@ import codechicken.multipart.api.part.*; import codechicken.multipart.util.PartRayTraceResult; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -23,8 +21,6 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.model.data.EmptyModelData; -import net.minecraftforge.client.model.data.IModelData; import org.jetbrains.annotations.Nullable; import java.util.Collections; @@ -76,21 +72,11 @@ public void readDesc(MCDataInput packet) { state = NbtUtils.readBlockState(packet.readCompoundNBT()); } - @Override - public boolean canRenderInLayer(RenderType layer) { - return ItemBlockRenderTypes.canRenderInLayer(state, layer); - } - @Override public BlockState getCurrentState() { return state; } - @Override - public IModelData getModelData() { - return EmptyModelData.INSTANCE; - } - @Nullable public MultiPart setStateOnPlacement(BlockPlaceContext context) { BlockState state = defaultBlockState().getBlock().getStateForPlacement(context); diff --git a/src/main/java/codechicken/multipart/minecraft/ModContent.java b/src/main/java/codechicken/multipart/minecraft/ModContent.java index b1c32ee..ff5596d 100644 --- a/src/main/java/codechicken/multipart/minecraft/ModContent.java +++ b/src/main/java/codechicken/multipart/minecraft/ModContent.java @@ -5,6 +5,7 @@ import codechicken.multipart.api.PartConverter; import codechicken.multipart.api.SimpleMultipartType; import codechicken.multipart.api.part.MultiPart; +import codechicken.multipart.init.MultiPartRegistries; import codechicken.multipart.util.MultipartPlaceContext; import net.minecraft.core.BlockPos; import net.minecraft.world.item.Item; @@ -13,12 +14,11 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.ObjectHolder; +import net.minecraftforge.registries.RegisterEvent; import java.util.Collection; import java.util.Collections; @@ -28,94 +28,96 @@ /** * Created by covers1624 on 1/9/20. */ -@ObjectHolder ("minecraft") public class ModContent { - @ObjectHolder ("torch") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:torch") public static MultipartType torchPartType; - @ObjectHolder ("soul_torch") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:soul_torch") public static MultipartType soulTorchPartType; - @ObjectHolder ("redstone_torch") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:redstone_torch") public static MultipartType redstoneTorchPartType; - @ObjectHolder ("lever") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:lever") public static MultipartType leverPartType; - @ObjectHolder ("stone_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:stone_button") public static MultipartType stoneButtonPartType; - @ObjectHolder ("polished_blackstone_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:polished_blackstone_button") public static MultipartType polishedBlackstoneButtonPartType; - @ObjectHolder ("oak_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:oak_button") public static MultipartType oakButtonPartType; - @ObjectHolder ("spruce_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:spruce_button") public static MultipartType spruceButtonPartType; - @ObjectHolder ("birch_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:birch_button") public static MultipartType birchButtonPartType; - @ObjectHolder ("jungle_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:jungle_button") public static MultipartType jungleButtonPartType; - @ObjectHolder ("acacia_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:acacia_button") public static MultipartType acaciaButtonPartType; - @ObjectHolder ("dark_oak_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:dark_oak_button") public static MultipartType darkOakButtonPartType; - @ObjectHolder ("crimson_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:crimson_button") public static MultipartType crimsonButtonPartType; - @ObjectHolder ("warped_button") + @ObjectHolder (registryName = "cb_multipart:multipart_types", value = "minecraft:warped_button") public static MultipartType warpedButtonPartType; @SubscribeEvent - public static void onRegisterMultiParts(RegistryEvent.Register> event) { - IForgeRegistry> r = event.getRegistry(); - ModContainer container = ModLoadingContext.get().getActiveContainer(); - ModLoadingContext.get().setActiveContainer(null); - - r.register(new SimpleMultipartType<>(e -> new TorchPart()).setRegistryName("torch")); - r.register(new SimpleMultipartType<>(e -> new SoulTorchPart()).setRegistryName("soul_torch")); - r.register(new SimpleMultipartType<>(e -> new RedstoneTorchPart()).setRegistryName("redstone_torch")); - r.register(new SimpleMultipartType<>(e -> new LeverPart()).setRegistryName("lever")); - - r.register(new SimpleMultipartType<>(e -> new ButtonPart.StoneButtonPart()).setRegistryName("stone_button")); - - r.register(new SimpleMultipartType<>(e -> new ButtonPart.PolishedBlackstoneButtonPart()).setRegistryName("polished_blackstone_button")); - r.register(new SimpleMultipartType<>(e -> new ButtonPart.OakButtonPart()).setRegistryName("oak_button")); - r.register(new SimpleMultipartType<>(e -> new ButtonPart.SpruceButtonPart()).setRegistryName("spruce_button")); - r.register(new SimpleMultipartType<>(e -> new ButtonPart.BirchButtonPart()).setRegistryName("birch_button")); - r.register(new SimpleMultipartType<>(e -> new ButtonPart.JungleButtonPart()).setRegistryName("jungle_button")); - r.register(new SimpleMultipartType<>(e -> new ButtonPart.AcaciaButtonPart()).setRegistryName("acacia_button")); - r.register(new SimpleMultipartType<>(e -> new ButtonPart.DarkOakButtonPart()).setRegistryName("dark_oak_button")); - r.register(new SimpleMultipartType<>(e -> new ButtonPart.CrimsonButtonPart()).setRegistryName("crimson_button")); - r.register(new SimpleMultipartType<>(e -> new ButtonPart.WarpedButtonPart()).setRegistryName("warped_button")); - - ModLoadingContext.get().setActiveContainer(container); + public static void onRegisterMultiParts(RegisterEvent event) { + event.register(MultiPartRegistries.MULTIPART_TYPES.getRegistryKey(), r -> { + ModContainer container = ModLoadingContext.get().getActiveContainer(); + ModLoadingContext.get().setActiveContainer(null); + + r.register("torch", new SimpleMultipartType<>(e -> new TorchPart())); + r.register("soul_torch", new SimpleMultipartType<>(e -> new SoulTorchPart())); + r.register("redstone_torch", new SimpleMultipartType<>(e -> new RedstoneTorchPart())); + r.register("lever", new SimpleMultipartType<>(e -> new LeverPart())); + + r.register("stone_button", new SimpleMultipartType<>(e -> new ButtonPart.StoneButtonPart())); + + r.register("polished_blackstone_button", new SimpleMultipartType<>(e -> new ButtonPart.PolishedBlackstoneButtonPart())); + r.register("oak_button", new SimpleMultipartType<>(e -> new ButtonPart.OakButtonPart())); + r.register("spruce_button", new SimpleMultipartType<>(e -> new ButtonPart.SpruceButtonPart())); + r.register("birch_button", new SimpleMultipartType<>(e -> new ButtonPart.BirchButtonPart())); + r.register("jungle_button", new SimpleMultipartType<>(e -> new ButtonPart.JungleButtonPart())); + r.register("acacia_button", new SimpleMultipartType<>(e -> new ButtonPart.AcaciaButtonPart())); + r.register("dark_oak_button", new SimpleMultipartType<>(e -> new ButtonPart.DarkOakButtonPart())); + r.register("crimson_button", new SimpleMultipartType<>(e -> new ButtonPart.CrimsonButtonPart())); + r.register("warped_button", new SimpleMultipartType<>(e -> new ButtonPart.WarpedButtonPart())); + + ModLoadingContext.get().setActiveContainer(container); + }); } @SubscribeEvent - public static void onRegisterMultiPartConverters(RegistryEvent.Register event) { - IForgeRegistry r = event.getRegistry(); - - ModContainer container = ModLoadingContext.get().getActiveContainer(); - ModLoadingContext.get().setActiveContainer(null); - - r.register(new Converter<>(TorchPart::new, TorchPart::new, Items.TORCH, Blocks.TORCH, Blocks.WALL_TORCH).setRegistryName("torch")); - r.register(new Converter<>(SoulTorchPart::new, SoulTorchPart::new, Items.SOUL_TORCH, Blocks.SOUL_TORCH, Blocks.SOUL_WALL_TORCH).setRegistryName("soul_torch")); - r.register(new Converter<>(RedstoneTorchPart::new, RedstoneTorchPart::new, Items.REDSTONE_TORCH, Blocks.REDSTONE_TORCH, Blocks.REDSTONE_WALL_TORCH).setRegistryName("redstone_torch")); - r.register(new Converter<>(LeverPart::new, LeverPart::new, Items.LEVER, Blocks.LEVER).setRegistryName("lever")); - - r.register(new Converter<>(ButtonPart.StoneButtonPart::new, ButtonPart.StoneButtonPart::new, Items.STONE_BUTTON, Blocks.STONE_BUTTON).setRegistryName("stone_button")); - - r.register(new Converter<>(ButtonPart.PolishedBlackstoneButtonPart::new, ButtonPart.PolishedBlackstoneButtonPart::new, Items.POLISHED_BLACKSTONE_BUTTON, Blocks.POLISHED_BLACKSTONE_BUTTON).setRegistryName("polished_blackstone_button")); - r.register(new Converter<>(ButtonPart.OakButtonPart::new, ButtonPart.OakButtonPart::new, Items.OAK_BUTTON, Blocks.OAK_BUTTON).setRegistryName("oak_button")); - r.register(new Converter<>(ButtonPart.SpruceButtonPart::new, ButtonPart.SpruceButtonPart::new, Items.SPRUCE_BUTTON, Blocks.SPRUCE_BUTTON).setRegistryName("spruce_button")); - r.register(new Converter<>(ButtonPart.BirchButtonPart::new, ButtonPart.BirchButtonPart::new, Items.BIRCH_BUTTON, Blocks.BIRCH_BUTTON).setRegistryName("birch_button")); - r.register(new Converter<>(ButtonPart.JungleButtonPart::new, ButtonPart.JungleButtonPart::new, Items.JUNGLE_BUTTON, Blocks.JUNGLE_BUTTON).setRegistryName("jungle_button")); - r.register(new Converter<>(ButtonPart.AcaciaButtonPart::new, ButtonPart.AcaciaButtonPart::new, Items.ACACIA_BUTTON, Blocks.ACACIA_BUTTON).setRegistryName("acacia_button")); - r.register(new Converter<>(ButtonPart.DarkOakButtonPart::new, ButtonPart.DarkOakButtonPart::new, Items.DARK_OAK_BUTTON, Blocks.DARK_OAK_BUTTON).setRegistryName("dark_oak_button")); - r.register(new Converter<>(ButtonPart.CrimsonButtonPart::new, ButtonPart.CrimsonButtonPart::new, Items.CRIMSON_BUTTON, Blocks.CRIMSON_BUTTON).setRegistryName("crimson_button")); - r.register(new Converter<>(ButtonPart.WarpedButtonPart::new, ButtonPart.WarpedButtonPart::new, Items.WARPED_BUTTON, Blocks.WARPED_BUTTON).setRegistryName("warped_button")); - - ModLoadingContext.get().setActiveContainer(container); + public static void onRegisterMultiPartConverters(RegisterEvent event) { + + event.register(MultiPartRegistries.PART_CONVERTERS.getRegistryKey(), r -> { + ModContainer container = ModLoadingContext.get().getActiveContainer(); + ModLoadingContext.get().setActiveContainer(null); + + r.register("torch", new Converter<>(TorchPart::new, TorchPart::new, Items.TORCH, Blocks.TORCH, Blocks.WALL_TORCH)); + r.register("soul_torch", new Converter<>(SoulTorchPart::new, SoulTorchPart::new, Items.SOUL_TORCH, Blocks.SOUL_TORCH, Blocks.SOUL_WALL_TORCH)); + r.register("redstone_torch", new Converter<>(RedstoneTorchPart::new, RedstoneTorchPart::new, Items.REDSTONE_TORCH, Blocks.REDSTONE_TORCH, Blocks.REDSTONE_WALL_TORCH)); + r.register("lever", new Converter<>(LeverPart::new, LeverPart::new, Items.LEVER, Blocks.LEVER)); + + r.register("stone_button", new Converter<>(ButtonPart.StoneButtonPart::new, ButtonPart.StoneButtonPart::new, Items.STONE_BUTTON, Blocks.STONE_BUTTON)); + + r.register("polished_blackstone_button", new Converter<>(ButtonPart.PolishedBlackstoneButtonPart::new, ButtonPart.PolishedBlackstoneButtonPart::new, Items.POLISHED_BLACKSTONE_BUTTON, Blocks.POLISHED_BLACKSTONE_BUTTON)); + r.register("oak_button", new Converter<>(ButtonPart.OakButtonPart::new, ButtonPart.OakButtonPart::new, Items.OAK_BUTTON, Blocks.OAK_BUTTON)); + r.register("spruce_button", new Converter<>(ButtonPart.SpruceButtonPart::new, ButtonPart.SpruceButtonPart::new, Items.SPRUCE_BUTTON, Blocks.SPRUCE_BUTTON)); + r.register("birch_button", new Converter<>(ButtonPart.BirchButtonPart::new, ButtonPart.BirchButtonPart::new, Items.BIRCH_BUTTON, Blocks.BIRCH_BUTTON)); + r.register("jungle_button", new Converter<>(ButtonPart.JungleButtonPart::new, ButtonPart.JungleButtonPart::new, Items.JUNGLE_BUTTON, Blocks.JUNGLE_BUTTON)); + r.register("acacia_button", new Converter<>(ButtonPart.AcaciaButtonPart::new, ButtonPart.AcaciaButtonPart::new, Items.ACACIA_BUTTON, Blocks.ACACIA_BUTTON)); + r.register("dark_oak_button", new Converter<>(ButtonPart.DarkOakButtonPart::new, ButtonPart.DarkOakButtonPart::new, Items.DARK_OAK_BUTTON, Blocks.DARK_OAK_BUTTON)); + r.register("crimson_button", new Converter<>(ButtonPart.CrimsonButtonPart::new, ButtonPart.CrimsonButtonPart::new, Items.CRIMSON_BUTTON, Blocks.CRIMSON_BUTTON)); + r.register("warped_button", new Converter<>(ButtonPart.WarpedButtonPart::new, ButtonPart.WarpedButtonPart::new, Items.WARPED_BUTTON, Blocks.WARPED_BUTTON)); + + ModLoadingContext.get().setActiveContainer(container); + }); + } private static class Converter extends PartConverter { diff --git a/src/main/java/codechicken/multipart/minecraft/RedstoneTorchPart.java b/src/main/java/codechicken/multipart/minecraft/RedstoneTorchPart.java index b76fe1e..121fcd1 100644 --- a/src/main/java/codechicken/multipart/minecraft/RedstoneTorchPart.java +++ b/src/main/java/codechicken/multipart/minecraft/RedstoneTorchPart.java @@ -6,6 +6,7 @@ import codechicken.multipart.api.part.redstone.FaceRedstonePart; import codechicken.multipart.util.TickScheduler; import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RedstoneTorchBlock; @@ -13,8 +14,6 @@ import net.minecraft.world.level.chunk.LevelChunk; import org.jetbrains.annotations.Nullable; -import java.util.Random; - public class RedstoneTorchPart extends TorchPart implements FaceRedstonePart, RandomTickPart { @Nullable @@ -47,7 +46,7 @@ public boolean active() { } @Override - public void animateTick(Random random) { + public void animateTick(RandomSource random) { if (!active()) { return; } diff --git a/src/main/java/codechicken/multipart/minecraft/TorchPart.java b/src/main/java/codechicken/multipart/minecraft/TorchPart.java index e837a78..9089fb9 100644 --- a/src/main/java/codechicken/multipart/minecraft/TorchPart.java +++ b/src/main/java/codechicken/multipart/minecraft/TorchPart.java @@ -9,6 +9,7 @@ import codechicken.multipart.api.part.MultiPart; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; @@ -20,8 +21,6 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.Nullable; -import java.util.Random; - public class TorchPart extends McSidedStatePart implements AnimateTickPart { public static VoxelShape STANDING_OCCLUSION; @@ -103,7 +102,7 @@ public MultiPart setStateOnPlacement(BlockPlaceContext context) { } @Override - public void animateTick(Random random) { + public void animateTick(RandomSource random) { state.getBlock().animateTick(state, level(), pos(), random); } } diff --git a/src/main/java/codechicken/multipart/trait/TAnimateTickTile.java b/src/main/java/codechicken/multipart/trait/TAnimateTickTile.java index a7244ae..3908a0b 100644 --- a/src/main/java/codechicken/multipart/trait/TAnimateTickTile.java +++ b/src/main/java/codechicken/multipart/trait/TAnimateTickTile.java @@ -5,9 +5,9 @@ import codechicken.multipart.api.part.AnimateTickPart; import codechicken.multipart.api.part.MultiPart; import codechicken.multipart.block.TileMultipart; +import net.minecraft.util.RandomSource; import java.util.List; -import java.util.Random; /** * Created by covers1624 on 2/9/20. @@ -16,7 +16,7 @@ public class TAnimateTickTile extends TileMultipart { @Override - public void animateTick(Random random) { + public void animateTick(RandomSource random) { List jPartList = getPartList(); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < jPartList.size(); i++) { diff --git a/src/main/java/codechicken/multipart/util/MultipartLoadHandler.java b/src/main/java/codechicken/multipart/util/MultipartLoadHandler.java index 9e8fbaa..9ebd094 100644 --- a/src/main/java/codechicken/multipart/util/MultipartLoadHandler.java +++ b/src/main/java/codechicken/multipart/util/MultipartLoadHandler.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.event.level.ChunkEvent; import net.minecraftforge.eventbus.api.EventPriority; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -38,7 +38,7 @@ public static void init() { // TODO move this to a Mixin. // Vanilla fires BlockEntity.handleUpdateTag before the LevelChunk has been added to the world. private static void onChunkLoad(ChunkEvent.Load event) { - if (event.getWorld().isClientSide() && event.getChunk() instanceof LevelChunk chunk) { + if (event.getLevel().isClientSide() && event.getChunk() instanceof LevelChunk chunk) { for (BlockEntity be : List.copyOf(chunk.getBlockEntities().values())) { if (be instanceof TileNBTContainer tile && tile.updateTag != null) { byte[] data = tile.updateTag.getByteArray("data"); diff --git a/src/main/java/codechicken/multipart/util/OffsetUseOnContext.java b/src/main/java/codechicken/multipart/util/OffsetUseOnContext.java deleted file mode 100644 index 6234eb7..0000000 --- a/src/main/java/codechicken/multipart/util/OffsetUseOnContext.java +++ /dev/null @@ -1,23 +0,0 @@ -package codechicken.multipart.util; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.item.context.UseOnContext; - -/** - * Created by covers1624 on 1/1/21. - */ -@Deprecated(since = "1.18.2", forRemoval = true) // Use MultipartPlaceContext -public class OffsetUseOnContext extends UseOnContext { - - private final BlockPos pos; - - public OffsetUseOnContext(UseOnContext other) { - super(other.getLevel(), other.getPlayer(), other.getHand(), other.getItemInHand(), other.getHitResult()); - this.pos = other.getClickedPos().relative(getClickedFace()); - } - - @Override - public BlockPos getClickedPos() { - return pos; - } -} diff --git a/src/main/java/codechicken/multipart/util/TickScheduler.java b/src/main/java/codechicken/multipart/util/TickScheduler.java index f963b5d..90167b0 100644 --- a/src/main/java/codechicken/multipart/util/TickScheduler.java +++ b/src/main/java/codechicken/multipart/util/TickScheduler.java @@ -17,7 +17,7 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.TickEvent; -import net.minecraftforge.event.world.ChunkEvent; +import net.minecraftforge.event.level.ChunkEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -98,7 +98,7 @@ public LazyOptional getCapability(@NotNull Capability cap, @Nullable D } private static void onChunkLoad(ChunkEvent.Load event) { - if (!(event.getWorld() instanceof ServerLevel) || !(event.getChunk() instanceof LevelChunk chunk)) { + if (!(event.getLevel() instanceof ServerLevel) || !(event.getChunk() instanceof LevelChunk chunk)) { return; } WorldTickScheduler.ChunkScheduler chunkScheduler = WorldTickScheduler.getInstance(chunk); @@ -106,15 +106,15 @@ private static void onChunkLoad(ChunkEvent.Load event) { } private static void onChunkUnload(ChunkEvent.Unload event) { - if (!(event.getWorld() instanceof ServerLevel level)) { + if (!(event.getLevel() instanceof ServerLevel level)) { return; } WorldTickScheduler worldScheduler = WorldTickScheduler.getInstance(level); worldScheduler.onChunkUnload(event.getChunk().getPos()); } - private static void onWorldTick(TickEvent.WorldTickEvent event) { - if (!(event.world instanceof ServerLevel level) || event.phase != TickEvent.Phase.END) { + private static void onWorldTick(TickEvent.LevelTickEvent event) { + if (!(event.level instanceof ServerLevel level) || event.phase != TickEvent.Phase.END) { return; } WorldTickScheduler worldScheduler = WorldTickScheduler.getInstance(level); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index b6d62c5..54cc859 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -23,7 +23,7 @@ license="GNU Lesser General Public License v2.1" [[dependencies.cb_multipart]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.cb_multipart]] @@ -52,7 +52,7 @@ versionRange="[${forge_version},)" [[dependencies.cb_microblock]] modId="minecraft" mandatory=true -versionRange="[1.18.2]" +versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.cb_microblock]] @@ -87,7 +87,7 @@ versionRange="[1.18.2]" [[dependencies.cb_multipart_minecraft]] modId="minecraft" mandatory=true - versionRange="[1.18.2]" + versionRange="[1.19.2]" ordering="NONE" side="BOTH" [[dependencies.cb_multipart_minecraft]]