mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
[ci skip] add a good chunk of patch identifying comments
This commit is contained in:
@@ -5,14 +5,14 @@ Subject: [PATCH] Stored Bee API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
index 7f0e37e23ff4c64355fdc822c0ac683959b8588a..6fa25cac9d88808a590281bf90f619fa2f167d4a 100644
|
||||
index 7f0e37e23ff4c64355fdc822c0ac683959b8588a..fdebf45a27b903f4abb0bf55e1d79d78b7cc3d32 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
@@ -147,11 +147,33 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
return list;
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Stored Bee API
|
||||
+ public List<Entity> releaseBee(BlockState iblockdata, BeehiveBlockEntity.BeeData data, BeehiveBlockEntity.BeeReleaseStatus tileentitybeehive_releasestatus, boolean force) {
|
||||
+ List<Entity> list = Lists.newArrayList();
|
||||
+
|
||||
@@ -26,18 +26,18 @@ index 7f0e37e23ff4c64355fdc822c0ac683959b8588a..6fa25cac9d88808a590281bf90f619fa
|
||||
+
|
||||
+ return list;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Stored Bee API
|
||||
+
|
||||
@VisibleForDebug
|
||||
public int getOccupantCount() {
|
||||
return this.stored.size();
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Stored Bee API
|
||||
+ public List<BeeData> getStored() {
|
||||
+ return stored;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Stored Bee API
|
||||
+
|
||||
// Paper start - Add EntityBlockStorage clearEntities
|
||||
public void clearBees() {
|
||||
@@ -47,43 +47,42 @@ index 7f0e37e23ff4c64355fdc822c0ac683959b8588a..6fa25cac9d88808a590281bf90f619fa
|
||||
}
|
||||
|
||||
- private static class BeeData {
|
||||
+ public static class BeeData { // Purpur - change from private to public
|
||||
+ public static class BeeData { // Purpur - change from private to public - Stored Bee API
|
||||
|
||||
- private final BeehiveBlockEntity.Occupant occupant;
|
||||
+ public final BeehiveBlockEntity.Occupant occupant; // Purpur - make public
|
||||
+ public final BeehiveBlockEntity.Occupant occupant; // Purpur - make public - Stored Bee API
|
||||
private int exitTickCounter; // Paper - Fix bees aging inside hives; separate counter for checking if bee should exit to reduce exit attempts
|
||||
private int ticksInHive;
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
|
||||
index 1a2a05160ba51d9c75f1ae6ae61d944d81428722..3beb26ad2ef0fded49a8da8c5dec64f9508c1995 100644
|
||||
index 1a2a05160ba51d9c75f1ae6ae61d944d81428722..a86b026f2f420637d125cf697bcd07bf314c98aa 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java
|
||||
@@ -16,8 +16,15 @@ import org.bukkit.entity.Bee;
|
||||
|
||||
public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> implements Beehive {
|
||||
|
||||
+ private final List<org.purpurmc.purpur.entity.StoredEntity<Bee>> storage = new ArrayList<>(); // Purpur
|
||||
+ private final List<org.purpurmc.purpur.entity.StoredEntity<Bee>> storage = new ArrayList<>(); // Purpur - Stored Bee API
|
||||
+
|
||||
public CraftBeehive(World world, BeehiveBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
+ // Purpur start - load bees to be able to modify them individually
|
||||
+ // Purpur start - load bees to be able to modify them individually - Stored Bee API
|
||||
+ for(BeehiveBlockEntity.BeeData data : tileEntity.getStored()) {
|
||||
+ storage.add(new org.purpurmc.purpur.entity.PurpurStoredBee(data, this));
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Stored Bee API
|
||||
}
|
||||
|
||||
protected CraftBeehive(CraftBeehive state, Location location) {
|
||||
@@ -75,15 +82,54 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
|
||||
bees.add((Bee) bee.getBukkitEntity());
|
||||
@@ -76,14 +83,54 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
|
||||
}
|
||||
}
|
||||
-
|
||||
+ storage.clear(); // Purpur
|
||||
|
||||
+ storage.clear(); // Purpur - Stored Bee API
|
||||
return bees;
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ // Purpur start - Stored Bee API
|
||||
+ @Override
|
||||
+ public Bee releaseEntity(org.purpurmc.purpur.entity.StoredEntity<Bee> entity) {
|
||||
+ ensureNoWorldGeneration();
|
||||
@@ -112,30 +111,29 @@ index 1a2a05160ba51d9c75f1ae6ae61d944d81428722..3beb26ad2ef0fded49a8da8c5dec64f9
|
||||
+ public List<org.purpurmc.purpur.entity.StoredEntity<Bee>> getEntities() {
|
||||
+ return new ArrayList<>(storage);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Stored Bee API
|
||||
+
|
||||
@Override
|
||||
public void addEntity(Bee entity) {
|
||||
Preconditions.checkArgument(entity != null, "Entity must not be null");
|
||||
|
||||
- this.getSnapshot().addOccupant(((CraftBee) entity).getHandle());
|
||||
+ int length = this.getSnapshot().getStored().size(); // Purpur
|
||||
+ getSnapshot().addOccupant(((CraftBee) entity).getHandle());
|
||||
+ int length = this.getSnapshot().getStored().size(); // Purpur - Stored Bee API
|
||||
this.getSnapshot().addOccupant(((CraftBee) entity).getHandle());
|
||||
+
|
||||
+ // Purpur start - check if new bee was added, and if yes, add to stored bees
|
||||
+ // Purpur start - check if new bee was added, and if yes, add to stored bees - Stored Bee API
|
||||
+ List<BeehiveBlockEntity.BeeData> storedBeeData = this.getSnapshot().getStored();
|
||||
+ if(length < storedBeeData.size()) {
|
||||
+ storage.add(new org.purpurmc.purpur.entity.PurpurStoredBee(storedBeeData.getLast(), this));
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ // Purpur end - Stored Bee API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,6 +146,7 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
|
||||
@@ -100,6 +147,7 @@ public class CraftBeehive extends CraftBlockEntityState<BeehiveBlockEntity> impl
|
||||
@Override
|
||||
public void clearEntities() {
|
||||
getSnapshot().clearBees();
|
||||
+ storage.clear(); // Purpur
|
||||
+ storage.clear(); // Purpur - Stored Bee API
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user