diff options
33 files changed, 167 insertions, 472 deletions
diff --git a/src/main/java/bartworks/MainMod.java b/src/main/java/bartworks/MainMod.java index 66eec8469b..a321718b17 100644 --- a/src/main/java/bartworks/MainMod.java +++ b/src/main/java/bartworks/MainMod.java @@ -45,7 +45,6 @@ import bartworks.common.loaders.RecipeLoader; import bartworks.common.loaders.RegisterGlassTiers; import bartworks.common.loaders.RegisterServerCommands; import bartworks.common.loaders.StaticRecipeChangeLoaders; -import bartworks.common.net.BWNetwork; import bartworks.server.EventHandler.ServerEventHandler; import bartworks.system.material.CircuitGeneration.CircuitImprintLoader; import bartworks.system.material.CircuitGeneration.CircuitPartLoader; @@ -106,8 +105,6 @@ public final class MainMod { @Mod.Instance(MainMod.MOD_ID) public static MainMod instance; - public static BWNetwork BW_Network_instance = new BWNetwork(); - public MainMod() { } diff --git a/src/main/java/bartworks/common/net/BWNetwork.java b/src/main/java/bartworks/common/net/BWNetwork.java deleted file mode 100644 index 78ab09e367..0000000000 --- a/src/main/java/bartworks/common/net/BWNetwork.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek 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 bartworks.common.net; - -import java.util.EnumMap; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteStreams; - -import cpw.mods.fml.common.network.FMLEmbeddedChannel; -import cpw.mods.fml.common.network.FMLOutboundHandler; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.internal.FMLProxyPacket; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.server.FMLServerHandler; -import gregtech.api.enums.GTValues; -import gregtech.api.net.GTPacket; -import gregtech.api.net.GTPacketNew; -import gregtech.api.net.IGT_NetworkHandler; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.MessageToMessageCodec; - -/* - * Original GT File slightly Modified - */ -@SuppressWarnings("deprecation") -@ChannelHandler.Sharable -public class BWNetwork extends MessageToMessageCodec<FMLProxyPacket, GTPacketNew> implements IGT_NetworkHandler { - - private final EnumMap<Side, FMLEmbeddedChannel> mChannel; - private final GTPacketNew[] mSubChannels; - - public BWNetwork() { - this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", this, new BWNetwork.HandlerShared()); - this.mSubChannels = new GTPacketNew[] { new RendererPacket(), new CircuitProgrammerPacket(), - new MetaBlockPacket(), new OreDictCachePacket(), new ServerJoinedPacket(), new EICPacket() }; - } - - @Override - protected void encode(ChannelHandlerContext aContext, GTPacketNew aPacket, List<Object> aOutput) throws Exception { - aOutput.add( - new FMLProxyPacket( - Unpooled.buffer() - .writeByte(aPacket.getPacketID()) - .writeBytes(aPacket.encode()) - .copy(), - aContext.channel() - .attr(NetworkRegistry.FML_CHANNEL) - .get())); - } - - @Override - protected void decode(ChannelHandlerContext aContext, FMLProxyPacket aPacket, List<Object> aOutput) - throws Exception { - ByteArrayDataInput aData = ByteStreams.newDataInput( - aPacket.payload() - .array()); - aOutput.add(this.mSubChannels[aData.readByte()].decode(aData)); - } - - @Override - public void sendToPlayer(@Nonnull GTPacket aPacket, @Nonnull EntityPlayerMP aPlayer) { - this.mChannel.get(Side.SERVER) - .attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.PLAYER); - this.mChannel.get(Side.SERVER) - .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) - .set(aPlayer); - this.mChannel.get(Side.SERVER) - .writeAndFlush(aPacket); - } - - public void sendToAllPlayersinWorld(@Nonnull GTPacket aPacket, World world) { - for (String name : FMLServerHandler.instance() - .getServer() - .getAllUsernames()) { - this.mChannel.get(Side.SERVER) - .attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.PLAYER); - this.mChannel.get(Side.SERVER) - .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) - .set(world.getPlayerEntityByName(name)); - this.mChannel.get(Side.SERVER) - .writeAndFlush(aPacket); - } - } - - @Override - public void sendToAllAround(@Nonnull GTPacket aPacket, NetworkRegistry.TargetPoint aPosition) { - this.mChannel.get(Side.SERVER) - .attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); - this.mChannel.get(Side.SERVER) - .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) - .set(aPosition); - this.mChannel.get(Side.SERVER) - .writeAndFlush(aPacket); - } - - @Override - public void sendToAll(@Nonnull GTPacket aPacket) { - this.mChannel.get(Side.SERVER) - .attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.ALL); - this.mChannel.get(Side.SERVER) - .writeAndFlush(aPacket); - } - - @Override - public void sendToServer(@Nonnull GTPacket aPacket) { - this.mChannel.get(Side.CLIENT) - .attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.TOSERVER); - this.mChannel.get(Side.CLIENT) - .writeAndFlush(aPacket); - } - - @Override - public void sendPacketToAllPlayersInRange(World aWorld, @Nonnull GTPacket aPacket, int aX, int aZ) { - if (!aWorld.isRemote) { - - for (Object tObject : aWorld.playerEntities) { - if (!(tObject instanceof EntityPlayerMP tPlayer)) { - break; - } - - Chunk tChunk = aWorld.getChunkFromBlockCoords(aX, aZ); - if (tPlayer.getServerForPlayer() - .getPlayerManager() - .isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) { - this.sendToPlayer(aPacket, tPlayer); - } - } - } - } - - @Sharable - static final class HandlerShared extends SimpleChannelInboundHandler<GTPacketNew> { - - HandlerShared() {} - - @Override - protected void channelRead0(ChannelHandlerContext ctx, GTPacketNew aPacket) throws Exception { - EntityPlayer aPlayer = GTValues.GT.getThePlayer(); - aPacket.process(aPlayer == null ? null : GTValues.GT.getThePlayer().worldObj); - } - } -} diff --git a/src/main/java/bartworks/common/net/CircuitProgrammerPacket.java b/src/main/java/bartworks/common/net/CircuitProgrammerPacket.java deleted file mode 100644 index 998d10cbfa..0000000000 --- a/src/main/java/bartworks/common/net/CircuitProgrammerPacket.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2018-2020 bartimaeusnek 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 bartworks.common.net; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; - -import com.google.common.io.ByteArrayDataInput; - -import bartworks.common.items.ItemCircuitProgrammer; -import gregtech.api.net.GTPacketNew; -import io.netty.buffer.ByteBuf; - -public class CircuitProgrammerPacket extends GTPacketNew { - - private int dimID, playerID; - private byte chipCfg; - private boolean hasChip; - - public CircuitProgrammerPacket() { - super(true); - } - - public CircuitProgrammerPacket(int dimID, int playerID, boolean hasChip, byte chipCfg) { - super(false); - this.dimID = dimID; - this.playerID = playerID; - this.hasChip = hasChip; - this.chipCfg = chipCfg; - } - - @Override - public byte getPacketID() { - return 1; - } - - @Override - public void encode(ByteBuf aOut) { - aOut.writeInt(this.dimID) - .writeInt(this.playerID) - .writeByte(this.hasChip ? this.chipCfg : -1); - } - - @Override - public GTPacketNew decode(ByteArrayDataInput byteArrayDataInput) { - return new CircuitProgrammerPacket( - byteArrayDataInput.readInt(), - byteArrayDataInput.readInt(), - byteArrayDataInput.readByte() > -1, - byteArrayDataInput.readByte()); - } - - @Override - public void process(IBlockAccess iBlockAccess) { - World w = DimensionManager.getWorld(this.dimID); - if (w != null && w.getEntityByID(this.playerID) instanceof EntityPlayer) { - ItemStack stack = ((EntityPlayer) w.getEntityByID(this.playerID)).getHeldItem(); - if (stack != null && stack.stackSize > 0) { - Item item = stack.getItem(); - if (item instanceof ItemCircuitProgrammer) { - NBTTagCompound nbt = stack.getTagCompound(); - nbt.setBoolean("HasChip", this.hasChip); - if (this.hasChip) nbt.setByte("ChipConfig", this.chipCfg); - stack.setTagCompound(nbt); - ((EntityPlayer) w.getEntityByID(this.playerID)).inventory.setInventorySlotContents( - ((EntityPlayer) w.getEntityByID(this.playerID)).inventory.currentItem, - stack); - } - } - } - } -} diff --git a/src/main/java/bartworks/common/net/MetaBlockPacket.java b/src/main/java/bartworks/common/net/PacketBWMetaBlock.java index ee8ab8231a..15af82903d 100644 --- a/src/main/java/bartworks/common/net/MetaBlockPacket.java +++ b/src/main/java/bartworks/common/net/PacketBWMetaBlock.java @@ -24,31 +24,31 @@ import com.google.common.io.ByteArrayDataInput; import bartworks.MainMod; import bartworks.system.material.TileEntityMetaGeneratedBlock; import bartworks.util.MurmurHash3; -import gregtech.api.net.GTPacketNew; +import gregtech.api.net.GTPacket; import io.netty.buffer.ByteBuf; -public class MetaBlockPacket extends GTPacketNew { +public class PacketBWMetaBlock extends GTPacket { int x; short y; int z; short meta; - public MetaBlockPacket(int x, int y, int z, int meta) { - super(false); + public PacketBWMetaBlock(int x, int y, int z, int meta) { + super(); this.x = x; this.y = (short) y; this.z = z; this.meta = (short) meta; } - public MetaBlockPacket() { - super(true); + public PacketBWMetaBlock() { + super(); } @Override public byte getPacketID() { - return 2; + return 24; } @Override @@ -71,12 +71,12 @@ public class MetaBlockPacket extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput byteArrayDataInput) { + public GTPacket decode(ByteArrayDataInput byteArrayDataInput) { this.x = byteArrayDataInput.readInt(); this.z = byteArrayDataInput.readInt(); this.y = byteArrayDataInput.readShort(); this.meta = byteArrayDataInput.readShort(); - MetaBlockPacket todecode = new MetaBlockPacket(this.x, this.y, this.z, this.meta); + PacketBWMetaBlock todecode = new PacketBWMetaBlock(this.x, this.y, this.z, this.meta); if (byteArrayDataInput.readInt() != MurmurHash3.murmurhash3_x86_32( ByteBuffer.allocate(12) .putInt(this.x) diff --git a/src/main/java/bartworks/common/net/RendererPacket.java b/src/main/java/bartworks/common/net/PacketBioVatRenderer.java index f4f03c3584..936ee6fc4f 100644 --- a/src/main/java/bartworks/common/net/RendererPacket.java +++ b/src/main/java/bartworks/common/net/PacketBioVatRenderer.java @@ -22,21 +22,21 @@ import bartworks.MainMod; import bartworks.common.tileentities.multis.MTEBioVat; import bartworks.util.BWColorUtil; import bartworks.util.Coords; -import gregtech.api.net.GTPacketNew; +import gregtech.api.net.GTPacket; import io.netty.buffer.ByteBuf; -public class RendererPacket extends GTPacketNew { +public class PacketBioVatRenderer extends GTPacket { private Coords coords; private int integer; private byte removal; - public RendererPacket() { - super(true); + public PacketBioVatRenderer() { + super(); } - public RendererPacket(Coords coords, int integer, boolean removal) { - super(false); + public PacketBioVatRenderer(Coords coords, int integer, boolean removal) { + super(); this.coords = coords; this.integer = integer; this.removal = (byte) (removal ? 1 : 0); @@ -44,7 +44,7 @@ public class RendererPacket extends GTPacketNew { @Override public byte getPacketID() { - return 0; + return 23; } @Override @@ -69,7 +69,7 @@ public class RendererPacket extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput dataInput) { + public GTPacket decode(ByteArrayDataInput dataInput) { this.coords = new Coords(dataInput.readInt(), dataInput.readShort(), dataInput.readInt(), dataInput.readInt()); this.integer = BWColorUtil .getColorFromRGBArray(new int[] { dataInput.readByte(), dataInput.readByte(), dataInput.readByte() }); @@ -86,7 +86,7 @@ public class RendererPacket extends GTPacketNew { return null; } - return new RendererPacket(this.coords, this.integer, this.removal == 1); + return new PacketBioVatRenderer(this.coords, this.integer, this.removal == 1); } @Override diff --git a/src/main/java/bartworks/common/net/EICPacket.java b/src/main/java/bartworks/common/net/PacketEIC.java index 9d2414a0e0..813cc1a07d 100644 --- a/src/main/java/bartworks/common/net/EICPacket.java +++ b/src/main/java/bartworks/common/net/PacketEIC.java @@ -10,27 +10,27 @@ import bartworks.common.tileentities.multis.MTEElectricImplosionCompressor; import bartworks.util.Coords; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.net.GTPacketNew; +import gregtech.api.net.GTPacket; import io.netty.buffer.ByteBuf; -public class EICPacket extends GTPacketNew { +public class PacketEIC extends GTPacket { private Coords coords; private boolean bool; - public EICPacket() { - super(true); + public PacketEIC() { + super(); } - public EICPacket(Coords coords, boolean bool) { - super(false); + public PacketEIC(Coords coords, boolean bool) { + super(); this.coords = coords; this.bool = bool; } @Override public byte getPacketID() { - return 5; + return 27; } @Override @@ -42,8 +42,8 @@ public class EICPacket extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { - return new EICPacket(new Coords(aData.readInt(), aData.readInt(), aData.readInt()), aData.readBoolean()); + public GTPacket decode(ByteArrayDataInput aData) { + return new PacketEIC(new Coords(aData.readInt(), aData.readInt(), aData.readInt()), aData.readBoolean()); } @Override diff --git a/src/main/java/bartworks/common/net/OreDictCachePacket.java b/src/main/java/bartworks/common/net/PacketOreDictCache.java index b8cda117ac..14b58faae7 100644 --- a/src/main/java/bartworks/common/net/OreDictCachePacket.java +++ b/src/main/java/bartworks/common/net/PacketOreDictCache.java @@ -21,25 +21,25 @@ import com.google.common.io.ByteArrayDataInput; import bartworks.system.oredict.OreDictHandler; import bartworks.util.Pair; -import gregtech.api.net.GTPacketNew; +import gregtech.api.net.GTPacket; import io.netty.buffer.ByteBuf; -public class OreDictCachePacket extends GTPacketNew { +public class PacketOreDictCache extends GTPacket { private HashSet<Pair<Integer, Short>> hashSet = new HashSet<>(); - public OreDictCachePacket() { - super(true); + public PacketOreDictCache() { + super(); } - public OreDictCachePacket(HashSet<Pair<Integer, Short>> set) { - super(false); + public PacketOreDictCache(HashSet<Pair<Integer, Short>> set) { + super(); this.hashSet = set; } @Override public byte getPacketID() { - return 3; + return 25; } @Override @@ -53,12 +53,12 @@ public class OreDictCachePacket extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput byteArrayDataInput) { + public GTPacket decode(ByteArrayDataInput byteArrayDataInput) { int size = byteArrayDataInput.readInt(); for (int i = 0; i < size; i++) { this.hashSet.add(new Pair<>(byteArrayDataInput.readInt(), byteArrayDataInput.readShort())); } - return new OreDictCachePacket(this.hashSet); + return new PacketOreDictCache(this.hashSet); } @Override diff --git a/src/main/java/bartworks/common/net/ServerJoinedPacket.java b/src/main/java/bartworks/common/net/PacketServerJoined.java index 8c6b89f28f..1c20996552 100644 --- a/src/main/java/bartworks/common/net/ServerJoinedPacket.java +++ b/src/main/java/bartworks/common/net/PacketServerJoined.java @@ -18,25 +18,25 @@ import net.minecraft.world.IBlockAccess; import com.google.common.io.ByteArrayDataInput; import bartworks.MainMod; -import gregtech.api.net.GTPacketNew; +import gregtech.api.net.GTPacket; import io.netty.buffer.ByteBuf; -public class ServerJoinedPacket extends GTPacketNew { +public class PacketServerJoined extends GTPacket { private byte config; - ServerJoinedPacket() { - super(true); + public PacketServerJoined() { + super(); } - public ServerJoinedPacket(Object obj) { - super(false); + public PacketServerJoined(Object obj) { + super(); this.config = 0; } @Override public byte getPacketID() { - return 4; + return 26; } @Override @@ -45,7 +45,7 @@ public class ServerJoinedPacket extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput byteArrayDataInput) { + public GTPacket decode(ByteArrayDataInput byteArrayDataInput) { this.config = byteArrayDataInput.readByte(); return this; } diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java b/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java index b3d4347616..88c5888878 100644 --- a/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java +++ b/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java @@ -57,11 +57,10 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import bartworks.API.SideReference; import bartworks.API.recipe.BartWorksRecipeMaps; -import bartworks.MainMod; import bartworks.common.configs.Configuration; import bartworks.common.items.ItemLabParts; import bartworks.common.loaders.FluidLoader; -import bartworks.common.net.RendererPacket; +import bartworks.common.net.PacketBioVatRenderer; import bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; import bartworks.util.BWUtil; import bartworks.util.BioCulture; @@ -69,6 +68,7 @@ import bartworks.util.Coords; import bartworks.util.MathUtils; import bartworks.util.ResultWrongSievert; import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -390,10 +390,10 @@ public class MTEBioVat extends MTEEnhancedMultiBlockBase<MTEBioVat> implements I lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB()); if (SideReference.Side.Server) { - MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + GTValues.NW.sendPacketToAllPlayersInRange( this.getBaseMetaTileEntity() .getWorld(), - new RendererPacket( + new PacketBioVatRenderer( new Coords( xDir + x + this.getBaseMetaTileEntity() @@ -411,10 +411,10 @@ public class MTEBioVat extends MTEEnhancedMultiBlockBase<MTEBioVat> implements I .getXCoord(), this.getBaseMetaTileEntity() .getZCoord()); - MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + GTValues.NW.sendPacketToAllPlayersInRange( this.getBaseMetaTileEntity() .getWorld(), - new RendererPacket( + new PacketBioVatRenderer( new Coords( xDir + x + this.getBaseMetaTileEntity() @@ -703,10 +703,10 @@ public class MTEBioVat extends MTEEnhancedMultiBlockBase<MTEBioVat> implements I for (int x = -1; x < 2; x++) { for (int y = 1; y < 3; y++) { for (int z = -1; z < 2; z++) { - MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + GTValues.NW.sendPacketToAllPlayersInRange( this.getBaseMetaTileEntity() .getWorld(), - new RendererPacket( + new PacketBioVatRenderer( new Coords( xDir + x + this.getBaseMetaTileEntity() diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java b/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java index 1339c11095..76cf946f85 100644 --- a/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java +++ b/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java @@ -65,15 +65,15 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureUtility; import bartworks.API.recipe.BartWorksRecipeMaps; -import bartworks.MainMod; import bartworks.client.renderer.EICPistonVisualizer; import bartworks.common.configs.Configuration; -import bartworks.common.net.EICPacket; +import bartworks.common.net.PacketEIC; import bartworks.util.Coords; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fox.spiteful.avaritia.blocks.LudicrousBlocks; import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; import gregtech.api.enums.Mods; import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; @@ -352,9 +352,9 @@ public class MTEElectricImplosionCompressor extends MTEExtendedPowerMultiBlockBa if (pistonEnabled && aBaseMetaTileEntity.isActive() && aTick % 20 == 0) { if (aBaseMetaTileEntity.isClientSide()) this.animatePiston(aBaseMetaTileEntity); - else if (aBaseMetaTileEntity.hasMufflerUpgrade()) MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + else if (aBaseMetaTileEntity.hasMufflerUpgrade()) GTValues.NW.sendPacketToAllPlayersInRange( aBaseMetaTileEntity.getWorld(), - new EICPacket( + new PacketEIC( new Coords( aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), diff --git a/src/main/java/bartworks/server/EventHandler/ServerEventHandler.java b/src/main/java/bartworks/server/EventHandler/ServerEventHandler.java index 2a1ba2b626..5351824c7c 100644 --- a/src/main/java/bartworks/server/EventHandler/ServerEventHandler.java +++ b/src/main/java/bartworks/server/EventHandler/ServerEventHandler.java @@ -19,14 +19,14 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.oredict.OreDictionary; import bartworks.API.SideReference; -import bartworks.MainMod; -import bartworks.common.net.OreDictCachePacket; -import bartworks.common.net.ServerJoinedPacket; +import bartworks.common.net.PacketOreDictCache; +import bartworks.common.net.PacketServerJoined; import bartworks.system.material.Werkstoff; import bartworks.system.oredict.OreDictHandler; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; +import gregtech.api.enums.GTValues; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GTOreDictUnificator; @@ -36,9 +36,8 @@ public class ServerEventHandler { @SubscribeEvent(priority = EventPriority.LOWEST) public void EntityJoinWorldEvent(EntityJoinWorldEvent event) { if (event == null || !(event.entity instanceof EntityPlayerMP) || !SideReference.Side.Server) return; - MainMod.BW_Network_instance - .sendToPlayer(new OreDictCachePacket(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity); - MainMod.BW_Network_instance.sendToPlayer(new ServerJoinedPacket(null), (EntityPlayerMP) event.entity); + GTValues.NW.sendToPlayer(new PacketOreDictCache(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity); + GTValues.NW.sendToPlayer(new PacketServerJoined(null), (EntityPlayerMP) event.entity); } // FMLCommonHandler.instance().bus() diff --git a/src/main/java/bartworks/system/material/TileEntityMetaGeneratedBlock.java b/src/main/java/bartworks/system/material/TileEntityMetaGeneratedBlock.java index c37613aa17..5fe9a70599 100644 --- a/src/main/java/bartworks/system/material/TileEntityMetaGeneratedBlock.java +++ b/src/main/java/bartworks/system/material/TileEntityMetaGeneratedBlock.java @@ -22,8 +22,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; -import bartworks.MainMod; -import bartworks.common.net.MetaBlockPacket; +import bartworks.common.net.PacketBWMetaBlock; +import gregtech.api.enums.GTValues; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; public abstract class TileEntityMetaGeneratedBlock extends TileEntity implements ITexturedTileEntity { @@ -49,9 +49,9 @@ public abstract class TileEntityMetaGeneratedBlock extends TileEntity implements @Override public Packet getDescriptionPacket() { - if (!this.worldObj.isRemote) MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + if (!this.worldObj.isRemote) GTValues.NW.sendPacketToAllPlayersInRange( this.worldObj, - new MetaBlockPacket(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), + new PacketBWMetaBlock(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), this.xCoord, this.zCoord); return null; diff --git a/src/main/java/gregtech/api/multitileentity/base/MultiTileEntity.java b/src/main/java/gregtech/api/multitileentity/base/MultiTileEntity.java index 24163f9c20..5ca30b6df6 100644 --- a/src/main/java/gregtech/api/multitileentity/base/MultiTileEntity.java +++ b/src/main/java/gregtech/api/multitileentity/base/MultiTileEntity.java @@ -52,8 +52,8 @@ import gregtech.api.multitileentity.MultiTileEntityClassContainer; import gregtech.api.multitileentity.MultiTileEntityRegistry; import gregtech.api.multitileentity.interfaces.IMultiTileEntity; import gregtech.api.multitileentity.interfaces.SyncedMultiTileEntity; +import gregtech.api.net.GTPacket; import gregtech.api.net.GTPacketMultiTileEntity; -import gregtech.api.net.GTPacketNew; import gregtech.api.net.data.CommonData; import gregtech.api.net.data.CoordinateData; import gregtech.api.net.data.MultiTileEntityData; @@ -105,9 +105,9 @@ public abstract class MultiTileEntity extends CoverableTileEntity private UUID ownerUUID = GTUtility.defaultUuid; private boolean lockUpgrade = false; - private final GTPacketMultiTileEntity fullPacket = new GTPacketMultiTileEntity(false); - private final GTPacketMultiTileEntity timedPacket = new GTPacketMultiTileEntity(false); - private final GTPacketMultiTileEntity graphicPacket = new GTPacketMultiTileEntity(false); + private final GTPacketMultiTileEntity fullPacket = new GTPacketMultiTileEntity(); + private final GTPacketMultiTileEntity timedPacket = new GTPacketMultiTileEntity(); + private final GTPacketMultiTileEntity graphicPacket = new GTPacketMultiTileEntity(); public MultiTileEntity(boolean isTicking) { this.isTicking = isTicking; @@ -1035,14 +1035,14 @@ public abstract class MultiTileEntity extends CoverableTileEntity */ public GTPacketMultiTileEntity getClientDataPacket() { - final GTPacketMultiTileEntity packet = new GTPacketMultiTileEntity(false); + final GTPacketMultiTileEntity packet = new GTPacketMultiTileEntity(); return packet; } @Override public void sendClientData(EntityPlayerMP aPlayer) { if (worldObj == null || worldObj.isRemote) return; - final GTPacketNew tPacket = getClientDataPacket(); + final GTPacket tPacket = getClientDataPacket(); if (aPlayer == null) { GTValues.NW.sendPacketToAllPlayersInRange(worldObj, tPacket, getXCoord(), getZCoord()); } else { diff --git a/src/main/java/gregtech/api/net/GTPacket.java b/src/main/java/gregtech/api/net/GTPacket.java index 1d2de3303b..68e08ab304 100644 --- a/src/main/java/gregtech/api/net/GTPacket.java +++ b/src/main/java/gregtech/api/net/GTPacket.java @@ -7,53 +7,35 @@ import com.google.common.io.ByteArrayDataInput; import io.netty.buffer.ByteBuf; -/** - * @deprecated Use {@link GTPacketNew} instead - */ -@Deprecated public abstract class GTPacket { - public GTPacket(boolean aIsReference) { - // - } + public GTPacket() {} /** - * I use constant IDs instead of Dynamic ones, since that is much more fail safe - * - * @return a Packet ID for this Class + * Unique ID of this packet. */ public abstract byte getPacketID(); /** - * @return encoded byte Stream - * @deprecated Use {@link #encode(ByteBuf)} instead - */ - @Deprecated - public abstract byte[] encode(); - - /** - * Encode the data into given byte buffer without creating an intermediate byte array. Default implementation just - * throw {@link UnsupportedOperationException}. + * Encode the data into given byte buffer. */ - public void encode(ByteBuf aOut) { - throw new UnsupportedOperationException(); - } + public abstract void encode(ByteBuf buffer); /** - * @return encoded byte Stream + * Decode byte buffer into packet object. */ - public abstract GTPacket decode(ByteArrayDataInput aData); + public abstract GTPacket decode(ByteArrayDataInput buffer); /** - * Process the packet + * Process the received packet. * - * @param aWorld null if message is received on server side, the client world if message is received on client side + * @param world null if message is received on server side, the client world if message is received on client side */ - public abstract void process(IBlockAccess aWorld); + public abstract void process(IBlockAccess world); /** * This will be called just before {@link #process(IBlockAccess)} to inform the handler about the source and type of - * connection + * connection. */ - public void setINetHandler(INetHandler aHandler) {} + public void setINetHandler(INetHandler handler) {} } diff --git a/src/main/java/gregtech/api/net/GTPacketBlockEvent.java b/src/main/java/gregtech/api/net/GTPacketBlockEvent.java index a2164f4f07..1e4e942bf2 100644 --- a/src/main/java/gregtech/api/net/GTPacketBlockEvent.java +++ b/src/main/java/gregtech/api/net/GTPacketBlockEvent.java @@ -10,18 +10,18 @@ import io.netty.buffer.ByteBuf; /** * Used to transfer Block Events in a much better fashion */ -public class GTPacketBlockEvent extends GTPacketNew { +public class GTPacketBlockEvent extends GTPacket { private int mX, mZ; private short mY; private byte mID, mValue; public GTPacketBlockEvent() { - super(true); + super(); } public GTPacketBlockEvent(int aX, short aY, int aZ, byte aID, byte aValue) { - super(false); + super(); mX = aX; mY = aY; mZ = aZ; @@ -39,7 +39,7 @@ public class GTPacketBlockEvent extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketBlockEvent( aData.readInt(), aData.readShort(), diff --git a/src/main/java/gregtech/api/net/GTPacketClientPreference.java b/src/main/java/gregtech/api/net/GTPacketClientPreference.java index ea5d9ec476..28a5a83f2e 100644 --- a/src/main/java/gregtech/api/net/GTPacketClientPreference.java +++ b/src/main/java/gregtech/api/net/GTPacketClientPreference.java @@ -11,17 +11,17 @@ import gregtech.GTMod; import gregtech.api.util.GTClientPreference; import io.netty.buffer.ByteBuf; -public class GTPacketClientPreference extends GTPacketNew { +public class GTPacketClientPreference extends GTPacket { private GTClientPreference mPreference; private EntityPlayerMP mPlayer; public GTPacketClientPreference() { - super(true); + super(); } public GTPacketClientPreference(GTClientPreference mPreference) { - super(false); + super(); this.mPreference = mPreference; } @@ -51,7 +51,7 @@ public class GTPacketClientPreference extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketClientPreference( new GTClientPreference(aData.readBoolean(), aData.readBoolean(), aData.readBoolean(), aData.readBoolean())); } diff --git a/src/main/java/gregtech/api/net/GTPacketInfiniteSpraycan.java b/src/main/java/gregtech/api/net/GTPacketInfiniteSpraycan.java index 302937f6ba..c12dc7d02a 100644 --- a/src/main/java/gregtech/api/net/GTPacketInfiniteSpraycan.java +++ b/src/main/java/gregtech/api/net/GTPacketInfiniteSpraycan.java @@ -16,24 +16,24 @@ import gregtech.api.util.GTUtility; import gregtech.common.items.behaviors.BehaviourSprayColorInfinite; import io.netty.buffer.ByteBuf; -public class GTPacketInfiniteSpraycan extends GTPacketNew { +public class GTPacketInfiniteSpraycan extends GTPacket { private Action action; private int newColor; private EntityPlayerMP player; public GTPacketInfiniteSpraycan() { - super(true); + super(); } public GTPacketInfiniteSpraycan(Action action) { - super(false); + super(); this.action = action; this.newColor = -1; } public GTPacketInfiniteSpraycan(Action action, int newColor) { - super(false); + super(); this.action = action; this.newColor = newColor; } @@ -53,7 +53,7 @@ public class GTPacketInfiniteSpraycan extends GTPacketNew { } @Override - public GTPacketNew decode(final ByteArrayDataInput aData) { + public GTPacket decode(final ByteArrayDataInput aData) { final int newColor = aData.readInt(); final int length = aData.readInt(); final byte[] name = new byte[length]; diff --git a/src/main/java/gregtech/api/net/GTPacketMultiTileEntity.java b/src/main/java/gregtech/api/net/GTPacketMultiTileEntity.java index b151f8eb5f..1b9fab34d4 100644 --- a/src/main/java/gregtech/api/net/GTPacketMultiTileEntity.java +++ b/src/main/java/gregtech/api/net/GTPacketMultiTileEntity.java @@ -18,14 +18,14 @@ import gregtech.api.net.data.MultiTileEntityProcess; import gregtech.api.net.data.PacketData; import io.netty.buffer.ByteBuf; -public class GTPacketMultiTileEntity extends GTPacketNew { +public class GTPacketMultiTileEntity extends GTPacket { private final Set<PacketData<MultiTileEntityProcess>> data = new HashSet<>(); public static final int COVERS = B[0], REDSTONE = B[1], MODES = B[2], CONTROLLER = B[3], INVENTORY_INDEX = B[4], INVENTORY_NAME_ID = B[5], BOOLEANS = B[6], SOUND = B[7]; - public GTPacketMultiTileEntity(boolean reference) { - super(reference); + public GTPacketMultiTileEntity() { + super(); } @Override @@ -97,11 +97,11 @@ public class GTPacketMultiTileEntity extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput in) { + public GTPacket decode(ByteArrayDataInput in) { Objects.requireNonNull(in); final int packetFeatures = in.readInt(); - final GTPacketMultiTileEntity packet = new GTPacketMultiTileEntity(false); + final GTPacketMultiTileEntity packet = new GTPacketMultiTileEntity(); if (containsBit(packetFeatures, CoordinateData.COORDINATE_DATA_ID)) { packet.addData(new CoordinateData()); diff --git a/src/main/java/gregtech/api/net/GTPacketMusicSystemData.java b/src/main/java/gregtech/api/net/GTPacketMusicSystemData.java index c650188594..c69772a2fb 100644 --- a/src/main/java/gregtech/api/net/GTPacketMusicSystemData.java +++ b/src/main/java/gregtech/api/net/GTPacketMusicSystemData.java @@ -8,16 +8,16 @@ import gregtech.api.util.GTMusicSystem; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -public class GTPacketMusicSystemData extends GTPacketNew { +public class GTPacketMusicSystemData extends GTPacket { ByteBuf storedData; public GTPacketMusicSystemData() { - super(true); + super(); } public GTPacketMusicSystemData(ByteBuf data) { - super(false); + super(); this.storedData = data; } @@ -39,7 +39,7 @@ public class GTPacketMusicSystemData extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { final int len = aData.readInt(); final byte[] fullData = new byte[len]; aData.readFully(fullData); diff --git a/src/main/java/gregtech/api/net/GTPacketNew.java b/src/main/java/gregtech/api/net/GTPacketNew.java deleted file mode 100644 index d3fee800c6..0000000000 --- a/src/main/java/gregtech/api/net/GTPacketNew.java +++ /dev/null @@ -1,30 +0,0 @@ -package gregtech.api.net; - -import com.google.common.io.ByteArrayDataInput; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; - -@SuppressWarnings("deprecation") -public abstract class GTPacketNew extends GTPacket { - - public GTPacketNew(boolean aIsReference) { - super(aIsReference); - } - - @Override - @Deprecated - public final byte[] encode() { - final ByteBuf tOut = Unpooled.buffer(); - encode(tOut); - final byte[] bytes = new byte[tOut.readableBytes()]; - tOut.readBytes(bytes); - return bytes; - } - - @Override - public abstract void encode(ByteBuf aOut); - - @Override - public abstract GTPacketNew decode(ByteArrayDataInput aData); -} diff --git a/src/main/java/gregtech/api/net/GTPacketPollution.java b/src/main/java/gregtech/api/net/GTPacketPollution.java index 2f4805aad8..6d15341682 100644 --- a/src/main/java/gregtech/api/net/GTPacketPollution.java +++ b/src/main/java/gregtech/api/net/GTPacketPollution.java @@ -8,17 +8,17 @@ import com.google.common.io.ByteArrayDataInput; import gregtech.common.GTClient; import io.netty.buffer.ByteBuf; -public class GTPacketPollution extends GTPacketNew { +public class GTPacketPollution extends GTPacket { private ChunkCoordIntPair chunk; private int pollution; public GTPacketPollution() { - super(true); + super(); } public GTPacketPollution(ChunkCoordIntPair chunk, int pollution) { - super(false); + super(); this.chunk = chunk; this.pollution = pollution; } @@ -31,7 +31,7 @@ public class GTPacketPollution extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketPollution(new ChunkCoordIntPair(aData.readInt(), aData.readInt()), aData.readInt()); } diff --git a/src/main/java/gregtech/api/net/GTPacketRequestCoverData.java b/src/main/java/gregtech/api/net/GTPacketRequestCoverData.java index 4679643624..5d42086454 100644 --- a/src/main/java/gregtech/api/net/GTPacketRequestCoverData.java +++ b/src/main/java/gregtech/api/net/GTPacketRequestCoverData.java @@ -19,7 +19,7 @@ import io.netty.buffer.ByteBuf; /** * Client -> Server : ask for cover data */ -public class GTPacketRequestCoverData extends GTPacketNew { +public class GTPacketRequestCoverData extends GTPacket { protected int mX; protected short mY; @@ -31,11 +31,11 @@ public class GTPacketRequestCoverData extends GTPacketNew { protected EntityPlayerMP mPlayer; public GTPacketRequestCoverData() { - super(true); + super(); } public GTPacketRequestCoverData(CoverInfo info, ICoverable tile) { - super(false); + super(); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); this.mZ = tile.getZCoord(); @@ -45,7 +45,7 @@ public class GTPacketRequestCoverData extends GTPacketNew { } public GTPacketRequestCoverData(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID) { - super(false); + super(); this.mX = mX; this.mY = mY; this.mZ = mZ; @@ -55,7 +55,7 @@ public class GTPacketRequestCoverData extends GTPacketNew { } public GTPacketRequestCoverData(ForgeDirection coverSide, int coverID, ICoverable tile) { - super(false); + super(); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); this.mZ = tile.getZCoord(); @@ -80,7 +80,7 @@ public class GTPacketRequestCoverData extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketRequestCoverData( aData.readInt(), aData.readShort(), diff --git a/src/main/java/gregtech/api/net/GTPacketSendCoverData.java b/src/main/java/gregtech/api/net/GTPacketSendCoverData.java index 76adb75d31..15945b113a 100644 --- a/src/main/java/gregtech/api/net/GTPacketSendCoverData.java +++ b/src/main/java/gregtech/api/net/GTPacketSendCoverData.java @@ -16,7 +16,7 @@ import io.netty.buffer.ByteBuf; /** * Server -> Client : Update cover data */ -public class GTPacketSendCoverData extends GTPacketNew { +public class GTPacketSendCoverData extends GTPacket { protected int mX; protected short mY; @@ -27,12 +27,12 @@ public class GTPacketSendCoverData extends GTPacketNew { protected ISerializableObject coverData; public GTPacketSendCoverData() { - super(true); + super(); } public GTPacketSendCoverData(int mX, short mY, int mZ, ForgeDirection coverSide, int coverID, ISerializableObject coverData) { - super(false); + super(); this.mX = mX; this.mY = mY; this.mZ = mZ; @@ -43,7 +43,7 @@ public class GTPacketSendCoverData extends GTPacketNew { } public GTPacketSendCoverData(CoverInfo info, ICoverable tile) { - super(false); + super(); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); this.mZ = tile.getZCoord(); @@ -55,7 +55,7 @@ public class GTPacketSendCoverData extends GTPacketNew { public GTPacketSendCoverData(ForgeDirection coverSide, int coverID, ISerializableObject coverData, ICoverable tile) { - super(false); + super(); this.mX = tile.getXCoord(); this.mY = tile.getYCoord(); this.mZ = tile.getZCoord(); @@ -82,7 +82,7 @@ public class GTPacketSendCoverData extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { final int coverId; return new GTPacketSendCoverData( aData.readInt(), diff --git a/src/main/java/gregtech/api/net/GTPacketSendOregenPattern.java b/src/main/java/gregtech/api/net/GTPacketSendOregenPattern.java index 9db0e9a471..dc9119d80a 100644 --- a/src/main/java/gregtech/api/net/GTPacketSendOregenPattern.java +++ b/src/main/java/gregtech/api/net/GTPacketSendOregenPattern.java @@ -9,16 +9,16 @@ import gregtech.common.GTWorldgenerator; import gregtech.common.GTWorldgenerator.OregenPattern; import io.netty.buffer.ByteBuf; -public class GTPacketSendOregenPattern extends GTPacketNew { +public class GTPacketSendOregenPattern extends GTPacket { protected OregenPattern pattern = OregenPattern.AXISSYMMETRICAL; public GTPacketSendOregenPattern() { - super(true); + super(); } public GTPacketSendOregenPattern(OregenPattern pattern) { - super(false); + super(); this.pattern = pattern; } @@ -28,7 +28,7 @@ public class GTPacketSendOregenPattern extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { int ordinal = aData.readInt(); // make sure we get valid data: if (ordinal >= 0 && ordinal < OregenPattern.values().length) { diff --git a/src/main/java/gregtech/api/net/GTPacketSetConfigurationCircuit.java b/src/main/java/gregtech/api/net/GTPacketSetConfigurationCircuit.java index 8984cea509..8aaf291de2 100644 --- a/src/main/java/gregtech/api/net/GTPacketSetConfigurationCircuit.java +++ b/src/main/java/gregtech/api/net/GTPacketSetConfigurationCircuit.java @@ -22,7 +22,7 @@ import io.netty.buffer.ByteBuf; /** * Client -> Server: Update machine configuration data */ -public class GTPacketSetConfigurationCircuit extends GTPacketNew { +public class GTPacketSetConfigurationCircuit extends GTPacket { protected int mX; protected short mY; @@ -32,7 +32,7 @@ public class GTPacketSetConfigurationCircuit extends GTPacketNew { protected ItemStack circuit; public GTPacketSetConfigurationCircuit() { - super(true); + super(); } public GTPacketSetConfigurationCircuit(IGregTechTileEntity tile, ItemStack circuit) { @@ -44,7 +44,7 @@ public class GTPacketSetConfigurationCircuit extends GTPacketNew { } public GTPacketSetConfigurationCircuit(int x, short y, int z, ItemStack circuit) { - super(false); + super(); this.mX = x; this.mY = y; @@ -82,7 +82,7 @@ public class GTPacketSetConfigurationCircuit extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketSetConfigurationCircuit( aData.readInt(), aData.readShort(), diff --git a/src/main/java/gregtech/api/net/GTPacketSound.java b/src/main/java/gregtech/api/net/GTPacketSound.java index 95f95e641d..feaf5abf85 100644 --- a/src/main/java/gregtech/api/net/GTPacketSound.java +++ b/src/main/java/gregtech/api/net/GTPacketSound.java @@ -12,7 +12,7 @@ import gregtech.api.util.GTUtility; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; -public class GTPacketSound extends GTPacketNew { +public class GTPacketSound extends GTPacket { private int mX, mZ; private short mY; @@ -20,11 +20,11 @@ public class GTPacketSound extends GTPacketNew { private float mSoundStrength, mSoundPitch; public GTPacketSound() { - super(true); + super(); } public GTPacketSound(String aSoundName, float aSoundStrength, float aSoundPitch, int aX, short aY, int aZ) { - super(false); + super(); mX = aX; mY = aY; mZ = aZ; @@ -49,7 +49,7 @@ public class GTPacketSound extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketSound( aData.readUTF(), aData.readFloat(), diff --git a/src/main/java/gregtech/api/net/GTPacketTileEntity.java b/src/main/java/gregtech/api/net/GTPacketTileEntity.java index eecb16d6da..e996f32ced 100644 --- a/src/main/java/gregtech/api/net/GTPacketTileEntity.java +++ b/src/main/java/gregtech/api/net/GTPacketTileEntity.java @@ -11,20 +11,20 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import io.netty.buffer.ByteBuf; -public class GTPacketTileEntity extends GTPacketNew { +public class GTPacketTileEntity extends GTPacket { private int mX, mZ, mC0, mC1, mC2, mC3, mC4, mC5; private short mY, mID, mRID; private byte mTexture, mTexturePage, mUpdate, mRedstone, mColor; public GTPacketTileEntity() { - super(true); + super(); } // For multi tiles public GTPacketTileEntity(int aX, short aY, int aZ, short aRID, short aID, int aC0, int aC1, int aC2, int aC3, int aC4, int aC5, byte aTexture, byte aTexturePage, byte aUpdate, byte aRedstone, byte aColor) { - super(false); + super(); mX = aX; mY = aY; mZ = aZ; @@ -95,7 +95,7 @@ public class GTPacketTileEntity extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketTileEntity( // Coords aData.readInt(), diff --git a/src/main/java/gregtech/api/net/GTPacketToolSwitchMode.java b/src/main/java/gregtech/api/net/GTPacketToolSwitchMode.java index 57cabcf2bf..df3b579180 100644 --- a/src/main/java/gregtech/api/net/GTPacketToolSwitchMode.java +++ b/src/main/java/gregtech/api/net/GTPacketToolSwitchMode.java @@ -11,12 +11,12 @@ import com.google.common.io.ByteArrayDataInput; import gregtech.api.items.MetaGeneratedTool; import io.netty.buffer.ByteBuf; -public class GTPacketToolSwitchMode extends GTPacketNew { +public class GTPacketToolSwitchMode extends GTPacket { private EntityPlayerMP player; public GTPacketToolSwitchMode() { - super(true); + super(); } @Override @@ -30,7 +30,7 @@ public class GTPacketToolSwitchMode extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketToolSwitchMode(); } diff --git a/src/main/java/gregtech/api/net/GTPacketTypes.java b/src/main/java/gregtech/api/net/GTPacketTypes.java index 17081ba92e..ed43274434 100644 --- a/src/main/java/gregtech/api/net/GTPacketTypes.java +++ b/src/main/java/gregtech/api/net/GTPacketTypes.java @@ -2,6 +2,11 @@ package gregtech.api.net; import java.util.Arrays; +import bartworks.common.net.PacketBWMetaBlock; +import bartworks.common.net.PacketBioVatRenderer; +import bartworks.common.net.PacketEIC; +import bartworks.common.net.PacketOreDictCache; +import bartworks.common.net.PacketServerJoined; import gregtech.common.blocks.PacketOres; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -20,20 +25,25 @@ public enum GTPacketTypes { UPDATE_ITEM(13, new GTPacketUpdateItem()), SEND_COVER_DATA(16, new GTPacketSendCoverData()), REQUEST_COVER_DATA(17, new GTPacketRequestCoverData()), - MULTI_TILE_ENTITY(18, new GTPacketMultiTileEntity(true)), + MULTI_TILE_ENTITY(18, new GTPacketMultiTileEntity()), SEND_OREGEN_PATTERN(19, new GTPacketSendOregenPattern()), TOOL_SWITCH_MODE(20, new GTPacketToolSwitchMode()), MUSIC_SYSTEM_DATA(21, new GTPacketMusicSystemData()), INFINITE_SPRAYCAN(22, new GTPacketInfiniteSpraycan()), + BIO_VAT_RENDERER(23, new PacketBioVatRenderer()), + BW_META_BLOCK(24, new PacketBWMetaBlock()), + ORE_DICT_CACHE(25, new PacketOreDictCache()), + SERVER_JOINED(26, new PacketServerJoined()), + EIC(27, new PacketEIC()), // merge conflict prevention comment, keep a trailing comma above ; static { // Validate no duplicate IDs final GTPacketTypes[] types = values(); - final Int2ObjectOpenHashMap<GTPacketNew> foundIds = new Int2ObjectOpenHashMap<>(types.length); + final Int2ObjectOpenHashMap<GTPacket> foundIds = new Int2ObjectOpenHashMap<>(types.length); for (GTPacketTypes type : types) { - final GTPacketNew previous = foundIds.get(type.id); + final GTPacket previous = foundIds.get(type.id); if (previous != null) { throw new IllegalStateException( "Duplicate packet IDs defined: " + type.id @@ -47,9 +57,9 @@ public enum GTPacketTypes { } public final byte id; - public final GTPacketNew referencePacket; + public final GTPacket referencePacket; - GTPacketTypes(int id, GTPacketNew referencePacket) { + GTPacketTypes(int id, GTPacket referencePacket) { if (((int) (byte) id) != id) { throw new IllegalArgumentException("Value outside of byte normal range: " + id); } @@ -57,9 +67,9 @@ public enum GTPacketTypes { this.referencePacket = referencePacket; } - public static GTPacketNew[] referencePackets() { + public static GTPacket[] referencePackets() { return Arrays.stream(values()) .map(p -> p.referencePacket) - .toArray(GTPacketNew[]::new); + .toArray(GTPacket[]::new); } } diff --git a/src/main/java/gregtech/api/net/GTPacketUpdateItem.java b/src/main/java/gregtech/api/net/GTPacketUpdateItem.java index 54846cdcc9..31e8f35a8e 100644 --- a/src/main/java/gregtech/api/net/GTPacketUpdateItem.java +++ b/src/main/java/gregtech/api/net/GTPacketUpdateItem.java @@ -17,17 +17,17 @@ import io.netty.buffer.ByteBuf; /** * Client -> Server: send arbitrary data to server and update the currently held item. */ -public class GTPacketUpdateItem extends GTPacketNew { +public class GTPacketUpdateItem extends GTPacket { private NBTTagCompound tag; private EntityPlayerMP mPlayer; public GTPacketUpdateItem() { - super(true); + super(); } public GTPacketUpdateItem(NBTTagCompound tag) { - super(false); + super(); this.tag = tag; } @@ -49,7 +49,7 @@ public class GTPacketUpdateItem extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new GTPacketUpdateItem(ISerializableObject.readCompoundTagFromGreggyByteBuf(aData)); } diff --git a/src/main/java/gregtech/api/net/IGT_NetworkHandler.java b/src/main/java/gregtech/api/net/IGT_NetworkHandler.java index 3569317b01..6eb28efdd5 100644 --- a/src/main/java/gregtech/api/net/IGT_NetworkHandler.java +++ b/src/main/java/gregtech/api/net/IGT_NetworkHandler.java @@ -5,16 +5,13 @@ import net.minecraft.world.World; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; -@SuppressWarnings("deprecation") public interface IGT_NetworkHandler { void sendToPlayer(GTPacket aPacket, EntityPlayerMP aPlayer); void sendToAllAround(GTPacket aPacket, TargetPoint aPosition); - default void sendToAll(GTPacket aPacket) { - throw new UnsupportedOperationException("sendToAll not implemented"); - } + void sendToAll(GTPacket aPacket); void sendToServer(GTPacket aPacket); diff --git a/src/main/java/gregtech/common/GTNetwork.java b/src/main/java/gregtech/common/GTNetwork.java index 30aaecc6cb..8da23fdc1b 100644 --- a/src/main/java/gregtech/common/GTNetwork.java +++ b/src/main/java/gregtech/common/GTNetwork.java @@ -20,7 +20,6 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import gregtech.api.enums.GTValues; import gregtech.api.net.GTPacket; -import gregtech.api.net.GTPacketNew; import gregtech.api.net.GTPacketTypes; import gregtech.api.net.IGT_NetworkHandler; import io.netty.buffer.ByteBuf; @@ -31,7 +30,6 @@ import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.MessageToMessageCodec; @ChannelHandler.Sharable -@SuppressWarnings("deprecation") public class GTNetwork extends MessageToMessageCodec<FMLProxyPacket, GTPacket> implements IGT_NetworkHandler { private final EnumMap<Side, FMLEmbeddedChannel> mChannel; @@ -41,7 +39,7 @@ public class GTNetwork extends MessageToMessageCodec<FMLProxyPacket, GTPacket> i this("GregTech", GTPacketTypes.referencePackets()); } - public GTNetwork(String channelName, GTPacketNew... packetTypes) { + public GTNetwork(String channelName, GTPacket... packetTypes) { this.mChannel = NetworkRegistry.INSTANCE.newChannel(channelName, this, new HandlerShared()); final int lastPId = packetTypes[packetTypes.length - 1].getPacketID(); this.mSubChannels = new GTPacket[lastPId + 1]; diff --git a/src/main/java/gregtech/common/blocks/PacketOres.java b/src/main/java/gregtech/common/blocks/PacketOres.java index 6548f8ae66..18a5672c55 100644 --- a/src/main/java/gregtech/common/blocks/PacketOres.java +++ b/src/main/java/gregtech/common/blocks/PacketOres.java @@ -6,11 +6,11 @@ import net.minecraft.world.World; import com.google.common.io.ByteArrayDataInput; -import gregtech.api.net.GTPacketNew; +import gregtech.api.net.GTPacket; import gregtech.api.net.GTPacketTypes; import io.netty.buffer.ByteBuf; -public class PacketOres extends GTPacketNew { +public class PacketOres extends GTPacket { private int mX; private int mZ; @@ -18,11 +18,11 @@ public class PacketOres extends GTPacketNew { private short mMetaData; public PacketOres() { - super(true); + super(); } public PacketOres(int aX, short aY, int aZ, short aMetaData) { - super(false); + super(); this.mX = aX; this.mY = aY; this.mZ = aZ; @@ -38,7 +38,7 @@ public class PacketOres extends GTPacketNew { } @Override - public GTPacketNew decode(ByteArrayDataInput aData) { + public GTPacket decode(ByteArrayDataInput aData) { return new PacketOres(aData.readInt(), aData.readShort(), aData.readInt(), aData.readShort()); } |