Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
#702: Add Block#applyBoneMeal()
Dieser Commit ist enthalten in:
Ursprung
8408de02d2
Commit
8c6115604b
11
nms-patches/ItemActionContext.patch
Normale Datei
11
nms-patches/ItemActionContext.patch
Normale Datei
@ -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
Normale Datei
15
nms-patches/ItemBoneMeal.patch
Normale Datei
@ -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.BlockTileEntity;
|
||||||
import net.minecraft.server.Blocks;
|
import net.minecraft.server.Blocks;
|
||||||
import net.minecraft.server.EnumDirection;
|
import net.minecraft.server.EnumDirection;
|
||||||
|
import net.minecraft.server.EnumHand;
|
||||||
|
import net.minecraft.server.EnumInteractionResult;
|
||||||
import net.minecraft.server.EnumSkyBlock;
|
import net.minecraft.server.EnumSkyBlock;
|
||||||
import net.minecraft.server.GeneratorAccess;
|
import net.minecraft.server.GeneratorAccess;
|
||||||
import net.minecraft.server.IBlockData;
|
import net.minecraft.server.IBlockData;
|
||||||
import net.minecraft.server.IRegistry;
|
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.MovingObjectPosition;
|
||||||
|
import net.minecraft.server.MovingObjectPositionBlock;
|
||||||
import net.minecraft.server.RayTrace;
|
import net.minecraft.server.RayTrace;
|
||||||
import net.minecraft.server.RegistryGeneration;
|
|
||||||
import net.minecraft.server.TileEntity;
|
import net.minecraft.server.TileEntity;
|
||||||
import net.minecraft.server.Vec3D;
|
import net.minecraft.server.Vec3D;
|
||||||
import net.minecraft.server.VoxelShape;
|
import net.minecraft.server.VoxelShape;
|
||||||
@ -629,6 +633,14 @@ public class CraftBlock implements Block {
|
|||||||
return setTypeAndData(Blocks.AIR.getBlockData(), true) && result;
|
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
|
@Override
|
||||||
public Collection<ItemStack> getDrops() {
|
public Collection<ItemStack> getDrops() {
|
||||||
return getDrops(null);
|
return getDrops(null);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren