From 595901802c5bc12ffa327f86df726840fecff363 Mon Sep 17 00:00:00 2001 From: Jottyfan Date: Thu, 15 Jan 2026 23:31:44 +0100 Subject: [PATCH] fixes the cutout bug, see #2 --- gradle.properties | 2 +- .../jottyfan/minecraft/block/BlockPlant.java | 23 +++++++++++++++++-- .../minecraft/mixin/QuicklyMixin.java | 22 ++++++++++++++---- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6fec1fe..6ebf910 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ loader_version=0.18.4 loom_version=1.14-SNAPSHOT # Mod Properties -mod_version=26.1.2 +mod_version=26.1.3 maven_group=de.jottyfan.minecraft archives_base_name=quickly diff --git a/src/main/java/de/jottyfan/minecraft/block/BlockPlant.java b/src/main/java/de/jottyfan/minecraft/block/BlockPlant.java index b7bc0f6..7da88d1 100644 --- a/src/main/java/de/jottyfan/minecraft/block/BlockPlant.java +++ b/src/main/java/de/jottyfan/minecraft/block/BlockPlant.java @@ -7,11 +7,15 @@ import net.minecraft.world.Containers; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.CropBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; /** * @@ -24,11 +28,26 @@ public class BlockPlant extends CropBlock { private Identifier fruitName; public BlockPlant(Properties properties, Identifier seedName, Identifier fruitName) { - super(properties); + super(properties.noOcclusion().dynamicShape()); this.seedName = seedName; this.fruitName = fruitName; } + @Override + protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { + return Block.box(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D); + } + + @Override + protected float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) { + return 1.0F; + } + + @Override + protected boolean propagatesSkylightDown(BlockState state) { + return true; + } + public ItemLike getSeed() { return QuicklyItems.of(seedName); } @@ -42,7 +61,7 @@ public class BlockPlant extends CropBlock { BlockHitResult hitResult) { if (!level.isClientSide() && isMaxAge(state)) { int fruitAmount = (level.getRandom().nextFloat() > 0.9f) ? 2 : 1; - Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(getFruit(), fruitAmount)); + Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(getFruit(), fruitAmount)); Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(getSeed())); level.setBlock(pos, state.setValue(AGE, 0), 2); return InteractionResult.SUCCESS; diff --git a/src/main/java/de/jottyfan/minecraft/mixin/QuicklyMixin.java b/src/main/java/de/jottyfan/minecraft/mixin/QuicklyMixin.java index 28b49d4..af03732 100644 --- a/src/main/java/de/jottyfan/minecraft/mixin/QuicklyMixin.java +++ b/src/main/java/de/jottyfan/minecraft/mixin/QuicklyMixin.java @@ -1,20 +1,34 @@ package de.jottyfan.minecraft.mixin; +import java.util.Map; + +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.server.MinecraftServer; +import de.jottyfan.minecraft.block.QuicklyBlocks; +import net.minecraft.client.renderer.ItemBlockRenderTypes; +import net.minecraft.client.renderer.chunk.ChunkSectionLayer; +import net.minecraft.world.level.block.Block; /** * * @author jotty * */ -@Mixin(MinecraftServer.class) +@Mixin(ItemBlockRenderTypes.class) public class QuicklyMixin { - @Inject(at = @At("HEAD"), method = "loadLevel") - private void init(CallbackInfo info) { + @Shadow + @Final + private static Map TYPE_BY_BLOCK; + + @Inject(method = "", at = @At("RETURN")) + private static void onStaticInit(CallbackInfo info) { + ChunkSectionLayer cutout = ChunkSectionLayer.CUTOUT; + TYPE_BY_BLOCK.put(QuicklyBlocks.CANOLAPLANT, cutout); + TYPE_BY_BLOCK.put(QuicklyBlocks.COTTONPLANT, cutout); } } \ No newline at end of file