mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 12:57:41 +01:00
#702: Add Block#applyBoneMeal()
This commit is contained in:
parent
8408de02d2
commit
8c6115604b
nms-patches
src/main/java/org/bukkit/craftbukkit/block
11
nms-patches/ItemActionContext.patch
Normal file
11
nms-patches/ItemActionContext.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/ItemActionContext.java
|
||||
+++ b/net/minecraft/server/ItemActionContext.java
|
||||
@@ -15,7 +15,7 @@
|
||||
this(entityhuman.world, entityhuman, enumhand, entityhuman.b(enumhand), movingobjectpositionblock);
|
||||
}
|
||||
|
||||
- protected ItemActionContext(World world, @Nullable EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, MovingObjectPositionBlock movingobjectpositionblock) {
|
||||
+ public ItemActionContext(World world, @Nullable EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, MovingObjectPositionBlock movingobjectpositionblock) { // PAIL protected -> public
|
||||
this.a = entityhuman;
|
||||
this.b = enumhand;
|
||||
this.c = movingobjectpositionblock;
|
15
nms-patches/ItemBoneMeal.patch
Normal file
15
nms-patches/ItemBoneMeal.patch
Normal file
@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/ItemBoneMeal.java
|
||||
+++ b/net/minecraft/server/ItemBoneMeal.java
|
||||
@@ -12,6 +12,12 @@
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(ItemActionContext itemactioncontext) {
|
||||
+ // CraftBukkit start - extract bonemeal application logic to separate, static method
|
||||
+ return applyBonemeal(itemactioncontext);
|
||||
+ }
|
||||
+
|
||||
+ public static EnumInteractionResult applyBonemeal(ItemActionContext itemactioncontext) {
|
||||
+ // CraftBukkit end
|
||||
World world = itemactioncontext.getWorld();
|
||||
BlockPosition blockposition = itemactioncontext.getClickPosition();
|
||||
BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace());
|
@ -12,14 +12,18 @@ import net.minecraft.server.BlockRedstoneWire;
|
||||
import net.minecraft.server.BlockTileEntity;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.EnumDirection;
|
||||
import net.minecraft.server.EnumHand;
|
||||
import net.minecraft.server.EnumInteractionResult;
|
||||
import net.minecraft.server.EnumSkyBlock;
|
||||
import net.minecraft.server.GeneratorAccess;
|
||||
import net.minecraft.server.IBlockData;
|
||||
import net.minecraft.server.IRegistry;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.ItemActionContext;
|
||||
import net.minecraft.server.ItemBoneMeal;
|
||||
import net.minecraft.server.Items;
|
||||
import net.minecraft.server.MovingObjectPosition;
|
||||
import net.minecraft.server.MovingObjectPositionBlock;
|
||||
import net.minecraft.server.RayTrace;
|
||||
import net.minecraft.server.RegistryGeneration;
|
||||
import net.minecraft.server.TileEntity;
|
||||
import net.minecraft.server.Vec3D;
|
||||
import net.minecraft.server.VoxelShape;
|
||||
@ -629,6 +633,14 @@ public class CraftBlock implements Block {
|
||||
return setTypeAndData(Blocks.AIR.getBlockData(), true) && result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyBoneMeal(BlockFace face) {
|
||||
EnumDirection direction = blockFaceToNotch(face);
|
||||
ItemActionContext context = new ItemActionContext(getCraftWorld().getHandle(), null, EnumHand.MAIN_HAND, Items.BONE_MEAL.r(), new MovingObjectPositionBlock(Vec3D.a, direction, getPosition(), false)); // PAIL rename createItemStack, ZERO
|
||||
|
||||
return ItemBoneMeal.applyBonemeal(context) == EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops() {
|
||||
return getDrops(null);
|
||||
|
Loading…
Reference in New Issue
Block a user