Update packets to new format, 930 errors

This commit is contained in:
modmuss50 2019-02-21 18:29:04 +00:00
parent f6a79ce579
commit 0c99a94250
12 changed files with 134 additions and 336 deletions

View file

@ -106,6 +106,9 @@ public class TechReborn {
TRTileEntities.init(); TRTileEntities.init();
ModFluids.init(); ModFluids.init();
ClientboundPackets.init();
ServerboundPackets.init();
// Entitys // Entitys
//EntityRegistry.registerModEntity(new ResourceLocation("techreborn", "nuke"), EntityNukePrimed.class, "nuke", 0, INSTANCE, 160, 5, true); //EntityRegistry.registerModEntity(new ResourceLocation("techreborn", "nuke"), EntityNukePrimed.class, "nuke", 0, INSTANCE, 160, 5, true);

View file

@ -31,7 +31,7 @@ import reborncore.client.gui.builder.GuiBase;
import reborncore.common.network.NetworkManager; import reborncore.common.network.NetworkManager;
import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.PowerSystem;
import reborncore.client.gui.builder.widget.GuiButtonUpDown; import reborncore.client.gui.builder.widget.GuiButtonUpDown;
import techreborn.packets.PacketAesu; import techreborn.packets.ServerboundPackets;
import techreborn.tiles.storage.TileAdjustableSU; import techreborn.tiles.storage.TileAdjustableSU;
import java.io.IOException; import java.io.IOException;
@ -83,7 +83,7 @@ public class GuiAESU extends GuiBase {
public void actionPerformed(final GuiButton button) throws IOException { public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button); super.actionPerformed(button);
if (button.id >= 300 && button.id <= 303) { if (button.id >= 300 && button.id <= 303) {
NetworkManager.sendToServer(new PacketAesu(button.id, tile)); NetworkManager.sendToServer(ServerboundPackets.createPacketAesu(button.id, tile));
} }
} }
} }

View file

