mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-30 20:29:14 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@7e70636 Initial 1.21.9 update (squashed) PaperMC/Paper@0a28816 Add Server#getRespawnWorld and Server#setRespawnWorld(World) PaperMC/Paper@b67fa6d move todos txt content into tracking issue PaperMC/Paper@68f26a1 Drop no-longer-needed packet diffs PaperMC/Paper@f9434d2 Use pitch when setting spawn position with Location PaperMC/Paper@810b3c6 Deprecate the Conversation API (for removal), Metadata API, and PlayerSpawnLocationEvent (for removal) PaperMC/Paper@1870261 Update Moonrise to 1.21.9-pre1 PaperMC/Paper@1141058 Shift feature patch #s for Moonrise being first PaperMC/Paper@510aa9b Update 'Optimize Network Manager and add advanced packet support' PaperMC/Paper@89cc24a Update 'Allow Saving of Oversized Chunks' PaperMC/Paper@bcd75d8 Update EAR 2.0 patch and enable oldPaperCommit for better 3-way merges PaperMC/Paper@6b44820 Update 'Use Velocity compression and cipher natives' PaperMC/Paper@87f3e2f Update 'Optimize GoalSelector Goal.Flag Set operations' PaperMC/Paper@5323486 Update 'Optimize Voxel Shape Merging' PaperMC/Paper@5aac8b4 Update 'Handle Oversized block entities in chunks' PaperMC/Paper@f0b3d62 Update 'optimize dirt and snow spreading' and drop 'Optimise getChunkAt calls for loaded chunks' patch to code replaced by Moonrise PaperMC/Paper@92f822d Update 'Optimize Bit Operations by inlining', 'Remove streams from hot code' PaperMC/Paper@98e745a Update 'Optimize Pathfinder - Remove Streams / Optimized collections' PaperMC/Paper@49e49d0 Update 'Fix entity tracker desync when new players are added to the tracker' PaperMC/Paper@87e0525 Update alternate redstone impls PaperMC/Paper@35e973d Update 'Improve exact choice recipe ingredients', 'Only write chunk data to disk if it serializes without throwing' PaperMC/Paper@181f9bb Update 'Entity load/save limit per chunk', 'Attempt to recalculate regionfile header if it is corrupt' PaperMC/Paper@b31ca18 Update 'Incremental chunk and player saving', 'Optimise general POI access' PaperMC/Paper@9b69cc5 Add some more Mannequin API PaperMC/Paper@8bb12cb Fix compile PaperMC/Paper@e3aca92 Replace ConcurrentUtil's Validate with Objects PaperMC/Paper@9a626dd Rewrite ticket counter system PaperMC/Paper@65250cb Drop "Optimize Collision to not load chunks" PaperMC/Paper@55d56d9 Apply "Flush regionfiles on save configuration option" PaperMC/Paper@920e8d3 Apply "Optimise collision checking in player move packet handling" PaperMC/Paper@ec492d3 Apply "Improve keepalive ping system" PaperMC/Paper@8f65947 Apply "Optimise EntityScheduler ticking" PaperMC/Paper@086b4fd Apply "Optional per player mob spawns" PaperMC/Paper@2f4211e Apply "Improve cancelling PreCreatureSpawnEvent with per player mob spawns" PaperMC/Paper@b6d9557 Apply "Optimize Hoppers" PaperMC/Paper@388e693 update generator PaperMC/Paper@a3c89a8 add javadocs for new api PaperMC/Paper@fcc763a Call BlockRedstoneEvent for the shelf PaperMC/Paper@03eb18b replace requireNonNull by checkArgument and deprecate MCUtil#toLocation PaperMC/Paper@6b7bf01 bump built-in datapack version PaperMC/Paper@2779a53 deprecate #lanterns material tag in favour of vanilla tag PaperMC/Paper@6f9957e Mannequin#createDefaultProfile -> Mannequin#defaultProfile PaperMC/Paper@24874e5 Also rename Mannequin profile getter/setters for consistency PaperMC/Paper@bc2ae10 Fix default respawn dimension being null for new worlds PaperMC/Paper@eb42158 Use 0.0.4 release of ConcurrentUtil PaperMC/Paper@bb01745 1.21.9-pre2 PaperMC/Paper@0249204 1.21.9-pre2 feature patches PaperMC/Paper@9360ba4 Identifying comments for MinecraftServer PaperMC/Paper@5d3aa53 Some diff improvements in prepare spawn task PaperMC/Paper@22ad451 Move some stuff to ATs PaperMC/Paper@0ea15c9 Drop no longer applicable ATs PaperMC/Paper@cf78f2a bump api-version/datapack format and add a copper torch tag PaperMC/Paper@60cb0df generate ClientOption enums and mark CraftBlockData impl as null marked PaperMC/Paper@4025289 Add pre2 to api version PaperMC/Paper@f2cb073 Set build channel to alpha PaperMC/Paper@90b29c4 Port most of the anti-xray patch PaperMC/Paper@4a8e88d Disable oldPaperCommit to fix CI build PaperMC/Paper@121ac2e Port the last Anti-XRay hunk PaperMC/Paper@f43641f Use ConcurrentUtil 0.0.5 PaperMC/Paper@1f79388 fix end portal teleportation PaperMC/Paper@2efb400 [ci skip] Adjust spawn location event docs PaperMC/Paper@cb9fc05 simplify overloads PaperMC/Paper@25ecc59 Enable Anti-Xray PaperMC/Paper@4d7185f Add AsyncPlayerSpawnLocationEvent#isNewPlayer (#13081) PaperMC/Paper@dc474a8 Fixup vanilla code for Anti-Xray changes PaperMC/Paper@0e23b02 Add back null check for chunkPacketBlockController PaperMC/Paper@e6f1483 Update to 1.21.9-pre3 PaperMC/Paper@44259ea Add ResolvableProfile.SkinPatch (#13091) PaperMC/Paper@634f51e Update to 1.21.9-pre4 PaperMC/Paper@fada3a7 Update DataConverter to 1.21.9-pre4 PaperMC/Paper@037179f Update Starlight stored version PaperMC/Paper@6b0b29a Update publishing endpoint PaperMC/Paper@f6fabc5 Call EntityChangeBlockEvent for copper golem statue changes (#13090) PaperMC/Paper@1d6ee7d Update adventure PaperMC/Paper@404e49f Update to 1.21.9-rc1 PaperMC/Paper@4055274 Fix empty SkinPatch initialization and swapped dynamic/static heuristic in ResolvableProfile build method PaperMC/Paper@51fe7aa Fixed modern forwarding support (#13098) PaperMC/Paper@5613a35 fix PlayerGameModeChangeEvent#cancelMessage PaperMC/Paper@673abf4 use PlayerShieldDisableEvent#getCooldown PaperMC/Paper@3a0dc7f Fix a couple PlayerProfile mutability issues PaperMC/Paper@e97fb40 Remove parallel generation config option PaperMC/Paper@c3a60b8 Use ThreadLocal for Starlight and ticket level propagator cache PaperMC/Paper@e16b369 Resize propagator queues less aggressively
347 lines
18 KiB
Diff
347 lines
18 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Sat, 9 Sep 2023 18:39:15 +0100
|
|
Subject: [PATCH] Merge Cannon Entities
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index bc714079924b4a724a6f1aa7ccfa53884a9e4fa9..259faa131f4aec7db565c78c38aa058d20ef3d28 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -709,6 +709,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
// Paper end - rewrite chunk system
|
|
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
|
this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings
|
|
+ this.levelTickScheduler.repeatingTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities
|
|
}
|
|
|
|
// Paper start
|
|
@@ -827,6 +828,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
|
|
io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR
|
|
+ final Entity[] previousEntity = new Entity[1]; // Sakura - merge cannon entities
|
|
this.entityTickList
|
|
.forEach(
|
|
entity -> {
|
|
@@ -845,6 +847,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
entity.stopRiding();
|
|
}
|
|
|
|
+ // Sakura start - merge cannon entities
|
|
+ final Entity previous = previousEntity[0];
|
|
+ if (this.mergeHandler.tryMerge(entity, previous)) {
|
|
+ return;
|
|
+ } else {
|
|
+ previousEntity[0] = entity;
|
|
+ }
|
|
+ // Sakura end - merge cannon entities
|
|
+
|
|
profilerFiller.push("tick");
|
|
this.guardEntityTick(this::tickNonPassenger, entity);
|
|
profilerFiller.pop();
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 127479da921c2679e19f13e71cc04be8a310b459..4ce3d09d30996fb2c13afe799bb31d910ce666ba 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -567,6 +567,27 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
|
return to.entityState() != null && to.entityState().comparePositionAndMotion(this);
|
|
}
|
|
// Sakura end - store entity data/state
|
|
+ // Sakura start - merge cannon entities
|
|
+ public final void updateBukkitHandle(final Entity entity) {
|
|
+ if (this.bukkitEntity != null) {
|
|
+ this.bukkitEntity.setHandle(entity);
|
|
+ } else {
|
|
+ this.bukkitEntity = entity.getBukkitEntity();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public final long getPackedOriginPosition() {
|
|
+ if (this.origin != null) {
|
|
+ return BlockPos.asLong(
|
|
+ Mth.floor(this.origin.x()),
|
|
+ Mth.floor(this.origin.y()),
|
|
+ Mth.floor(this.origin.z())
|
|
+ );
|
|
+ } else {
|
|
+ return Long.MIN_VALUE;
|
|
+ }
|
|
+ }
|
|
+ // Sakura end - merge cannon entities
|
|
|
|
public Entity(EntityType<?> entityType, Level level) {
|
|
this.type = entityType;
|
|
@@ -5241,6 +5262,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
|
if (this.removalReason != Entity.RemovalReason.UNLOADED_TO_CHUNK) { this.getPassengers().forEach(Entity::stopRiding); } // Paper - rewrite chunk system
|
|
this.levelCallback.onRemove(removalReason);
|
|
this.onRemoval(removalReason);
|
|
+ // Sakura start - merge cannon entities
|
|
+ if (removalReason == RemovalReason.DISCARDED) {
|
|
+ this.level.mergeHandler.removeEntity(this);
|
|
+ }
|
|
+ // Sakura end - merge cannon entities
|
|
// Paper start - Folia schedulers
|
|
if (!(this instanceof ServerPlayer) && removalReason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
|
|
// Players need to be special cased, because they are regularly removed from the world
|
|
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
index 59aa539b7d830de48ff582b0da6fa17796b8c4b8..af7dd04ecbf9e8b35357da421fb156aee61261b5 100644
|
|
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -53,7 +53,7 @@ import net.minecraft.world.phys.HitResult;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import org.slf4j.Logger;
|
|
|
|
-public class FallingBlockEntity extends Entity {
|
|
+public class FallingBlockEntity extends Entity implements me.samsuik.sakura.entity.merge.MergeableEntity { // Sakura - merge cannon entities
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
private static final BlockState DEFAULT_BLOCK_STATE = Blocks.SAND.defaultBlockState();
|
|
private static final int DEFAULT_TIME = 0;
|
|
@@ -75,12 +75,63 @@ public class FallingBlockEntity extends Entity {
|
|
public boolean autoExpire = true; // Paper - Expand FallingBlock API
|
|
public boolean heightParity; // Sakura - falling block height parity api
|
|
|
|
+ // Sakura start - merge cannon entities
|
|
+ private final me.samsuik.sakura.entity.merge.MergeEntityData mergeData = new me.samsuik.sakura.entity.merge.MergeEntityData(this);
|
|
+
|
|
+ @Override
|
|
+ public final me.samsuik.sakura.entity.merge.MergeEntityData getMergeEntityData() {
|
|
+ return this.mergeData;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final boolean isSafeToMergeInto(final me.samsuik.sakura.entity.merge.MergeableEntity entity, final boolean ticksLived) {
|
|
+ return entity instanceof FallingBlockEntity fbe
|
|
+ && fbe.blockState.equals(this.blockState)
|
|
+ && (!ticksLived || fbe.time - 1 == this.time);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final void respawnEntity(int count) {
|
|
+ while (count-- >= 1) {
|
|
+ // Unlike PrimedTnt we have to try respawn each stacked entity
|
|
+ final FallingBlockEntity fallingBlock = new FallingBlockEntity(EntityType.FALLING_BLOCK, this.level());
|
|
+
|
|
+ // Try to stack the falling block
|
|
+ this.entityState().apply(fallingBlock);
|
|
+ fallingBlock.blockState = this.blockState;
|
|
+ fallingBlock.spawnReason = this.spawnReason;
|
|
+ fallingBlock.time = this.time - 1;
|
|
+ fallingBlock.tick();
|
|
+
|
|
+ // If you horizontal stack into a moving piston block this condition will be met.
|
|
+ if (!fallingBlock.isRemoved()) {
|
|
+ this.mergeData.count = count + 1;
|
|
+ fallingBlock.storeEntityState();
|
|
+ fallingBlock.entityState().apply(this);
|
|
+ break;
|
|
+ } else if (count == 0) {
|
|
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public @Nullable ItemEntity spawnAtLocation(final ServerLevel level, final net.minecraft.world.level.ItemLike item) { // may be overridden by plugins
|
|
+ ItemEntity itemEntity = null;
|
|
+ for (int i = 0; i < this.mergeData.count; ++i) {
|
|
+ itemEntity = super.spawnAtLocation(level, item);
|
|
+ }
|
|
+ return itemEntity;
|
|
+ }
|
|
+ // Sakura end - merge cannon entities
|
|
+
|
|
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
|
|
super(entityType, level);
|
|
this.dropItem = level.sakuraConfig().cannons.sand.dropItems; // Sakura - configure falling blocks dropping items
|
|
this.heightParity = level.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics
|
|
this.isFallingBlock = true; // Sakura - client visibility settings
|
|
this.loadChunks = level.sakuraConfig().cannons.loadChunks; // Sakura - load chunks on movement
|
|
+ this.mergeData.mergeLevel = level.sakuraConfig().cannons.mergeLevel; // Sakura - merge cannon entities
|
|
}
|
|
|
|
public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) {
|
|
@@ -239,6 +290,7 @@ public class FallingBlockEntity extends Entity {
|
|
return;
|
|
}
|
|
// CraftBukkit end
|
|
+ if (this.tryToRespawnEntity()) return; // Sakura - merge cannon entities
|
|
if (this.level().setBlock(blockPos, this.blockState, 3)) {
|
|
serverLevel.getChunkSource()
|
|
.chunkMap
|
|
@@ -345,6 +397,11 @@ public class FallingBlockEntity extends Entity {
|
|
|
|
output.putBoolean("CancelDrop", this.cancelDrop);
|
|
if (!this.autoExpire) output.putBoolean("Paper.AutoExpire", false); // Paper - Expand FallingBlock API
|
|
+ // Sakura start - merge cannon entities; save to nbt
|
|
+ if (this.mergeData.count != 1) {
|
|
+ output.putInt("merge_count", this.mergeData.count);
|
|
+ }
|
|
+ // Sakura end - merge cannon entities; save to nbt
|
|
}
|
|
|
|
@Override
|
|
@@ -359,6 +416,7 @@ public class FallingBlockEntity extends Entity {
|
|
this.blockData = input.read("TileEntityData", CompoundTag.CODEC).map(blockData -> this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock ? null : blockData).map(CompoundTag::copy).orElse(null); // Paper - Filter bad block entity nbt data from falling blocks
|
|
this.cancelDrop = input.getBooleanOr("CancelDrop", false);
|
|
this.autoExpire = input.getBooleanOr("Paper.AutoExpire", true); // Paper - Expand FallingBlock API
|
|
+ this.mergeData.count = input.getIntOr("merge_count", 1); // Sakura - merge cannon entities; load from nbt
|
|
}
|
|
|
|
public void setHurtsEntities(float fallDamagePerDistance, int fallDamageMax) {
|
|
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
|
|
index 6797e16f973b11d168906dfce240c70db25bc6f0..8a36e0ce4792e7152905256dde7746fd09d42729 100644
|
|
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -34,7 +34,7 @@ import org.bukkit.event.entity.EntityRemoveEvent;
|
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
// CraftBukkit end
|
|
|
|
-public class PrimedTnt extends Entity implements TraceableEntity {
|
|
+public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sakura.entity.merge.MergeableEntity { // Sakura - merge cannon entities
|
|
private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT);
|
|
private static final EntityDataAccessor<BlockState> DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE);
|
|
private static final short DEFAULT_FUSE_TIME = 80;
|
|
@@ -60,11 +60,48 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
public float explosionPower = 4.0F;
|
|
public boolean isIncendiary = false; // CraftBukkit
|
|
|
|
+ // Sakura start - merge cannon entities
|
|
+ private final me.samsuik.sakura.entity.merge.MergeEntityData mergeData = new me.samsuik.sakura.entity.merge.MergeEntityData(this);
|
|
+
|
|
+ @Override
|
|
+ public final me.samsuik.sakura.entity.merge.MergeEntityData getMergeEntityData() {
|
|
+ return this.mergeData;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final boolean isSafeToMergeInto(final me.samsuik.sakura.entity.merge.MergeableEntity entity, final boolean ticksLived) {
|
|
+ return entity instanceof PrimedTnt tnt
|
|
+ && tnt.getFuse() + 1 == this.getFuse()
|
|
+ // required to prevent issues with powdered snow
|
|
+ && (tnt.entityState().fallDistance() == this.fallDistance
|
|
+ || tnt.entityState().fallDistance() > 2.5f && this.fallDistance > 2.5f);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final void respawnEntity(int count) {
|
|
+ final PrimedTnt tnt = new PrimedTnt(EntityType.TNT, this.level());
|
|
+ tnt.updateBukkitHandle(this); // update handle for plugins
|
|
+ while (count-- > 1) {
|
|
+ this.setFuse(100); // Prevent unwanted explosions while ticking
|
|
+
|
|
+ // Cause an explosion to affect this entity
|
|
+ tnt.setPos(this.position());
|
|
+ tnt.setDeltaMovement(this.getDeltaMovement());
|
|
+ this.entityState().apply(this);
|
|
+ tnt.explode();
|
|
+ this.storeEntityState();
|
|
+
|
|
+ this.tick();
|
|
+ }
|
|
+ }
|
|
+ // Sakura end - merge cannon entities
|
|
+
|
|
public PrimedTnt(EntityType<? extends PrimedTnt> entityType, Level level) {
|
|
super(entityType, level);
|
|
this.blocksBuilding = true;
|
|
this.isPrimedTNT = true; // Sakura - client visibility settings
|
|
this.loadChunks = level.sakuraConfig().cannons.loadChunks; // Sakura - load chunks on movement
|
|
+ this.mergeData.mergeLevel = level.sakuraConfig().cannons.mergeLevel; // Sakura - merge cannon entities
|
|
}
|
|
|
|
public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
|
|
@@ -144,6 +181,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
if (i <= 0) {
|
|
// CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
|
|
//this.discard();
|
|
+ this.tryToRespawnEntity(); // Sakura - merge cannon entities
|
|
if (!this.level().isClientSide()) {
|
|
this.explode();
|
|
}
|
|
@@ -203,6 +241,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
}
|
|
|
|
EntityReference.store(this.owner, output, "owner");
|
|
+ // Sakura start - merge cannon entities; save to nbt
|
|
+ if (this.mergeData.count != 1) {
|
|
+ output.putInt("merge_count", this.mergeData.count);
|
|
+ }
|
|
+ // Sakura end - merge cannon entities; save to nbt
|
|
}
|
|
|
|
@Override
|
|
@@ -211,6 +254,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
this.setBlockState(input.read("block_state", BlockState.CODEC).orElse(DEFAULT_BLOCK_STATE));
|
|
this.explosionPower = Mth.clamp(input.getFloatOr("explosion_power", 4.0F), 0.0F, 128.0F);
|
|
this.owner = EntityReference.read(input, "owner");
|
|
+ this.mergeData.count = input.getIntOr("merge_count", 1); // Sakura - merge cannon entities; load from nbt
|
|
}
|
|
|
|
@Nullable
|
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
|
index 5f49990b13ac7fdd4366585d976d50bd3ae183cb..93ff0fdaee21ac493833640b5f620f9bec1a69c8 100644
|
|
--- a/net/minecraft/world/level/Level.java
|
|
+++ b/net/minecraft/world/level/Level.java
|
|
@@ -833,6 +833,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
public final me.samsuik.sakura.listener.LevelTickScheduler levelTickScheduler = new me.samsuik.sakura.listener.LevelTickScheduler(this);
|
|
public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this);
|
|
// Sakura end - track block changes and tick scheduler
|
|
+ public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
|
|
|
|
protected Level(
|
|
WritableLevelData levelData,
|
|
diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
|
index fe9b5cf6fb8d8221b98836148e95aa857241181d..f9c1c5a7f0602c225d18005e7161384cc1d3c604 100644
|
|
--- a/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
|
+++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
|
@@ -92,7 +92,7 @@ public abstract class BasePressurePlateBlock extends Block {
|
|
}
|
|
|
|
private void checkPressed(@Nullable Entity entity, Level level, BlockPos pos, BlockState state, int currentSignal) {
|
|
- int signalStrength = this.getSignalStrength(level, pos);
|
|
+ int signalStrength = this.getSignalStrength(level, pos, currentSignal == 0); // Sakura - merge cannon entities
|
|
boolean flag = currentSignal > 0;
|
|
boolean flag1 = signalStrength > 0;
|
|
|
|
@@ -162,6 +162,12 @@ public abstract class BasePressurePlateBlock extends Block {
|
|
// CraftBukkit end
|
|
}
|
|
|
|
+ // Sakura start - merge cannon entities
|
|
+ protected int getSignalStrength(final Level world, final BlockPos pos, final boolean entityInside) {
|
|
+ return this.getSignalStrength(world, pos);
|
|
+ }
|
|
+ // Sakura end - merge cannon entities
|
|
+
|
|
protected abstract int getSignalStrength(Level level, BlockPos pos);
|
|
|
|
protected abstract int getSignalForState(BlockState state);
|
|
diff --git a/net/minecraft/world/level/block/WeightedPressurePlateBlock.java b/net/minecraft/world/level/block/WeightedPressurePlateBlock.java
|
|
index 5e095919828e89d12f2676b3c544842a81e047a1..e45ceec307a4944f40d044af0369d0c598a4e9ae 100644
|
|
--- a/net/minecraft/world/level/block/WeightedPressurePlateBlock.java
|
|
+++ b/net/minecraft/world/level/block/WeightedPressurePlateBlock.java
|
|
@@ -39,6 +39,13 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock {
|
|
|
|
@Override
|
|
protected int getSignalStrength(Level level, BlockPos pos) {
|
|
+ // Sakura start - merge cannon entities
|
|
+ return this.getSignalStrength(level, pos, false);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected final int getSignalStrength(final Level level, final BlockPos pos, final boolean entityInside) {
|
|
+ // Sakura end - merge cannon entities
|
|
// CraftBukkit start
|
|
// int min = Math.min(getEntityCount(level, TOUCH_AABB.move(pos), Entity.class), this.maxWeight);
|
|
int min = 0;
|
|
@@ -54,7 +61,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock {
|
|
|
|
// We only want to block turning the plate on if all events are cancelled
|
|
if (!cancellable.isCancelled()) {
|
|
- min++;
|
|
+ min += !entityInside && entity instanceof me.samsuik.sakura.entity.merge.MergeableEntity mergeEntity ? mergeEntity.getMergeEntityData().count : 1; // Sakura - merge cannon entities
|
|
}
|
|
}
|
|
// CraftBukkit end
|