mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
SPIGOT-7572: Bee nests generated without bees
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
parent
7b15562116
commit
aca2bf97bb
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/net/minecraft/world/item/ItemStack.java
|
||||
@@ -81,6 +81,43 @@
|
||||
@@ -81,6 +81,44 @@
|
||||
import net.minecraft.world.level.block.state.pattern.ShapeDetectorBlock;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.TreeType;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.craftbukkit.block.CapturedBlockState;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
@ -44,7 +45,7 @@
|
||||
public final class ItemStack {
|
||||
|
||||
public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
@@ -175,7 +212,18 @@
|
||||
@@ -175,7 +213,18 @@
|
||||
this.item = null;
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@
|
||||
this.item = (Item) BuiltInRegistries.ITEM.get(new MinecraftKey(nbttagcompound.getString("id")));
|
||||
this.count = nbttagcompound.getByte("Count");
|
||||
if (nbttagcompound.contains("tag", 10)) {
|
||||
@@ -189,6 +237,11 @@
|
||||
@@ -189,6 +238,11 @@
|
||||
|
||||
}
|
||||
|
||||
@ -76,7 +77,7 @@
|
||||
public static ItemStack of(NBTTagCompound nbttagcompound) {
|
||||
try {
|
||||
return new ItemStack(nbttagcompound);
|
||||
@@ -266,11 +319,190 @@
|
||||
@@ -266,11 +320,191 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
Item item = this.getItem();
|
||||
@ -128,7 +129,8 @@
|
||||
+ this.setCount(newCount);
|
||||
+ }
|
||||
+ for (CraftBlockState blockstate : blocks) {
|
||||
+ world.setBlock(blockstate.getPosition(),blockstate.getHandle(), blockstate.getFlag()); // SPIGOT-7248 - manual update to avoid physics where appropriate
|
||||
+ // SPIGOT-7572 - Move fix for SPIGOT-7248 to CapturedBlockState, to allow bees in bee nest
|
||||
+ CapturedBlockState.setBlockState(blockstate);
|
||||
+ }
|
||||
+ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); // SPIGOT-7236 - award stat
|
||||
+ }
|
||||
@ -269,7 +271,7 @@
|
||||
|
||||
return enuminteractionresult;
|
||||
}
|
||||
@@ -351,6 +583,21 @@
|
||||
@@ -351,6 +585,21 @@
|
||||
}
|
||||
|
||||
i -= k;
|
||||
@ -291,7 +293,7 @@
|
||||
if (i <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -372,6 +619,11 @@
|
||||
@@ -372,6 +621,11 @@
|
||||
if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
|
||||
consumer.accept(t0);
|
||||
Item item = this.getItem();
|
||||
@ -303,7 +305,7 @@
|
||||
|
||||
this.shrink(1);
|
||||
if (t0 instanceof EntityHuman) {
|
||||
@@ -524,6 +776,17 @@
|
||||
@@ -524,6 +778,17 @@
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
@ -321,7 +323,7 @@
|
||||
public NBTTagCompound getOrCreateTag() {
|
||||
if (this.tag == null) {
|
||||
this.setTag(new NBTTagCompound());
|
||||
@@ -948,6 +1211,13 @@
|
||||
@@ -948,6 +1213,13 @@
|
||||
nbttaglist.add(nbttagcompound);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/block/BlockSapling.java
|
||||
+++ b/net/minecraft/world/level/block/BlockSapling.java
|
||||
@@ -17,6 +17,14 @@
|
||||
@@ -17,6 +17,15 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.TreeType;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.craftbukkit.block.CapturedBlockState;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.event.world.StructureGrowEvent;
|
||||
+// CraftBukkit end
|
||||
@ -15,7 +16,7 @@
|
||||
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
|
||||
|
||||
public static final MapCodec<BlockSapling> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
@@ -28,6 +36,7 @@
|
||||
@@ -28,6 +37,7 @@
|
||||
protected static final float AABB_OFFSET = 6.0F;
|
||||
protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
|
||||
protected final WorldGenTreeProvider treeGrower;
|
||||
@ -23,7 +24,7 @@
|
||||
|
||||
@Override
|
||||
public MapCodec<? extends BlockSapling> codec() {
|
||||
@@ -57,7 +66,32 @@
|
||||
@@ -57,7 +67,32 @@
|
||||
if ((Integer) iblockdata.getValue(BlockSapling.STAGE) == 0) {
|
||||
worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 4);
|
||||
} else {
|
||||
@ -48,7 +49,7 @@
|
||||
+ }
|
||||
+ if (event == null || !event.isCancelled()) {
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ blockstate.update(true);
|
||||
+ CapturedBlockState.setBlockState(blockstate);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
@ -10,6 +10,8 @@ import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityBeehive;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
|
||||
public final class CapturedBlockState extends CraftBlockState {
|
||||
|
||||
@ -31,6 +33,22 @@ public final class CapturedBlockState extends CraftBlockState {
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
// Probably no longer needed with the extra #updatedTree method,
|
||||
// but leave if here for now in case a plugin for whatever reason relies on this.
|
||||
addBees();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void updatedTree() {
|
||||
// SPIGOT-7248 - Manual update to avoid physics where appropriate
|
||||
// SPIGOT-7572 - Move SPIGOT-7248 fix from nms ItemStack to here, to allow bee generation in nests
|
||||
world.getHandle().setBlock(CraftLocation.toBlockPosition(getLocation()), getHandle(), getFlag());
|
||||
|
||||
addBees();
|
||||
}
|
||||
|
||||
private void addBees() {
|
||||
// SPIGOT-5537: Horrible hack to manually add bees given World.captureTreeGeneration does not support tiles
|
||||
if (this.treeBlock && getType() == Material.BEE_NEST) {
|
||||
GeneratorAccessSeed generatoraccessseed = this.world.getHandle();
|
||||
@ -52,8 +70,6 @@ public final class CapturedBlockState extends CraftBlockState {
|
||||
}
|
||||
// End copied block
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,4 +84,12 @@ public final class CapturedBlockState extends CraftBlockState {
|
||||
public static CapturedBlockState getTreeBlockState(World world, BlockPosition pos, int flag) {
|
||||
return new CapturedBlockState(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), flag, true);
|
||||
}
|
||||
|
||||
public static void setBlockState(BlockState blockState) {
|
||||
if (blockState instanceof CapturedBlockState capturedBlockState) {
|
||||
capturedBlockState.updatedTree();
|
||||
} else {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user