3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00

#702: Add Block#applyBoneMeal()

Dieser Commit ist enthalten in:
Parker Hawke 2020-08-27 11:27:13 +10:00 committet von md_5
Ursprung 8408de02d2
Commit 8c6115604b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: E8E901AC7C617C11
3 geänderte Dateien mit 40 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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;

Datei anzeigen

@ -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());

Datei anzeigen

@ -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);