3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 16:40:14 +01:00

Block entity cleanup

Dieser Commit ist enthalten in:
Camotoy 2020-12-23 12:37:55 -05:00
Ursprung e4ecd1a092
Commit 0f735a8330
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
15 geänderte Dateien mit 17 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -31,7 +31,7 @@ import com.nukkitx.nbt.NbtMapBuilder;
import org.geysermc.connector.network.translators.item.translators.BannerTranslator; import org.geysermc.connector.network.translators.item.translators.BannerTranslator;
import org.geysermc.connector.network.translators.world.block.BlockStateValues; import org.geysermc.connector.network.translators.world.block.BlockStateValues;
@BlockEntity(name = "Banner", regex = "banner") @BlockEntity(name = "Banner")
public class BannerBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState { public class BannerBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override @Override
public boolean isBlock(int blockState) { public boolean isBlock(int blockState) {

Datei anzeigen

@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtMapBuilder;
@BlockEntity(name = "Beacon", regex = "beacon") @BlockEntity(name = "Beacon")
public class BeaconBlockEntityTranslator extends BlockEntityTranslator { public class BeaconBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {

Datei anzeigen

@ -29,7 +29,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtMapBuilder;
import org.geysermc.connector.network.translators.world.block.BlockStateValues; import org.geysermc.connector.network.translators.world.block.BlockStateValues;
@BlockEntity(name = "Bed", regex = "bed") @BlockEntity(name = "Bed")
public class BedBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState { public class BedBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override @Override
public boolean isBlock(int blockState) { public boolean isBlock(int blockState) {

Datei anzeigen

@ -36,10 +36,4 @@ public @interface BlockEntity {
* @return the name of the block entity * @return the name of the block entity
*/ */
String name(); String name();
/**
* The search term used in BlockTranslator
* @return the search term used in BlockTranslator
*/
String regex();
} }

Datei anzeigen

@ -109,7 +109,7 @@ public abstract class BlockEntityTranslator {
int y = ((IntTag) tag.getValue().get("y")).getValue(); int y = ((IntTag) tag.getValue().get("y")).getValue();
int z = ((IntTag) tag.getValue().get("z")).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); translateTag(tagBuilder, tag, blockState);
return tagBuilder.build(); return tagBuilder.build();
} }
@ -123,13 +123,12 @@ public abstract class BlockEntityTranslator {
return tag; 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() return NbtMap.builder()
.putInt("x", x) .putInt("x", x)
.putInt("y", y) .putInt("y", y)
.putInt("z", z) .putInt("z", z)
.putString("id", bedrockId) .putString("id", bedrockId);
.build();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

Datei anzeigen

@ -32,7 +32,7 @@ import com.nukkitx.nbt.NbtMapBuilder;
import org.geysermc.connector.network.translators.item.ItemEntry; import org.geysermc.connector.network.translators.item.ItemEntry;
import org.geysermc.connector.network.translators.item.ItemRegistry; import org.geysermc.connector.network.translators.item.ItemRegistry;
@BlockEntity(name = "Campfire", regex = "campfire") @BlockEntity(name = "Campfire")
public class CampfireBlockEntityTranslator extends BlockEntityTranslator { public class CampfireBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {

Datei anzeigen

@ -30,7 +30,7 @@ import com.nukkitx.nbt.NbtMapBuilder;
import org.geysermc.connector.network.translators.world.block.BlockStateValues; import org.geysermc.connector.network.translators.world.block.BlockStateValues;
import org.geysermc.connector.network.translators.chat.MessageTranslator; import org.geysermc.connector.network.translators.chat.MessageTranslator;
@BlockEntity(name = "CommandBlock", regex = "command_block") @BlockEntity(name = "CommandBlock")
public class CommandBlockBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState { public class CommandBlockBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override @Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {

Datei anzeigen

@ -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 * 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 { public class DoubleChestBlockEntityTranslator extends BlockEntityTranslator implements BedrockOnlyBlockEntity, RequiresBlockState {
@Override @Override
public boolean isBlock(int blockState) { public boolean isBlock(int blockState) {
@ -46,7 +46,7 @@ public class DoubleChestBlockEntityTranslator extends BlockEntityTranslator impl
@Override @Override
public void updateBlock(GeyserSession session, int blockState, Vector3i position) { public void updateBlock(GeyserSession session, int blockState, Vector3i position) {
CompoundTag javaTag = getConstantJavaTag("chest", position.getX(), position.getY(), position.getZ()); 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); translateTag(tagBuilder, javaTag, blockState);
BlockEntityUtils.updateBlockEntity(session, tagBuilder.build(), position); BlockEntityUtils.updateBlockEntity(session, tagBuilder.build(), position);
} }

Datei anzeigen

@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.world.block.entity;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtMapBuilder;
@BlockEntity(name = "Empty", regex = "") @BlockEntity(name = "Empty")
public class EmptyBlockEntityTranslator extends BlockEntityTranslator { public class EmptyBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {

Datei anzeigen

@ -35,7 +35,7 @@ import it.unimi.dsi.fastutil.ints.IntList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@BlockEntity(name = "EndGateway", regex = "end_gateway") @BlockEntity(name = "EndGateway")
public class EndGatewayBlockEntityTranslator extends BlockEntityTranslator { public class EndGatewayBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {

Datei anzeigen

@ -29,7 +29,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtMapBuilder;
@BlockEntity(name = "JigsawBlock", regex = "jigsaw") @BlockEntity(name = "JigsawBlock")
public class JigsawBlockBlockEntityTranslator extends BlockEntityTranslator { public class JigsawBlockBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {

Datei anzeigen

@ -29,7 +29,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtMapBuilder;
import org.geysermc.connector.network.translators.world.block.BlockStateValues; import org.geysermc.connector.network.translators.world.block.BlockStateValues;
@BlockEntity(name = "ShulkerBox", regex = "shulker_box") @BlockEntity(name = "ShulkerBox")
public class ShulkerBoxBlockEntityTranslator extends BlockEntityTranslator { public class ShulkerBoxBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {

Datei anzeigen

@ -30,7 +30,7 @@ import com.nukkitx.nbt.NbtMapBuilder;
import org.geysermc.connector.network.translators.chat.MessageTranslator; import org.geysermc.connector.network.translators.chat.MessageTranslator;
import org.geysermc.connector.utils.SignUtils; import org.geysermc.connector.utils.SignUtils;
@BlockEntity(name = "Sign", regex = "sign") @BlockEntity(name = "Sign")
public class SignBlockEntityTranslator extends BlockEntityTranslator { public class SignBlockEntityTranslator extends BlockEntityTranslator {
/** /**
* Maps a color stored in a sign's Color tag to a Bedrock Edition formatting code. * Maps a color stored in a sign's Color tag to a Bedrock Edition formatting code.

Datei anzeigen

@ -46,7 +46,7 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@BlockEntity(name = "Skull", regex = "skull") @BlockEntity(name = "Skull")
public class SkullBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState { public class SkullBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
public static boolean ALLOW_CUSTOM_SKULLS; public static boolean ALLOW_CUSTOM_SKULLS;

Datei anzeigen

@ -30,7 +30,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtMapBuilder;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
@BlockEntity(name = "MobSpawner", regex = "mob_spawner") @BlockEntity(name = "MobSpawner")
public class SpawnerBlockEntityTranslator extends BlockEntityTranslator { public class SpawnerBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {