mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix compilation for Spigot
This commit is contained in:
parent
beef01f3fc
commit
a439f3e3d7
5 changed files with 34 additions and 29 deletions
|
@ -30,8 +30,8 @@ import it.unimi.dsi.fastutil.Pair;
|
|||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
|
@ -157,7 +157,7 @@ public final class GeyserboundPacketHandlerImpl extends AbstractGeyserboundPacke
|
|||
.stream()
|
||||
.map(entry -> Pair.of(entry.getKey(), BlockState.of(entry.getIntValue())))
|
||||
.filter(pair -> BlockStateValues.canPistonMoveBlock(pair.value(), isExtend));
|
||||
Object2ObjectMap<Vector3i, BlockState> attachedBlocks = new Object2ObjectOpenHashMap<>();
|
||||
Object2ObjectMap<Vector3i, BlockState> attachedBlocks = new Object2ObjectArrayMap<>();
|
||||
stream.forEach(pair -> attachedBlocks.put(pair.key(), pair.value()));
|
||||
|
||||
session.executeInEventLoop(() -> {
|
||||
|
|
|
@ -62,6 +62,16 @@ public final class BlockState {
|
|||
return this.block == block;
|
||||
}
|
||||
|
||||
private String paramsToString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var it = this.states.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
var entry = it.next();
|
||||
builder.append(entry.getKey()).append("=").append(entry.getValue());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static BlockState of(int javaId) {
|
||||
return BlockRegistries.BLOCK_STATES.get(javaId);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package org.geysermc.geyser.translator.level.block.entity;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||
import org.geysermc.geyser.level.block.type.BlockState;
|
||||
|
@ -56,6 +57,10 @@ public abstract class BlockEntityTranslator {
|
|||
return getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(type), x, y, z);
|
||||
}
|
||||
|
||||
public static NbtMapBuilder getConstantBedrockTag(String bedrockId, Vector3i position) {
|
||||
return getConstantBedrockTag(bedrockId, position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
public static NbtMapBuilder getConstantBedrockTag(String bedrockId, int x, int y, int z) {
|
||||
return NbtMap.builder()
|
||||
.putInt("x", x)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.translator.level.block.entity;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntArrays;
|
||||
import it.unimi.dsi.fastutil.objects.*;
|
||||
import org.geysermc.geyser.level.block.Blocks;
|
||||
import org.geysermc.geyser.level.block.type.Block;
|
||||
|
@ -74,7 +75,7 @@ public class PistonBlockEntity {
|
|||
/**
|
||||
* A flattened array of the positions of attached blocks, stored in XYZ order.
|
||||
*/
|
||||
private int[] flattenedAttachedBlocks = new int[0];
|
||||
private int[] flattenedAttachedBlocks = IntArrays.EMPTY_ARRAY;
|
||||
|
||||
private boolean placedFinalBlocks = true;
|
||||
|
||||
|
@ -732,18 +733,14 @@ public class PistonBlockEntity {
|
|||
* @return A piston data tag
|
||||
*/
|
||||
private NbtMap buildPistonTag() {
|
||||
NbtMapBuilder builder = NbtMap.builder()
|
||||
.putString("id", "PistonArm")
|
||||
NbtMapBuilder builder = BlockEntityTranslator.getConstantBedrockTag("PistonArm", position)
|
||||
.putIntArray("AttachedBlocks", flattenedAttachedBlocks)
|
||||
.putFloat("Progress", progress)
|
||||
.putFloat("LastProgress", lastProgress)
|
||||
.putByte("NewState", getState())
|
||||
.putByte("State", getState())
|
||||
.putBoolean("Sticky", sticky)
|
||||
.putBoolean("isMovable", false)
|
||||
.putInt("x", position.getX())
|
||||
.putInt("y", position.getY())
|
||||
.putInt("z", position.getZ());
|
||||
.putBoolean("isMovable", false);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -756,17 +753,13 @@ public class PistonBlockEntity {
|
|||
* @return A piston data tag for a fully extended/retracted piston
|
||||
*/
|
||||
public static NbtMap buildStaticPistonTag(Vector3i position, boolean extended, boolean sticky) {
|
||||
NbtMapBuilder builder = NbtMap.builder()
|
||||
.putString("id", "PistonArm")
|
||||
NbtMapBuilder builder = BlockEntityTranslator.getConstantBedrockTag("PistonArm", position)
|
||||
.putFloat("Progress", extended ? 1.0f : 0.0f)
|
||||
.putFloat("LastProgress", extended ? 1.0f : 0.0f)
|
||||
.putByte("NewState", (byte) (extended ? 2 : 0))
|
||||
.putByte("State", (byte) (extended ? 2 : 0))
|
||||
.putBoolean("Sticky", sticky)
|
||||
.putBoolean("isMovable", false)
|
||||
.putInt("x", position.getX())
|
||||
.putInt("y", position.getY())
|
||||
.putInt("z", position.getZ());
|
||||
.putBoolean("isMovable", false);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -781,17 +774,13 @@ public class PistonBlockEntity {
|
|||
private NbtMap buildMovingBlockTag(Vector3i position, BlockState state, Vector3i pistonPosition) {
|
||||
// Get Bedrock block state data
|
||||
NbtMap movingBlock = session.getBlockMappings().getBedrockBlock(state).getState();
|
||||
NbtMapBuilder builder = NbtMap.builder()
|
||||
.putString("id", "MovingBlock")
|
||||
NbtMapBuilder builder = BlockEntityTranslator.getConstantBedrockTag("MovingBlock", position)
|
||||
.putBoolean("expanding", action == PistonValueType.PUSHING)
|
||||
.putCompound("movingBlock", movingBlock)
|
||||
.putBoolean("isMovable", true)
|
||||
.putInt("pistonPosX", pistonPosition.getX())
|
||||
.putInt("pistonPosY", pistonPosition.getY())
|
||||
.putInt("pistonPosZ", pistonPosition.getZ())
|
||||
.putInt("x", position.getX())
|
||||
.putInt("y", position.getY())
|
||||
.putInt("z", position.getZ());
|
||||
.putInt("pistonPosZ", pistonPosition.getZ());
|
||||
if (state.block() instanceof PistonBlock piston) {
|
||||
builder.putCompound("movingEntity", piston.createTag(session, position, state));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue