mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Block entity cleanup
This commit is contained in:
parent
e4ecd1a092
commit
0f735a8330
15 changed files with 17 additions and 24 deletions
|
@ -31,7 +31,7 @@ import com.nukkitx.nbt.NbtMapBuilder;
|
|||
import org.geysermc.connector.network.translators.item.translators.BannerTranslator;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockStateValues;
|
||||
|
||||
@BlockEntity(name = "Banner", regex = "banner")
|
||||
@BlockEntity(name = "Banner")
|
||||
public class BannerBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
|
||||
@Override
|
||||
public boolean isBlock(int blockState) {
|
||||
|
|
|
@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.world.block.entity;
|
|||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
|
||||
@BlockEntity(name = "Beacon", regex = "beacon")
|
||||
@BlockEntity(name = "Beacon")
|
||||
public class BeaconBlockEntityTranslator extends BlockEntityTranslator {
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockStateValues;
|
||||
|
||||
@BlockEntity(name = "Bed", regex = "bed")
|
||||
@BlockEntity(name = "Bed")
|
||||
public class BedBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
|
||||
@Override
|
||||
public boolean isBlock(int blockState) {
|
||||
|
|
|
@ -36,10 +36,4 @@ public @interface BlockEntity {
|
|||
* @return the name of the block entity
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* The search term used in BlockTranslator
|
||||
* @return the search term used in BlockTranslator
|
||||
*/
|
||||
String regex();
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public abstract class BlockEntityTranslator {
|
|||
int y = ((IntTag) tag.getValue().get("y")).getValue();
|
||||
int z = ((IntTag) tag.getValue().get("z")).getValue();
|
||||
|
||||
NbtMapBuilder tagBuilder = getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(id), x, y, z).toBuilder();
|
||||
NbtMapBuilder tagBuilder = getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(id), x, y, z);
|
||||
translateTag(tagBuilder, tag, blockState);
|
||||
return tagBuilder.build();
|
||||
}
|
||||
|
@ -123,13 +123,12 @@ public abstract class BlockEntityTranslator {
|
|||
return tag;
|
||||
}
|
||||
|
||||
protected NbtMap getConstantBedrockTag(String bedrockId, int x, int y, int z) {
|
||||
protected NbtMapBuilder getConstantBedrockTag(String bedrockId, int x, int y, int z) {
|
||||
return NbtMap.builder()
|
||||
.putInt("x", x)
|
||||
.putInt("y", y)
|
||||
.putInt("z", z)
|
||||
.putString("id", bedrockId)
|
||||
.build();
|
||||
.putString("id", bedrockId);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.nukkitx.nbt.NbtMapBuilder;
|
|||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||
import org.geysermc.connector.network.translators.item.ItemRegistry;
|
||||
|
||||
@BlockEntity(name = "Campfire", regex = "campfire")
|
||||
@BlockEntity(name = "Campfire")
|
||||
public class CampfireBlockEntityTranslator extends BlockEntityTranslator {
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.nukkitx.nbt.NbtMapBuilder;
|
|||
import org.geysermc.connector.network.translators.world.block.BlockStateValues;
|
||||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||
|
||||
@BlockEntity(name = "CommandBlock", regex = "command_block")
|
||||
@BlockEntity(name = "CommandBlock")
|
||||
public class CommandBlockBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.geysermc.connector.utils.BlockEntityUtils;
|
|||
/**
|
||||
* Chests have more block entity properties in Bedrock, which is solved by implementing the BedrockOnlyBlockEntity
|
||||
*/
|
||||
@BlockEntity(name = "Chest", regex = "chest")
|
||||
@BlockEntity(name = "Chest")
|
||||
public class DoubleChestBlockEntityTranslator extends BlockEntityTranslator implements BedrockOnlyBlockEntity, RequiresBlockState {
|
||||
@Override
|
||||
public boolean isBlock(int blockState) {
|
||||
|
@ -46,7 +46,7 @@ public class DoubleChestBlockEntityTranslator extends BlockEntityTranslator impl
|
|||
@Override
|
||||
public void updateBlock(GeyserSession session, int blockState, Vector3i position) {
|
||||
CompoundTag javaTag = getConstantJavaTag("chest", position.getX(), position.getY(), position.getZ());
|
||||
NbtMapBuilder tagBuilder = getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId("chest"), position.getX(), position.getY(), position.getZ()).toBuilder();
|
||||
NbtMapBuilder tagBuilder = getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId("chest"), position.getX(), position.getY(), position.getZ());
|
||||
translateTag(tagBuilder, javaTag, blockState);
|
||||
BlockEntityUtils.updateBlockEntity(session, tagBuilder.build(), position);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.world.block.entity;
|
|||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
|
||||
@BlockEntity(name = "Empty", regex = "")
|
||||
@BlockEntity(name = "Empty")
|
||||
public class EmptyBlockEntityTranslator extends BlockEntityTranslator {
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
|
|
|
@ -35,7 +35,7 @@ import it.unimi.dsi.fastutil.ints.IntList;
|
|||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@BlockEntity(name = "EndGateway", regex = "end_gateway")
|
||||
@BlockEntity(name = "EndGateway")
|
||||
public class EndGatewayBlockEntityTranslator extends BlockEntityTranslator {
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
|
||||
@BlockEntity(name = "JigsawBlock", regex = "jigsaw")
|
||||
@BlockEntity(name = "JigsawBlock")
|
||||
public class JigsawBlockBlockEntityTranslator extends BlockEntityTranslator {
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockStateValues;
|
||||
|
||||
@BlockEntity(name = "ShulkerBox", regex = "shulker_box")
|
||||
@BlockEntity(name = "ShulkerBox")
|
||||
public class ShulkerBoxBlockEntityTranslator extends BlockEntityTranslator {
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.nukkitx.nbt.NbtMapBuilder;
|
|||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||
import org.geysermc.connector.utils.SignUtils;
|
||||
|
||||
@BlockEntity(name = "Sign", regex = "sign")
|
||||
@BlockEntity(name = "Sign")
|
||||
public class SignBlockEntityTranslator extends BlockEntityTranslator {
|
||||
/**
|
||||
* Maps a color stored in a sign's Color tag to a Bedrock Edition formatting code.
|
||||
|
|
|
@ -46,7 +46,7 @@ import java.util.UUID;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@BlockEntity(name = "Skull", regex = "skull")
|
||||
@BlockEntity(name = "Skull")
|
||||
public class SkullBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
|
||||
public static boolean ALLOW_CUSTOM_SKULLS;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
|
||||
@BlockEntity(name = "MobSpawner", regex = "mob_spawner")
|
||||
@BlockEntity(name = "MobSpawner")
|
||||
public class SpawnerBlockEntityTranslator extends BlockEntityTranslator {
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
|
|
Loading…
Reference in a new issue