Skip to content

Commit 56fbf62

Browse files
committed
feat:some block patches
1 parent 7f69459 commit 56fbf62

11 files changed

Lines changed: 117 additions & 160 deletions

File tree

nms-patches/net/minecraft/world/level/block/BlockWaterLily.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

nms-patches/net/minecraft/world/level/block/BlockWitherRose.patch

Lines changed: 0 additions & 11 deletions
This file was deleted.

nms-patches/net/minecraft/world/level/block/BlockWitherSkull.patch

Lines changed: 0 additions & 50 deletions
This file was deleted.

nms-patches/net/minecraft/world/level/block/BuddingAmethystBlock.patch

Lines changed: 0 additions & 11 deletions
This file was deleted.

nms-patches/net/minecraft/world/level/block/CaveVines.patch

Lines changed: 0 additions & 42 deletions
This file was deleted.

nms-patches/net/minecraft/world/level/block/CeilingHangingSignBlock.patch

Lines changed: 0 additions & 10 deletions
This file was deleted.

nms-patches/net/minecraft/world/level/block/ChangeOverTimeBlock.patch

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.teneted.neotenet.mixin.world.level.block;
2+
3+
import com.llamalad7.mixinextras.sugar.Cancellable;
4+
import com.llamalad7.mixinextras.sugar.Local;
5+
import net.minecraft.core.BlockPos;
6+
import net.minecraft.world.InteractionResult;
7+
import net.minecraft.world.entity.Entity;
8+
import net.minecraft.world.entity.player.Player;
9+
import net.minecraft.world.item.ItemStack;
10+
import net.minecraft.world.item.Items;
11+
import net.minecraft.world.level.Level;
12+
import net.minecraft.world.level.block.Block;
13+
import net.minecraft.world.level.block.CaveVines;
14+
import net.minecraft.world.level.block.state.BlockState;
15+
import org.bukkit.craftbukkit.event.CraftEventFactory;
16+
import org.bukkit.craftbukkit.inventory.CraftItemStack;
17+
import org.bukkit.event.player.PlayerHarvestBlockEvent;
18+
import org.spongepowered.asm.mixin.Mixin;
19+
import org.spongepowered.asm.mixin.injection.At;
20+
import org.spongepowered.asm.mixin.injection.Redirect;
21+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
22+
23+
import javax.annotation.Nullable;
24+
import java.util.Collections;
25+
26+
@Mixin(CaveVines.class)
27+
public interface MixinCaveVines {
28+
29+
@Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;popResource(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V"))
30+
private static void neotenet$callPlayerHarvestBlockEvent(Level level, BlockPos blockPos, ItemStack itemStack, @Local(argsOnly = true) @Nullable Entity entity, @Local(argsOnly = true) BlockState iblockdata, @Cancellable CallbackInfoReturnable<InteractionResult> cir) {
31+
// CraftBukkit start
32+
if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPos, (BlockState) iblockdata.setValue(CaveVines.BERRIES, false))) {
33+
cir.setReturnValue(InteractionResult.SUCCESS);
34+
}
35+
36+
if (entity instanceof Player) {
37+
PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(level, blockPos, (Player) entity, net.minecraft.world.InteractionHand.MAIN_HAND, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1)));
38+
if (event.isCancelled()) {
39+
cir.setReturnValue(InteractionResult.SUCCESS); // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
40+
}
41+
for (org.bukkit.inventory.ItemStack bukkitStack : event.getItemsHarvested()) {
42+
Block.popResource(level, blockPos, CraftItemStack.asNMSCopy(bukkitStack));
43+
}
44+
} else {
45+
Block.popResource(level, blockPos, new ItemStack(Items.GLOW_BERRIES, 1));
46+
}
47+
// CraftBukkit end
48+
}
49+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.teneted.neotenet.mixin.world.level.block;
2+
3+
import net.minecraft.core.BlockPos;
4+
import net.minecraft.server.level.ServerLevel;
5+
import net.minecraft.world.level.block.ChangeOverTimeBlock;
6+
import net.minecraft.world.level.block.state.BlockState;
7+
import org.bukkit.craftbukkit.event.CraftEventFactory;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Redirect;
11+
12+
@Mixin(ChangeOverTimeBlock.class)
13+
public interface MixinChangeOverTimeBlock {
14+
15+
@Redirect(method = "lambda$changeOverTime$0",
16+
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z"))
17+
private static boolean neotenet$handleBlockFormEvent(ServerLevel instance, BlockPos blockPos, BlockState blockState) {
18+
return CraftEventFactory.handleBlockFormEvent(instance, blockPos, blockState);
19+
}
20+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.teneted.neotenet.mixin.world.level.block;
2+
3+
import com.llamalad7.mixinextras.sugar.Local;
4+
import net.minecraft.core.BlockPos;
5+
import net.minecraft.world.entity.Entity;
6+
import net.minecraft.world.entity.boss.wither.WitherBoss;
7+
import net.minecraft.world.level.Level;
8+
import net.minecraft.world.level.block.CarvedPumpkinBlock;
9+
import net.minecraft.world.level.block.WitherSkullBlock;
10+
import net.minecraft.world.level.block.entity.SkullBlockEntity;
11+
import net.minecraft.world.level.block.state.pattern.BlockPattern;
12+
import org.bukkit.event.entity.CreatureSpawnEvent;
13+
import org.spongepowered.asm.mixin.Mixin;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.Redirect;
17+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18+
19+
@Mixin(WitherSkullBlock.class)
20+
public class MixinWitherSkullBlock {
21+
22+
@Inject(method = "checkSpawn(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/SkullBlockEntity;)V", at = @At("HEAD"), cancellable = true)
23+
private static void neotenet$capture(Level p_58256_, BlockPos p_58257_, SkullBlockEntity p_58258_, CallbackInfo ci) {
24+
if (p_58256_.captureBlockStates) ci.cancel(); return; // CraftBukkit
25+
}
26+
27+
@Inject(method = "checkSpawn(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/SkullBlockEntity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntitiesOfClass(Ljava/lang/Class;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;"), cancellable = true)
28+
private static void neotenet$pushReason(Level p_58256_, BlockPos p_58257_, SkullBlockEntity p_58258_, CallbackInfo ci, @Local BlockPattern.BlockPatternMatch blockpattern$blockpatternmatch, @Local WitherBoss witherboss) {
29+
// CraftBukkit start
30+
if (!p_58256_.addFreshEntity(witherboss, CreatureSpawnEvent.SpawnReason.BUILD_WITHER)) {
31+
ci.cancel();
32+
return;
33+
}
34+
CarvedPumpkinBlock.clearPatternBlocks(p_58256_, blockpattern$blockpatternmatch); // CraftBukkit - from above
35+
// CraftBukkit end
36+
}
37+
38+
@Redirect(method = "checkSpawn(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/SkullBlockEntity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/CarvedPumpkinBlock;clearPatternBlocks(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/block/state/pattern/BlockPattern$BlockPatternMatch;)V"))
39+
private static void neotenet$moveDown(Level level, BlockPattern.BlockPatternMatch blockPatternMatch) {}
40+
41+
@Redirect(method = "checkSpawn(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/SkullBlockEntity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z"))
42+
private static boolean neotenet$moveUp(Level instance, Entity entity) {
43+
return false;
44+
}
45+
}

0 commit comments

Comments
 (0)