Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PacketSyncTeleporterPosToClient {
- private final int posX, posY, posZ;
- private final int d1posX, d1posY, d1posZ;
- private final int d2posX, d2posY, d2posZ;
- private final int d3posX, d3posY, d3posZ;
- private final int d4posX, d4posY, d4posZ;
- private final int d5posX, d5posY, d5posZ;
- private final int d6posX, d6posY, d6posZ;
- private final int d7posX, d7posY, d7posZ;
- private String dimName;
- private final BlockPos blockPos;
- private final int selected;
- private final String dest0name,dest1name,dest2name,dest3name,dest4name,dest5name,dest6name,dest7name;
- private final boolean dest0exists,dest1exists,dest2exists,dest3exists,dest4exists,dest5exists,dest6exists,dest7exists;
- private final String dest0dim,dest1dim,dest2dim,dest3dim,dest4dim,dest5dim,dest6dim,dest7dim;
- public PacketSyncTeleporterPosToClient(String dest0dim,
- String dest1dim,
- String dest2dim,
- String dest3dim,
- String dest4dim,
- String dest5dim,
- String dest6dim,
- String dest7dim,
- boolean dest0exists,
- boolean dest1exists,
- boolean dest2exists,
- boolean dest3exists,
- boolean dest4exists,
- boolean dest5exists,
- boolean dest6exists,
- boolean dest7exists,
- String dest0name,
- String dest1name,
- String dest2name,
- String dest3name,
- String dest4name,
- String dest5name,
- String dest6name,
- String dest7name,
- int selected, int posX,int posY,int posZ,
- int d1posX,int d1posY,int d1posZ,
- int d2posX,int d2posY,int d2posZ,
- int d3posX,int d3posY,int d3posZ,
- int d4posX,int d4posY,int d4posZ,
- int d5posX,int d5posY,int d5posZ,
- int d6posX,int d6posY,int d6posZ,
- int d7posX,int d7posY,int d7posZ, String dimName, BlockPos pos) {
- this.posX = posX;this.posY = posY;this.posZ = posZ;
- this.d1posX = d1posX;this.d1posY = d1posY;this.d1posZ = d1posZ;
- this.d2posX = d2posX;this.d2posY = d2posY;this.d2posZ = d2posZ;
- this.d3posX = d3posX;this.d3posY = d3posY;this.d3posZ = d3posZ;
- this.d4posX = d4posX;this.d4posY = d4posY;this.d4posZ = d4posZ;
- this.d5posX = d5posX;this.d5posY = d5posY;this.d5posZ = d5posZ;
- this.d6posX = d6posX;this.d6posY = d6posY;this.d6posZ = d6posZ;
- this.d7posX = d7posX;this.d7posY = d7posY;this.d7posZ = d7posZ;
- this.dimName = dimName;
- this.blockPos = pos;
- this.selected = selected;
- this.dest0name = dest0name;
- this.dest1name = dest1name;
- this.dest2name = dest2name;
- this.dest3name = dest3name;
- this.dest4name = dest4name;
- this.dest5name = dest5name;
- this.dest6name = dest6name;
- this.dest7name = dest7name;
- this.dest0exists = dest0exists;
- this.dest1exists = dest1exists;
- this.dest2exists = dest2exists;
- this.dest3exists = dest3exists;
- this.dest4exists = dest4exists;
- this.dest5exists = dest5exists;
- this.dest6exists = dest6exists;
- this.dest7exists = dest7exists;
- this.dest0dim = dest0dim;
- this.dest1dim = dest1dim;
- this.dest2dim = dest2dim;
- this.dest3dim = dest3dim;
- this.dest4dim = dest4dim;
- this.dest5dim = dest5dim;
- this.dest6dim = dest6dim;
- this.dest7dim = dest7dim;
- }
- public PacketSyncTeleporterPosToClient(FriendlyByteBuf buf) {
- this.posX = buf.readInt();this.posY = buf.readInt();this.posZ = buf.readInt();
- this.d1posX = buf.readInt();this.d1posY = buf.readInt();this.d1posZ = buf.readInt();
- this.d2posX = buf.readInt();this.d2posY = buf.readInt();this.d2posZ = buf.readInt();
- this.d3posX = buf.readInt();this.d3posY = buf.readInt();this.d3posZ = buf.readInt();
- this.d4posX = buf.readInt();this.d4posY = buf.readInt();this.d4posZ = buf.readInt();
- this.d5posX = buf.readInt();this.d5posY = buf.readInt();this.d5posZ = buf.readInt();
- this.d6posX = buf.readInt();this.d6posY = buf.readInt();this.d6posZ = buf.readInt();
- this.d7posX = buf.readInt();this.d7posY = buf.readInt();this.d7posZ = buf.readInt();
- this.blockPos = buf.readBlockPos();
- this.selected = buf.readInt();
- this.dest0name = buf.readUtf();
- this.dest1name = buf.readUtf();
- this.dest2name = buf.readUtf();
- this.dest3name = buf.readUtf();
- this.dest4name = buf.readUtf();
- this.dest5name = buf.readUtf();
- this.dest6name = buf.readUtf();
- this.dest7name = buf.readUtf();
- this.dest0exists = buf.readBoolean();
- this.dest1exists = buf.readBoolean();
- this.dest2exists = buf.readBoolean();
- this.dest3exists = buf.readBoolean();
- this.dest4exists = buf.readBoolean();
- this.dest5exists = buf.readBoolean();
- this.dest6exists = buf.readBoolean();
- this.dest7exists = buf.readBoolean();
- this.dest0dim = buf.readUtf();
- this.dest1dim = buf.readUtf();
- this.dest2dim = buf.readUtf();
- this.dest3dim = buf.readUtf();
- this.dest4dim = buf.readUtf();
- this.dest5dim = buf.readUtf();
- this.dest6dim = buf.readUtf();
- this.dest7dim = buf.readUtf();
- }
- public void toBytes(FriendlyByteBuf buf) {
- buf.writeInt(posX);buf.writeInt(posY);buf.writeInt(posZ);
- buf.writeInt(d1posX);buf.writeInt(d1posY);buf.writeInt(d1posZ);
- buf.writeInt(d2posX);buf.writeInt(d2posY);buf.writeInt(d2posZ);
- buf.writeInt(d3posX);buf.writeInt(d3posY);buf.writeInt(d3posZ);
- buf.writeInt(d4posX);buf.writeInt(d4posY);buf.writeInt(d4posZ);
- buf.writeInt(d5posX);buf.writeInt(d5posY);buf.writeInt(d5posZ);
- buf.writeInt(d6posX);buf.writeInt(d6posY);buf.writeInt(d6posZ);
- buf.writeInt(d7posX);buf.writeInt(d7posY);buf.writeInt(d7posZ);
- buf.writeBlockPos(blockPos);
- buf.writeInt(selected);
- buf.writeUtf(dest0name);
- buf.writeUtf(dest1name);
- buf.writeUtf(dest2name);
- buf.writeUtf(dest3name);
- buf.writeUtf(dest4name);
- buf.writeUtf(dest5name);
- buf.writeUtf(dest6name);
- buf.writeUtf(dest7name);
- buf.writeBoolean(dest0exists);
- buf.writeBoolean(dest1exists);
- buf.writeBoolean(dest2exists);
- buf.writeBoolean(dest3exists);
- buf.writeBoolean(dest4exists);
- buf.writeBoolean(dest5exists);
- buf.writeBoolean(dest6exists);
- buf.writeBoolean(dest7exists);
- buf.writeUtf(dest0dim);
- buf.writeUtf(dest1dim);
- buf.writeUtf(dest2dim);
- buf.writeUtf(dest3dim);
- buf.writeUtf(dest4dim);
- buf.writeUtf(dest5dim);
- buf.writeUtf(dest6dim);
- buf.writeUtf(dest7dim);
- }
- public boolean handle(Supplier<NetworkEvent.Context> ctx) {
- NetworkEvent.Context context = ctx.get();
- context.enqueueWork(() -> {
- // This is the client
- if(Minecraft.getInstance().level.getBlockEntity(blockPos) instanceof WarpPipeBlockEntity blockEntity) {
- blockEntity.setPosX(posX, 0);
- blockEntity.setPosX(d1posX, 1);
- blockEntity.setPosX(d2posX, 2);
- blockEntity.setPosX(d3posX, 3);
- blockEntity.setPosX(d4posX, 4);
- blockEntity.setPosX(d5posX, 5);
- blockEntity.setPosX(d6posX, 6);
- blockEntity.setPosX(d7posX, 7);
- blockEntity.setPosY(posY, 0);
- blockEntity.setPosY(d1posY, 1);
- blockEntity.setPosY(d2posY, 2);
- blockEntity.setPosY(d3posY, 3);
- blockEntity.setPosY(d4posY, 4);
- blockEntity.setPosY(d5posY, 5);
- blockEntity.setPosY(d6posY, 6);
- blockEntity.setPosY(d7posY, 7);
- blockEntity.setPosZ(posZ, 0);
- blockEntity.setPosZ(d1posZ, 1);
- blockEntity.setPosZ(d2posZ, 2);
- blockEntity.setPosZ(d3posZ, 3);
- blockEntity.setPosZ(d4posZ, 4);
- blockEntity.setPosZ(d5posZ, 5);
- blockEntity.setPosZ(d6posZ, 6);
- blockEntity.setPosZ(d7posZ, 7);
- blockEntity.setDimensionName(dimName);
- blockEntity.setSelectedWheelPart(this.selected);
- blockEntity.setDestName(0,dest0name);
- blockEntity.setDestName(1,dest1name);
- blockEntity.setDestName(2,dest2name);
- blockEntity.setDestName(3,dest3name);
- blockEntity.setDestName(4,dest4name);
- blockEntity.setDestName(5,dest5name);
- blockEntity.setDestName(6,dest6name);
- blockEntity.setDestName(7,dest7name);
- blockEntity.setDestDimension(0, dest0dim);
- blockEntity.setDestDimension(1, dest1dim);
- blockEntity.setDestDimension(2, dest2dim);
- blockEntity.setDestDimension(3, dest3dim);
- blockEntity.setDestDimension(4, dest4dim);
- blockEntity.setDestDimension(5, dest5dim);
- blockEntity.setDestDimension(6, dest6dim);
- blockEntity.setDestDimension(7, dest7dim);
- blockEntity.setDestExists(0,dest0exists);
- blockEntity.setDestExists(1,dest1exists);
- blockEntity.setDestExists(2,dest2exists);
- blockEntity.setDestExists(3,dest3exists);
- blockEntity.setDestExists(4,dest4exists);
- blockEntity.setDestExists(5,dest5exists);
- blockEntity.setDestExists(6,dest6exists);
- blockEntity.setDestExists(7,dest7exists);
- blockEntity.setChanged();
- if(Minecraft.getInstance().player.containerMenu instanceof TeleporterMenu menu &&
- menu.blockEntity.getBlockPos().equals(blockPos)) {
- blockEntity.setPosX(posX, 0);
- blockEntity.setPosX(d1posX, 1);
- blockEntity.setPosX(d2posX, 2);
- blockEntity.setPosX(d3posX, 3);
- blockEntity.setPosX(d4posX, 4);
- blockEntity.setPosX(d5posX, 5);
- blockEntity.setPosX(d6posX, 6);
- blockEntity.setPosX(d7posX, 7);
- blockEntity.setPosY(posY, 0);
- blockEntity.setPosY(d1posY, 1);
- blockEntity.setPosY(d2posY, 2);
- blockEntity.setPosY(d3posY, 3);
- blockEntity.setPosY(d4posY, 4);
- blockEntity.setPosY(d5posY, 5);
- blockEntity.setPosY(d6posY, 6);
- blockEntity.setPosY(d7posY, 7);
- blockEntity.setPosZ(posZ, 0);
- blockEntity.setPosZ(d1posZ, 1);
- blockEntity.setPosZ(d2posZ, 2);
- blockEntity.setPosZ(d3posZ, 3);
- blockEntity.setPosZ(d4posZ, 4);
- blockEntity.setPosZ(d5posZ, 5);
- blockEntity.setPosZ(d6posZ, 6);
- blockEntity.setPosZ(d7posZ, 7);
- blockEntity.setDimensionName(dimName);
- blockEntity.setSelectedWheelPart(this.selected);
- blockEntity.setDestName(0,dest0name);
- blockEntity.setDestName(1,dest1name);
- blockEntity.setDestName(2,dest2name);
- blockEntity.setDestName(3,dest3name);
- blockEntity.setDestName(4,dest4name);
- blockEntity.setDestName(5,dest5name);
- blockEntity.setDestName(6,dest6name);
- blockEntity.setDestName(7,dest7name);
- blockEntity.setDestDimension(0, dest0dim);
- blockEntity.setDestDimension(1, dest1dim);
- blockEntity.setDestDimension(2, dest2dim);
- blockEntity.setDestDimension(3, dest3dim);
- blockEntity.setDestDimension(4, dest4dim);
- blockEntity.setDestDimension(5, dest5dim);
- blockEntity.setDestDimension(6, dest6dim);
- blockEntity.setDestDimension(7, dest7dim);
- blockEntity.setDestExists(0,dest0exists);
- blockEntity.setDestExists(1,dest1exists);
- blockEntity.setDestExists(2,dest2exists);
- blockEntity.setDestExists(3,dest3exists);
- blockEntity.setDestExists(4,dest4exists);
- blockEntity.setDestExists(5,dest5exists);
- blockEntity.setDestExists(6,dest6exists);
- blockEntity.setDestExists(7,dest7exists);
- blockEntity.setChanged();
- }
- }
- });
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement