Skip to content

Commit

Permalink
new: cactus crop hitboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sychic committed Jun 16, 2023
1 parent 3b2f14c commit 0a8de54
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/club/sk1er/patcher/hooks/CropUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class CropUtilities {
new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.875D, 1.0D)
};

public static final AxisAlignedBB CACTUS_BOX = new AxisAlignedBB(0.0625, 0.0, 0.0625, 0.9375, 1.0, 0.9375);

public static void updateCropsMaxY(World world, BlockPos pos, Block block) {
final IBlockState blockState = world.getBlockState(pos);
final Integer ageValue = blockState.getValue(BlockCrops.AGE);
Expand All @@ -69,5 +71,16 @@ public static void updateWartMaxY(World world, BlockPos pos, Block block) {
: .25F
);
}

public static void updateCactusBox(Block block) {
block.setBlockBounds(
(float) CACTUS_BOX.minX,
(float) CACTUS_BOX.minY,
(float) CACTUS_BOX.minZ,
(float) CACTUS_BOX.maxX,
(float) CACTUS_BOX.maxY,
(float) CACTUS_BOX.maxZ
);
}
//#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package club.sk1er.patcher.mixins.features.cropheight;

import club.sk1er.patcher.config.PatcherConfig;
import club.sk1er.patcher.hooks.CropUtilities;
import net.minecraft.block.BlockCactus;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BlockCactus.class)
public class BlockCactusMixin_CropHitbox extends BlockMixin_CropHitbox {
//#if MC==10809
@Inject(method = "getSelectedBoundingBox", at = @At("HEAD"))
public void patcher$getSelectedBoundingBox(World worldIn, BlockPos pos, CallbackInfoReturnable<AxisAlignedBB> cir) {
if (PatcherConfig.futureHitBoxes) {
CropUtilities.updateCactusBox(worldIn.getBlockState(pos).getBlock());
}
}

@Override
public void collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end, CallbackInfoReturnable<MovingObjectPosition> cir) {
if (PatcherConfig.futureHitBoxes) {
CropUtilities.updateCactusBox(worldIn.getBlockState(pos).getBlock());
}
}
//#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package club.sk1er.patcher.mixins.features.cropheight;

import net.minecraft.block.Block;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Block.class)
public class BlockMixin_CropHitbox {
@Inject(method = "collisionRayTrace", at = @At("HEAD"))
public void collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end, CallbackInfoReturnable<MovingObjectPosition> cir) {

}
}
2 changes: 2 additions & 0 deletions src/main/resources/patcher.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@
"features.TileEntitySkullRendererMixin_CancelRender",
"features.containeropacity.GuiChestMixin_ContainerOpacity",
"features.containeropacity.GuiInventoryMixin_ContainerOpacity",
"features.cropheight.BlockCactusMixin_CropHitbox",
"features.cropheight.BlockCropsMixin_CropHeight",
"features.cropheight.BlockMixin_CropHitbox",
"features.cropheight.BlockNetherWartMixin_CropHeight",
"features.disableenchantglint.LayerArmorBaseMixin_DisableEnchantGlint",
"features.disableenchantglint.RenderItemMixin_DisableEnchantGlint",
Expand Down

0 comments on commit 0a8de54

Please sign in to comment.