summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java
diff options
context:
space:
mode:
authorMerrg1n <[email protected]>2022-08-13 22:36:35 +0800
committerMerrg1n <[email protected]>2022-08-14 01:42:37 +0800
commit94f092015a05d0179e307468c717ad391e455742 (patch)
tree1e90e0462e8bc2a6d4ae4131808b655089db72a9 /src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java
parent323226a7956b2dc1d56c56e63bc9354e2b8bd244 (diff)
carpet ext
Diffstat (limited to 'src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java')
-rw-r--r--src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java b/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java
deleted file mode 100644
index 7e25bf1..0000000
--- a/src/main/java/com/keuin/ohmyvanillamc/mixin/Mc113809BambooBlockMixin.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.keuin.ohmyvanillamc.mixin;
-
-import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft;
-import net.minecraft.block.BambooBlock;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.server.world.ServerWorld;
-import net.minecraft.state.property.IntProperty;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.BlockView;
-import net.minecraft.world.World;
-import org.spongepowered.asm.mixin.Final;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Overwrite;
-import org.spongepowered.asm.mixin.Shadow;
-
-import java.util.Random;
-
-@Mixin(BambooBlock.class)
-public abstract class Mc113809BambooBlockMixin extends Block {
-
- public Mc113809BambooBlockMixin(Settings settings) {
- super(settings);
- }
-
- @Shadow
- @Final
- public static IntProperty STAGE;
-
- @Shadow
- protected abstract int countBambooBelow(BlockView world, BlockPos pos);
-
- @Shadow
- protected abstract void updateLeaves(BlockState state, World world, BlockPos pos, Random random, int height);
-
- /**
- * Reintroduce the base class's implementation.
- *
- * @reason reintroduce base class's implementation.
- * @author trueKeuin
- */
- @Overwrite
- public boolean hasRandomTicks(BlockState state) {
- boolean zf = OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableBambooForceRipening();
- return ((state.get(STAGE) == 0) && !zf) || (randomTicks && zf);
- }
-
- /**
- * Revert to base class (Block) implementation of randomTick: just simply call scheduledTick.
- * (both 1.15.2 and 1.16.4 are the same)
- *
- * @author trueKeuin
- * @reason revert to the base class `Block` implementation.
- */
- @Overwrite
- public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
- if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableBambooForceRipening()) {
- scheduledTick(state, world, pos, random);
- } else {
- realGrow(state, world, pos, random);
- }
- }
-
- /**
- * Reintroduce the MC-113809 glitch for bamboo. The implementation is identical to Minecraft 1.15.2.
- *
- * @author trueKeuin
- * @reason reintroduce MC-113809 for bamboo.
- */
- @Overwrite
- public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
- if (!state.canPlaceAt(world, pos)) {
- world.breakBlock(pos, true);
- } else if (OhMyVanillaMinecraft.getConfiguration().isReintroduceZeroTickFarm() && OhMyVanillaMinecraft.getConfiguration().isEnableBambooForceRipening()) {
- realGrow(state, world, pos, random);
- }
- }
-
- private void realGrow(BlockState state, ServerWorld world, BlockPos pos, Random random) {
- if (state.get(STAGE) == 0) {
- if (random.nextInt(3) == 0 && world.isAir(pos.up()) && world.getBaseLightLevel(pos.up(), 0) >= 9) {
- int i = this.countBambooBelow(world, pos) + 1;
- if (i < 16) {
- this.updateLeaves(state, world, pos, random, i);
- }
- }
- }
- }
-
-}