From ac61d3082c46f5ea1954ced99b00d9d33c37427f Mon Sep 17 00:00:00 2001 From: quat1024 Date: Thu, 15 Jun 2023 01:53:04 -0400 Subject: [PATCH] Succumb to the whims of Yarn contributors (at least compiles) --- .../github/cottonmc/templates/block/SlopeBlock.java | 6 +++--- .../cottonmc/templates/block/TemplateBlock.java | 1 - .../templates/block/entity/TemplateEntity.java | 12 ++++++++---- .../cottonmc/templates/model/AbstractModel.java | 2 +- .../cottonmc/templates/model/MeshTransformer.java | 4 ++-- .../github/cottonmc/templates/model/SimpleModel.java | 4 ++-- .../github/cottonmc/templates/model/SlopeModel.java | 8 ++++---- .../model/TemplateModelVariantProvider.java | 2 +- .../cottonmc/templates/util/BlockStateUtil.java | 8 ++++---- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/github/cottonmc/templates/block/SlopeBlock.java b/src/main/java/io/github/cottonmc/templates/block/SlopeBlock.java index 07b411e..73c0277 100644 --- a/src/main/java/io/github/cottonmc/templates/block/SlopeBlock.java +++ b/src/main/java/io/github/cottonmc/templates/block/SlopeBlock.java @@ -6,7 +6,7 @@ import net.minecraft.block.*; import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.EntityContext; import net.minecraft.item.*; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; @@ -28,11 +28,11 @@ public class SlopeBlock extends TemplateBlock { public SlopeBlock() { super(FabricBlockSettings.of(Material.WOOD).build()); - this.setDefaultState(this.getStateFactory().getDefaultState().with(FACING, Direction.NORTH).with(LIGHT, 0).with(REDSTONE, false)); + this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(LIGHT, 0).with(REDSTONE, false)); } @Override - protected void appendProperties(StateFactory.Builder builder) { + protected void appendProperties(StateManager.Builder builder) { builder.add(FACING, LIGHT, REDSTONE); } diff --git a/src/main/java/io/github/cottonmc/templates/block/TemplateBlock.java b/src/main/java/io/github/cottonmc/templates/block/TemplateBlock.java index 1e9d84a..e4dd1d3 100644 --- a/src/main/java/io/github/cottonmc/templates/block/TemplateBlock.java +++ b/src/main/java/io/github/cottonmc/templates/block/TemplateBlock.java @@ -17,7 +17,6 @@ import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import net.minecraft.world.World; diff --git a/src/main/java/io/github/cottonmc/templates/block/entity/TemplateEntity.java b/src/main/java/io/github/cottonmc/templates/block/entity/TemplateEntity.java index 591f923..07badad 100644 --- a/src/main/java/io/github/cottonmc/templates/block/entity/TemplateEntity.java +++ b/src/main/java/io/github/cottonmc/templates/block/entity/TemplateEntity.java @@ -10,9 +10,10 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.client.world.ClientWorld; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtHelper; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.TagHelper; import net.minecraft.util.math.Direction; public abstract class TemplateEntity extends BlockEntity implements BlockEntityClientSerializable, RenderAttachmentBlockEntity { @@ -38,19 +39,22 @@ public abstract class TemplateEntity extends BlockEntity implements BlockEntityC @Override public void fromTag(CompoundTag tag) { super.fromTag(tag); - if (tag.containsKey("BlockState", NbtType.COMPOUND)) renderedState = TagHelper.deserializeBlockState(tag.getCompound("BlockState")); + if (tag.contains("BlockState", NbtType.COMPOUND)) renderedState = NbtHelper.toBlockState(tag.getCompound("BlockState")); else renderedState = BlockStateUtil.fromTag(tag); glowstone = tag.getBoolean("Glowstone"); redstone = tag.getBoolean("Redstone"); if (world != null && world.isClient) { - world.scheduleBlockRender(pos); + //TODO probably unsafe, i think the method was removed in 1.14.4 or something though + // i cant find any relevant method that takes only 1 blockpos argument + ((ClientWorld)world).scheduleBlockRenders(pos.getX(), pos.getY(), pos.getZ()); + //world.scheduleBlockRender(pos); } } @Override public CompoundTag toTag(CompoundTag tag) { super.toTag(tag); - tag.put("BlockState", TagHelper.serializeBlockState(renderedState)); + tag.put("BlockState", NbtHelper.fromBlockState(renderedState)); tag.putBoolean("Glowstone", glowstone); tag.putBoolean("Redstone", redstone); return tag; diff --git a/src/main/java/io/github/cottonmc/templates/model/AbstractModel.java b/src/main/java/io/github/cottonmc/templates/model/AbstractModel.java index 69e8001..98f3729 100644 --- a/src/main/java/io/github/cottonmc/templates/model/AbstractModel.java +++ b/src/main/java/io/github/cottonmc/templates/model/AbstractModel.java @@ -26,7 +26,7 @@ public abstract class AbstractModel implements BakedModel, FabricBakedModel { } @Override - public boolean hasDepthInGui() { + public boolean hasDepth() { return true; } diff --git a/src/main/java/io/github/cottonmc/templates/model/MeshTransformer.java b/src/main/java/io/github/cottonmc/templates/model/MeshTransformer.java index 71650dd..0f87438 100644 --- a/src/main/java/io/github/cottonmc/templates/model/MeshTransformer.java +++ b/src/main/java/io/github/cottonmc/templates/model/MeshTransformer.java @@ -7,10 +7,10 @@ import net.fabricmc.fabric.api.renderer.v1.render.RenderContext.QuadTransform; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ExtendedBlockView; +import net.minecraft.world.BlockRenderView; public interface MeshTransformer extends QuadTransform { - MeshTransformer prepare(ExtendedBlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier); + MeshTransformer prepare(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier randomSupplier); MeshTransformer prepare(ItemStack stack, Supplier randomSupplier); } diff --git a/src/main/java/io/github/cottonmc/templates/model/SimpleModel.java b/src/main/java/io/github/cottonmc/templates/model/SimpleModel.java index 7b35ad0..10aaa4e 100644 --- a/src/main/java/io/github/cottonmc/templates/model/SimpleModel.java +++ b/src/main/java/io/github/cottonmc/templates/model/SimpleModel.java @@ -21,7 +21,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.world.ExtendedBlockView; +import net.minecraft.world.BlockRenderView; import net.minecraft.world.World; /** @@ -60,7 +60,7 @@ public class SimpleModel extends AbstractModel { } @Override - public void emitBlockQuads(ExtendedBlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { + public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { final MeshTransformer transform = transformerFactory == null ? null : transformerFactory.get().prepare(blockView, state, pos, randomSupplier); if(transform != null) { context.pushTransform(transform); diff --git a/src/main/java/io/github/cottonmc/templates/model/SlopeModel.java b/src/main/java/io/github/cottonmc/templates/model/SlopeModel.java index 3b50355..3a4f771 100644 --- a/src/main/java/io/github/cottonmc/templates/model/SlopeModel.java +++ b/src/main/java/io/github/cottonmc/templates/model/SlopeModel.java @@ -3,6 +3,8 @@ package io.github.cottonmc.templates.model; import java.util.Random; import java.util.function.Supplier; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.world.BlockRenderView; import org.apache.commons.lang3.ObjectUtils; import io.github.cottonmc.templates.util.SpriteSet; @@ -16,7 +18,6 @@ import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter; import net.fabricmc.fabric.api.renderer.v1.model.ModelHelper; import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView; import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; @@ -28,7 +29,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.world.ExtendedBlockView; public class SlopeModel extends SimpleModel { @@ -143,7 +143,7 @@ public class SlopeModel extends SimpleModel { private RenderMaterial material; @Override - public MeshTransformer prepare(ExtendedBlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier) { + public MeshTransformer prepare(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier randomSupplier) { dir = state.get(Properties.HORIZONTAL_FACING); color = 0xffffff; final BlockState template = ObjectUtils.defaultIfNull((BlockState) ((RenderAttachedBlockView)blockView).getBlockEntityRenderAttachment(pos), Blocks.AIR.getDefaultState()); @@ -151,7 +151,7 @@ public class SlopeModel extends SimpleModel { if(block == Blocks.AIR) { sprites.clear(); - material = finder.clear().blendMode(0, BlockRenderLayer.CUTOUT).find(); + material = finder.clear().blendMode(0, RenderLayer.CUTOUT).find(); } else { material = finder.clear().disableDiffuse(0, false).disableAo(0, false).blendMode(0, block.getRenderLayer()).find(); BakedModel model = minecraft.getBlockRenderManager().getModel(template); diff --git a/src/main/java/io/github/cottonmc/templates/model/TemplateModelVariantProvider.java b/src/main/java/io/github/cottonmc/templates/model/TemplateModelVariantProvider.java index 6bcf308..83bcca8 100644 --- a/src/main/java/io/github/cottonmc/templates/model/TemplateModelVariantProvider.java +++ b/src/main/java/io/github/cottonmc/templates/model/TemplateModelVariantProvider.java @@ -24,7 +24,7 @@ public class TemplateModelVariantProvider implements ModelVariantProvider { } public void registerTemplateModels(Block block, BlockState itemState, Function model) { - for (BlockState state : block.getStateFactory().getStates()) { + for (BlockState state : block.getStateManager().getStates()) { variants.put(BlockModels.getModelId(state), (SimpleUnbakedModel)() -> model.apply(state)); } variants.put(new ModelIdentifier(Registry.ITEM.getId(block.asItem()), "inventory"), (SimpleUnbakedModel)() -> model.apply(itemState)); diff --git a/src/main/java/io/github/cottonmc/templates/util/BlockStateUtil.java b/src/main/java/io/github/cottonmc/templates/util/BlockStateUtil.java index 78fa955..c884bbc 100644 --- a/src/main/java/io/github/cottonmc/templates/util/BlockStateUtil.java +++ b/src/main/java/io/github/cottonmc/templates/util/BlockStateUtil.java @@ -3,7 +3,7 @@ package io.github.cottonmc.templates.util; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundTag; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.Property; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -11,14 +11,14 @@ import net.minecraft.util.registry.Registry; import java.util.Optional; /** - * use {@link net.minecraft.util.TagHelper}, which I should have been using from the start oops + * use {@link net.minecraft.nbt.NbtHelper}, which I should have been using from the start oops */ @Deprecated public class BlockStateUtil { public static BlockState fromTag(CompoundTag tag) { Block block = Registry.BLOCK.get(new Identifier(tag.getString("Block"))); CompoundTag properties = tag.getCompound("Properties"); - StateFactory factory = block.getStateFactory(); + StateManager factory = block.getStateManager(); BlockState state = factory.getDefaultState(); for (String key : properties.getKeys()) { Property prop = factory.getProperty(key); @@ -39,7 +39,7 @@ public class BlockStateUtil { } public static > BlockState parseProperty(BlockState state, Property property, String value) { - Optional optional = property.getValue(value); + Optional optional = property.parse(value); if (optional.isPresent()) { state = state.with(property, optional.get()); }