Merge branch 'master' into feature/1.21.20

This commit is contained in:
Kas-tle 2024-07-30 06:32:26 -07:00 committed by GitHub
commit 841cb68003
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 155 additions and 20 deletions

View file

@ -131,7 +131,7 @@ public final class BlockRegistryPopulator {
NbtMapBuilder builder = vanillaBlockStates.get(i).toBuilder();
builder.remove("version"); // Remove all nbt tags which are not needed for differentiating states
builder.remove("name_hash"); // Quick workaround - was added in 1.19.20
builder.remove("network_id"); // Added in 1.19.80 - ????
builder.remove("network_id"); // Added in 1.19.80
builder.remove("block_id"); // Added in 1.20.60
//noinspection UnstableApiUsage
builder.putCompound("states", statesInterner.intern((NbtMap) builder.remove("states")));

View file

@ -37,7 +37,6 @@ import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.cloudburstmc.protocol.bedrock.packet.UpdateBlockPacket;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.level.block.BlockStateValues;
import org.geysermc.geyser.level.block.Blocks;
import org.geysermc.geyser.level.block.property.Properties;
@ -230,8 +229,8 @@ public class PistonBlockEntity {
BlockState state = session.getGeyser().getWorldManager().blockAt(session, blockInFront);
if (state.is(Blocks.PISTON_HEAD)) {
ChunkUtils.updateBlock(session, Block.JAVA_AIR_ID, blockInFront);
} else if ((session.getGeyser().getPlatformType() == PlatformType.SPIGOT || session.getErosionHandler().isActive()) && state.is(Blocks.AIR)) {
// Spigot removes the piston head from the cache, but we need to send the block update ourselves
} else if ((session.getGeyser().getWorldManager().hasOwnChunkCache() || session.getErosionHandler().isActive()) && state.is(Blocks.AIR)) {
// The platform removes the piston head from the cache, but we need to send the block update ourselves
ChunkUtils.updateBlock(session, Block.JAVA_AIR_ID, blockInFront);
}
}

View file

@ -82,16 +82,22 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
Direction direction = Direction.fromPistonValue(pistonValue.getDirection());
PistonCache pistonCache = session.getPistonCache();
if (session.getGeyser().getPlatformType() == PlatformType.SPIGOT || session.getErosionHandler().isActive()) {
// Mostly handled in the GeyserPistonEvents class
// Retracting sticky pistons is an exception, since the event is not called on Spigot from 1.13.2 - 1.17.1
// See https://github.com/PaperMC/Paper/blob/6fa1983e9ce177a4a412d5b950fd978620174777/patches/server/0304-Fire-BlockPistonRetractEvent-for-all-empty-pistons.patch
if (session.getGeyser().getWorldManager().hasOwnChunkCache() || session.getErosionHandler().isActive()) {
// Mostly handled in the GeyserPistonEvents class (Spigot) / the PistonBlockBaseMixin (Mod platforms)
// However, the retracting event is not fully covered. (Spigot)
// Mod platforms only handle pistons moving blocks; not the retracting of pistons.
if (action == PistonValueType.PULLING || action == PistonValueType.CANCELLED_MID_PUSH) {
BlockState pistonBlock = session.getGeyser().getWorldManager().blockAt(session, position);
if (!isSticky(pistonBlock)) {
// Retracting sticky pistons is an exception, since the event is not called on Spigot from 1.13.2 - 1.17.1
// See https://github.com/PaperMC/Paper/blob/6fa1983e9ce177a4a412d5b950fd978620174777/patches/server/0304-Fire-BlockPistonRetractEvent-for-all-empty-pistons.patch
boolean isSticky = isSticky(pistonBlock);
if (session.getGeyser().getPlatformType() == PlatformType.SPIGOT && !isSticky) {
return;
}
if (action != PistonValueType.CANCELLED_MID_PUSH) {
// Only sticky pistons that don't pull any blocks are affected
if (action != PistonValueType.CANCELLED_MID_PUSH && isSticky) {
Vector3i blockInFrontPos = position.add(direction.getUnitVector());
int blockInFront = session.getGeyser().getWorldManager().getBlockAt(session, blockInFrontPos);
if (blockInFront != Block.JAVA_AIR_ID) {
@ -99,7 +105,7 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
return;
}
}
PistonBlockEntity blockEntity = pistonCache.getPistons().computeIfAbsent(position, pos -> new PistonBlockEntity(session, pos, direction, true, true));
PistonBlockEntity blockEntity = pistonCache.getPistons().computeIfAbsent(position, pos -> new PistonBlockEntity(session, pos, direction, isSticky, true));
if (blockEntity.getAction() != action) {
blockEntity.setAction(action, Object2ObjectMaps.emptyMap());
}