SPIGOT-5537: Bee nests generated by growing trees near flower have no bees
By: md_5 <git@md-5.net>
This commit is contained in:
@@ -1,29 +1,24 @@
|
||||
--- a/net/minecraft/server/World.java
|
||||
+++ b/net/minecraft/server/World.java
|
||||
@@ -14,6 +14,22 @@
|
||||
@@ -14,6 +14,17 @@
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.util.Supplier;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.google.common.collect.Maps;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
+import org.bukkit.craftbukkit.block.CapturedBlockState;
|
||||
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
+import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class World implements GeneratorAccess, AutoCloseable {
|
||||
|
||||
protected static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -40,7 +56,51 @@
|
||||
@@ -40,7 +51,39 @@
|
||||
private final WorldBorder worldBorder;
|
||||
private final BiomeManager biomeManager;
|
||||
|
||||
@@ -36,20 +31,8 @@
|
||||
+
|
||||
+ public boolean captureBlockStates = false;
|
||||
+ public boolean captureTreeGeneration = false;
|
||||
+ public ArrayList<CraftBlockState> capturedBlockStates = new ArrayList<CraftBlockState>() {
|
||||
+ @Override
|
||||
+ public boolean add(CraftBlockState blockState) {
|
||||
+ Iterator<CraftBlockState> blockStateIterator = this.iterator();
|
||||
+ while (blockStateIterator.hasNext()) {
|
||||
+ BlockState blockState1 = blockStateIterator.next();
|
||||
+ if (blockState1.getLocation().equals(blockState.getLocation())) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return super.add(blockState);
|
||||
+ }
|
||||
+ };
|
||||
+ public Map<BlockPosition, CapturedBlockState> capturedBlockStates = new HashMap<>();
|
||||
+ public Map<BlockPosition, TileEntity> capturedTileEntities = new HashMap<>();
|
||||
+ public List<EntityItem> captureDrops;
|
||||
+ public long ticksPerAnimalSpawns;
|
||||
+ public long ticksPerMonsterSpawns;
|
||||
@@ -76,7 +59,7 @@
|
||||
this.methodProfiler = gameprofilerfiller;
|
||||
this.worldData = worlddata;
|
||||
this.worldProvider = dimensionmanager.getWorldProvider(this);
|
||||
@@ -49,6 +109,35 @@
|
||||
@@ -49,6 +92,35 @@
|
||||
this.worldBorder = this.worldProvider.getWorldBorder();
|
||||
this.serverThread = Thread.currentThread();
|
||||
this.biomeManager = new BiomeManager(this, flag ? worlddata.getSeed() : WorldData.c(worlddata.getSeed()), dimensionmanager.getGenLayerZoomer());
|
||||
@@ -112,44 +95,34 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,6 +194,26 @@
|
||||
@@ -105,6 +177,17 @@
|
||||
|
||||
@Override
|
||||
public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) {
|
||||
+ // CraftBukkit start - tree generation
|
||||
+ if (this.captureTreeGeneration) {
|
||||
+ CraftBlockState blockstate = null;
|
||||
+ Iterator<CraftBlockState> it = capturedBlockStates.iterator();
|
||||
+ while (it.hasNext()) {
|
||||
+ CraftBlockState previous = it.next();
|
||||
+ if (previous.getPosition().equals(blockposition)) {
|
||||
+ blockstate = previous;
|
||||
+ it.remove();
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ CapturedBlockState blockstate = capturedBlockStates.get(blockposition);
|
||||
+ if (blockstate == null) {
|
||||
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition, i);
|
||||
+ blockstate = CapturedBlockState.getTreeBlockState(this, blockposition, i);
|
||||
+ this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate);
|
||||
+ }
|
||||
+ blockstate.setData(iblockdata);
|
||||
+ this.capturedBlockStates.add(blockstate);
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (isOutsideWorld(blockposition)) {
|
||||
return false;
|
||||
} else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
|
||||
@@ -112,9 +221,23 @@
|
||||
@@ -112,9 +195,22 @@
|
||||
} else {
|
||||
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
- IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0);
|
||||
+
|
||||
+ // CraftBukkit start - capture blockstates
|
||||
+ CraftBlockState blockstate = null;
|
||||
+ if (this.captureBlockStates) {
|
||||
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition, i);
|
||||
+ this.capturedBlockStates.add(blockstate);
|
||||
+ if (this.captureBlockStates && !this.capturedBlockStates.containsKey(blockposition)) {
|
||||
+ CapturedBlockState blockstate = CapturedBlockState.getBlockState(this, blockposition, i);
|
||||
+ this.capturedBlockStates.put(blockposition.immutableCopy(), blockstate);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@@ -158,13 +131,13 @@
|
||||
if (iblockdata1 == null) {
|
||||
+ // CraftBukkit start - remove blockstate if failed
|
||||
+ if (this.captureBlockStates) {
|
||||
+ this.capturedBlockStates.remove(blockstate);
|
||||
+ this.capturedBlockStates.remove(blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return false;
|
||||
} else {
|
||||
IBlockData iblockdata2 = this.getType(blockposition);
|
||||
@@ -125,6 +248,7 @@
|
||||
@@ -125,6 +221,7 @@
|
||||
this.methodProfiler.exit();
|
||||
}
|
||||
|
||||
@@ -172,7 +145,7 @@
|
||||
if (iblockdata2 == iblockdata) {
|
||||
if (iblockdata1 != iblockdata2) {
|
||||
this.b(blockposition, iblockdata1, iblockdata2);
|
||||
@@ -151,12 +275,65 @@
|
||||
@@ -151,12 +248,65 @@
|
||||
|
||||
this.a(blockposition, iblockdata1, iblockdata2);
|
||||
}
|
||||
@@ -238,7 +211,7 @@
|
||||
public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {}
|
||||
|
||||
@Override
|
||||
@@ -195,6 +372,11 @@
|
||||
@@ -195,6 +345,11 @@
|
||||
@Override
|
||||
public void update(BlockPosition blockposition, Block block) {
|
||||
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
|
||||
@@ -250,7 +223,7 @@
|
||||
this.applyPhysics(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -243,6 +425,17 @@
|
||||
@@ -243,6 +398,17 @@
|
||||
IBlockData iblockdata = this.getType(blockposition);
|
||||
|
||||
try {
|
||||
@@ -268,25 +241,22 @@
|
||||
iblockdata.doPhysics(this, blockposition, block, blockposition1, false);
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
|
||||
@@ -285,6 +478,17 @@
|
||||
@@ -285,6 +451,14 @@
|
||||
|
||||
@Override
|
||||
public IBlockData getType(BlockPosition blockposition) {
|
||||
+ // CraftBukkit start - tree generation
|
||||
+ if (captureTreeGeneration) {
|
||||
+ Iterator<CraftBlockState> it = capturedBlockStates.iterator();
|
||||
+ while (it.hasNext()) {
|
||||
+ CraftBlockState previous = it.next();
|
||||
+ if (previous.getPosition().equals(blockposition)) {
|
||||
+ return previous.getHandle();
|
||||
+ }
|
||||
+ CapturedBlockState previous = capturedBlockStates.get(blockposition);
|
||||
+ if (previous != null) {
|
||||
+ return previous.getHandle();
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (isOutsideWorld(blockposition)) {
|
||||
return Blocks.VOID_AIR.getBlockData();
|
||||
} else {
|
||||
@@ -306,11 +510,11 @@
|
||||
@@ -306,11 +480,11 @@
|
||||
}
|
||||
|
||||
public boolean isDay() {
|
||||
@@ -300,7 +270,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -432,9 +636,11 @@
|
||||
@@ -432,9 +606,11 @@
|
||||
TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i);
|
||||
|
||||
if (!tileentity1.isRemoved()) {
|
||||
@@ -312,7 +282,7 @@
|
||||
|
||||
if (this.isLoaded(tileentity1.getPosition())) {
|
||||
Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
|
||||
@@ -442,6 +648,12 @@
|
||||
@@ -442,6 +618,12 @@
|
||||
|
||||
chunk.setTileEntity(tileentity1.getPosition(), tileentity1);
|
||||
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
|
||||
@@ -325,7 +295,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -606,12 +818,26 @@
|
||||
@@ -606,12 +788,25 @@
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -333,7 +303,6 @@
|
||||
public TileEntity getTileEntity(BlockPosition blockposition) {
|
||||
+ return getTileEntity(blockposition, true);
|
||||
+ }
|
||||
+ public Map<BlockPosition, TileEntity> capturedTileEntities = Maps.newHashMap();
|
||||
+
|
||||
+ @Nullable
|
||||
+ protected TileEntity getTileEntity(BlockPosition blockposition, boolean validate) {
|
||||
@@ -352,21 +321,21 @@
|
||||
TileEntity tileentity = null;
|
||||
|
||||
if (this.tickingTileEntities) {
|
||||
@@ -646,6 +872,13 @@
|
||||
@@ -646,6 +841,13 @@
|
||||
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
|
||||
if (!isOutsideWorld(blockposition)) {
|
||||
if (tileentity != null && !tileentity.isRemoved()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (captureBlockStates) {
|
||||
+ tileentity.setLocation(this, blockposition);
|
||||
+ capturedTileEntities.put(blockposition, tileentity);
|
||||
+ capturedTileEntities.put(blockposition.immutableCopy(), tileentity);
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.tickingTileEntities) {
|
||||
tileentity.setLocation(this, blockposition);
|
||||
Iterator iterator = this.tileEntityListPending.iterator();
|
||||
@@ -670,7 +903,7 @@
|
||||
@@ -670,7 +872,7 @@
|
||||
}
|
||||
|
||||
public void removeTileEntity(BlockPosition blockposition) {
|
||||
|
||||
Reference in New Issue
Block a user