@ -35,7 +35,7 @@ import net.minecraft.util.ResourceLocation;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.guibuilder.GuiBuilder; import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.network.NetworkManager; import reborncore.common.network.NetworkManager;
import techreborn.packets.PacketAutoCraftingTableLock; import techreborn.packets.ServerboundPackets;
import techreborn.tiles.machine.tier1.TileAutoCraftingTable; import techreborn.tiles.machine.tier1.TileAutoCraftingTable;
import java.io.IOException; import java.io.IOException;
@ -111,7 +111,7 @@ public class GuiAutoCrafting extends GuiBase {
@Override @Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
if (isPointInRect(145, 4, 20, 12, mouseX, mouseY)) { if (isPointInRect(145, 4, 20, 12, mouseX, mouseY)) {
NetworkManager.sendToServer(new PacketAutoCraftingTableLock(tileAutoCraftingTable, !tileAutoCraftingTable.locked)); NetworkManager.sendToServer(ServerboundPackets.createPacketAutoCraftingTableLock(tileAutoCraftingTable, !tileAutoCraftingTable.locked));
return; return;
} }
super.mouseClicked(mouseX, mouseY, mouseButton); super.mouseClicked(mouseX, mouseY, mouseButton);

View file

@ -40,7 +40,7 @@ import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.Torus; import reborncore.common.util.Torus;
import reborncore.client.gui.builder.widget.GuiButtonUpDown; import reborncore.client.gui.builder.widget.GuiButtonUpDown;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import techreborn.packets.PacketFusionControlSize; import techreborn.packets.ServerboundPackets;
import techreborn.tiles.fusionReactor.TileFusionControlComputer; import techreborn.tiles.fusionReactor.TileFusionControlComputer;
import java.awt.*; import java.awt.*;
@ -134,7 +134,7 @@ public class GuiFusionReactor extends GuiBase {
} }
private void sendSizeChange(int sizeDelta){ private void sendSizeChange(int sizeDelta){
NetworkManager.sendToServer(new PacketFusionControlSize(sizeDelta, tile.getPos())); NetworkManager.sendToServer(ServerboundPackets.createPacketFusionControlSize(sizeDelta, tile.getPos()));
//Reset the multiblock as it will be wrong now. //Reset the multiblock as it will be wrong now.
if(ClientProxy.multiblockRenderEvent.currentMultiblock != null){ if(ClientProxy.multiblockRenderEvent.currentMultiblock != null){
updateMultiBlockRender(); updateMultiBlockRender();

View file

@ -28,7 +28,7 @@ import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.guibuilder.GuiBuilder; import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.network.NetworkManager; import reborncore.common.network.NetworkManager;
import techreborn.packets.PacketRollingMachineLock; import techreborn.packets.ServerboundPackets;
import techreborn.tiles.machine.tier1.TileRollingMachine; import techreborn.tiles.machine.tier1.TileRollingMachine;
import java.io.IOException; import java.io.IOException;
@ -77,7 +77,7 @@ public class GuiRollingMachine extends GuiBase {
@Override @Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
if(isPointInRect(130, 4, 20, 12, mouseX, mouseY)){ if(isPointInRect(130, 4, 20, 12, mouseX, mouseY)){
NetworkManager.sendToServer(new PacketRollingMachineLock(rollingMachine, !rollingMachine.locked)); NetworkManager.sendToServer(ServerboundPackets.createPacketRollingMachineLock(rollingMachine, !rollingMachine.locked));
return; return;
} }
super.mouseClicked(mouseX, mouseY, mouseButton); super.mouseClicked(mouseX, mouseY, mouseButton);

View file

@ -0,0 +1,9 @@
package techreborn.packets;
public class ClientboundPackets {
public static void init() {
}
}

View file

@ -1,66 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.packets;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.network.NetworkEvent;
import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.INetworkPacket;
import techreborn.tiles.storage.TileAdjustableSU;
public class PacketAesu implements INetworkPacket {
int buttonID;
BlockPos pos;
public PacketAesu() {
}
public PacketAesu(int buttonID, TileAdjustableSU tile) {
this.pos = tile.getPos();
this.buttonID = buttonID;
}
@Override
public void writeData(ExtendedPacketBuffer out) {
out.writeBlockPos(pos);
out.writeInt(buttonID);
}
@Override
public void readData(ExtendedPacketBuffer in) {
this.pos = in.readBlockPos();
this.buttonID = in.readInt();
}
@Override
public void processData(NetworkEvent.Context context) {
TileEntity tile = context.getSender().world.getTileEntity(pos);
if (tile instanceof TileAdjustableSU){
((TileAdjustableSU) tile).handleGuiInputFromClient(buttonID);
}
}
}

View file

@ -1,66 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.packets;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.network.NetworkEvent;
import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.INetworkPacket;
import techreborn.tiles.machine.tier1.TileAutoCraftingTable;
public class PacketAutoCraftingTableLock implements INetworkPacket {
BlockPos machinePos;
boolean locked;
public PacketAutoCraftingTableLock(TileAutoCraftingTable machine, boolean locked) {
this.machinePos = machine.getPos();
this.locked = locked;
}
public PacketAutoCraftingTableLock() {
}
@Override
public void writeData(ExtendedPacketBuffer buffer) {
buffer.writeBlockPos(machinePos);
buffer.writeBoolean(locked);
}
@Override
public void readData(ExtendedPacketBuffer buffer) {
machinePos = buffer.readBlockPos();
locked = buffer.readBoolean();
}
@Override
public void processData(NetworkEvent.Context context) {
TileEntity tileEntity = context.getSender().world.getTileEntity(machinePos);
if(tileEntity instanceof TileAutoCraftingTable){
((TileAutoCraftingTable) tileEntity).locked = locked;
}
}
}

View file

@ -1,66 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.packets;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.network.NetworkEvent;
import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.INetworkPacket;
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
public class PacketFusionControlSize implements INetworkPacket {
int sizeDelta;
BlockPos pos;
public PacketFusionControlSize(int sizeDelta, BlockPos pos) {
this.sizeDelta = sizeDelta;
this.pos = pos;
}
public PacketFusionControlSize() {
}
@Override
public void writeData(ExtendedPacketBuffer buffer) {
buffer.writeInt(sizeDelta);
buffer.writeBlockPos(pos);
}
@Override
public void readData(ExtendedPacketBuffer buffer) {
sizeDelta = buffer.readInt();
pos = buffer.readBlockPos();
}
@Override
public void processData(NetworkEvent.Context context) {
TileEntity tile = context.getSender().world.getTileEntity(pos);
if(tile instanceof TileFusionControlComputer){
((TileFusionControlComputer) tile).changeSize(sizeDelta);
}
}
}

View file

@ -1,64 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.packets;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.network.NetworkEvent;
import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.INetworkPacket;
import techreborn.tiles.storage.idsu.TileInterdimensionalSU;
public class PacketIdsu implements INetworkPacket {
int buttonID;
BlockPos pos;
public PacketIdsu() {
}
public PacketIdsu(int buttonID, TileInterdimensionalSU tile) {
this.pos = tile.getPos();
this.buttonID = buttonID;
}
@Override
public void writeData(ExtendedPacketBuffer out) {
out.writeBlockPos(pos);
out.writeInt(buttonID);
}
@Override
public void readData(ExtendedPacketBuffer in) {
this.pos = in.readBlockPos();
buttonID = in.readInt();
}
@Override
public void processData(NetworkEvent.Context context) {
// if (!pos.getWorld().isRemote) {
// pos.handleGuiInputFromClient(buttonID);
// }
}
}

View file

@ -1,66 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2018 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.packets;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.network.NetworkEvent;
import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.INetworkPacket;
import techreborn.tiles.machine.tier1.TileRollingMachine;
public class PacketRollingMachineLock implements INetworkPacket {
BlockPos machinePos;
boolean locked;
public PacketRollingMachineLock(TileRollingMachine machine, boolean locked) {
this.machinePos = machine.getPos();
this.locked = locked;
}
public PacketRollingMachineLock() {
}
@Override
public void writeData(ExtendedPacketBuffer buffer) {
buffer.writeBlockPos(machinePos);
buffer.writeBoolean(locked);
}
@Override
public void readData(ExtendedPacketBuffer buffer) {
machinePos = buffer.readBlockPos();
locked = buffer.readBoolean();
}
@Override
public void processData(NetworkEvent.Context context) {
TileEntity tileEntity = context.getSender().world.getTileEntity(machinePos);
if(tileEntity instanceof TileRollingMachine){
((TileRollingMachine) tileEntity).locked = locked;
}
}
}

View file

@ -0,0 +1,114 @@
package techreborn.packets;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import reborncore.common.network.NetworkManager;
import reborncore.common.network.NetworkPacket;
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
import techreborn.tiles.machine.tier1.TileAutoCraftingTable;
import techreborn.tiles.machine.tier1.TileRollingMachine;
import techreborn.tiles.storage.TileAdjustableSU;
import techreborn.tiles.storage.idsu.TileInterdimensionalSU;
public class ServerboundPackets {
public static final ResourceLocation AESU = new ResourceLocation("techreborn", "aesu");
public static final ResourceLocation AUTO_CRAFTING_LOCK = new ResourceLocation("techreborn", "auto_crafting_lock");
public static final ResourceLocation ROLLING_MACHINE_LOCK = new ResourceLocation("techreborn", "rolling_machine_lock");
public static final ResourceLocation FUSION_CONTROL_SIZE = new ResourceLocation("techreborn", "fusion_control_size");
public static final ResourceLocation IDSU = new ResourceLocation("techreborn", "idsu");
public static void init() {
NetworkManager.registerPacketHandler(AESU, (extendedPacketBuffer, context) -> {
BlockPos pos = extendedPacketBuffer.readBlockPos();
int buttonID = extendedPacketBuffer.readInt();
context.enqueueWork(() -> {
TileEntity tile = context.getSender().world.getTileEntity(pos);
if (tile instanceof TileAdjustableSU) {
((TileAdjustableSU) tile).handleGuiInputFromClient(buttonID);
}
});
});
NetworkManager.registerPacketHandler(AUTO_CRAFTING_LOCK, (extendedPacketBuffer, context) -> {
BlockPos machinePos = extendedPacketBuffer.readBlockPos();
boolean locked = extendedPacketBuffer.readBoolean();
context.enqueueWork(() -> {
TileEntity tileEntity = context.getSender().world.getTileEntity(machinePos);
if (tileEntity instanceof TileAutoCraftingTable) {
((TileAutoCraftingTable) tileEntity).locked = locked;
}
});
});
NetworkManager.registerPacketHandler(FUSION_CONTROL_SIZE, (extendedPacketBuffer, context) -> {
int sizeDelta = extendedPacketBuffer.readInt();
BlockPos pos = extendedPacketBuffer.readBlockPos();
context.enqueueWork(() -> {
TileEntity tile = context.getSender().world.getTileEntity(pos);
if (tile instanceof TileFusionControlComputer) {
((TileFusionControlComputer) tile).changeSize(sizeDelta);
}
});
});
NetworkManager.registerPacketHandler(IDSU, (extendedPacketBuffer, context) -> {
BlockPos pos = extendedPacketBuffer.readBlockPos();
int buttonID = extendedPacketBuffer.readInt();
context.enqueueWork(() -> {
//TODO was commented out when I ported it, so ill leave it here, needs looking into tho
// if (!pos.getWorld().isRemote) {
// pos.handleGuiInputFromClient(buttonID);
// }
});
});
NetworkManager.registerPacketHandler(ROLLING_MACHINE_LOCK, (extendedPacketBuffer, context) -> {
BlockPos machinePos = extendedPacketBuffer.readBlockPos();
boolean locked = extendedPacketBuffer.readBoolean();
context.enqueueWork(() -> {
TileEntity tileEntity = context.getSender().world.getTileEntity(machinePos);
if (tileEntity instanceof TileRollingMachine) {
((TileRollingMachine) tileEntity).locked = locked;
}
});
});
}
public static NetworkPacket createPacketAesu(int buttonID, TileAdjustableSU tile) {
return NetworkManager.createPacket(AESU, extendedPacketBuffer -> {
extendedPacketBuffer.writeBlockPos(tile.getPos());
extendedPacketBuffer.writeInt(buttonID);
});
}
public static NetworkPacket createPacketAutoCraftingTableLock(TileAutoCraftingTable machine, boolean locked) {
return NetworkManager.createPacket(AUTO_CRAFTING_LOCK, extendedPacketBuffer -> {
extendedPacketBuffer.writeBlockPos(machine.getPos());
extendedPacketBuffer.writeBoolean(locked);
});
}
public static NetworkPacket createPacketFusionControlSize(int sizeDelta, BlockPos pos) {
return NetworkManager.createPacket(FUSION_CONTROL_SIZE, extendedPacketBuffer -> {
extendedPacketBuffer.writeInt(sizeDelta);
extendedPacketBuffer.writeBlockPos(pos);
});
}
public static NetworkPacket createPacketIdsu(int buttonID, TileInterdimensionalSU tile) {
return NetworkManager.createPacket(IDSU, extendedPacketBuffer -> {
extendedPacketBuffer.writeBlockPos(tile.getPos());
extendedPacketBuffer.writeInt(buttonID);
});
}
public static NetworkPacket createPacketRollingMachineLock(TileRollingMachine machine, boolean locked) {
return NetworkManager.createPacket(ROLLING_MACHINE_LOCK, extendedPacketBuffer -> {
extendedPacketBuffer.writeBlockPos(machine.getPos());
extendedPacketBuffer.writeBoolean(locked);
});
}
}