Skip to content

Commit

Permalink
Moved packets from battlegear to backhand package.
Browse files Browse the repository at this point in the history
  • Loading branch information
c0508383 committed Jun 26, 2024
1 parent 5da9f0f commit be00cc3
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import xonin.backhand.api.PlayerEventChild;
import mods.battlegear2.packet.BattlegearSyncItemPacket;
import mods.battlegear2.packet.OffhandConfigSyncPacket;
import mods.battlegear2.packet.OffhandPlaceBlockPacket;
import xonin.backhand.packet.OffhandSyncItemPacket;
import xonin.backhand.packet.OffhandConfigSyncPacket;
import xonin.backhand.packet.OffhandPlaceBlockPacket;
import xonin.backhand.utils.EnumAnimations;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -352,7 +352,7 @@ private boolean hasEntityInteraction(ItemStack itemStack, Entity entity, EntityP
@SubscribeEvent
public void addTracking(PlayerEvent.StartTracking event){
if(event.target instanceof EntityPlayer && !isFake(event.target)){
((EntityPlayerMP)event.entityPlayer).playerNetServerHandler.sendPacket(new BattlegearSyncItemPacket((EntityPlayer) event.target).generatePacket());
((EntityPlayerMP)event.entityPlayer).playerNetServerHandler.sendPacket(new OffhandSyncItemPacket((EntityPlayer) event.target).generatePacket());
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/xonin/backhand/Backhand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import cpw.mods.fml.common.network.FMLEventChannel;
import cpw.mods.fml.common.network.NetworkRegistry;
import mods.battlegear2.BattlemodeHookContainerClass;
import mods.battlegear2.packet.BattlegearPacketHandler;
import xonin.backhand.packet.BackhandPacketHandler;
import xonin.backhand.utils.BackhandConfig;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
Expand All @@ -25,7 +25,7 @@ public class Backhand {
@SidedProxy(clientSide = "xonin.backhand.client.ClientProxy",
serverSide = "xonin.backhand.CommonProxy")
public static CommonProxy proxy;
public static BattlegearPacketHandler packetHandler;
public static BackhandPacketHandler packetHandler;

public static boolean OffhandAttack = false;
public static boolean EmptyOffhand = false;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void load(FMLPreInitializationEvent event) {

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
packetHandler = new BattlegearPacketHandler();
packetHandler = new BackhandPacketHandler();
packetHandler.register();
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/xonin/backhand/ServerTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import xonin.backhand.api.core.BattlegearUtils;
import mods.battlegear2.packet.BattlegearSyncItemPacket;
import mods.battlegear2.packet.OffhandWorldHotswapPacket;
import xonin.backhand.packet.OffhandSyncItemPacket;
import xonin.backhand.packet.OffhandWorldHotswapPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
Expand Down Expand Up @@ -115,7 +115,7 @@ public void onUpdatePlayer(TickEvent.PlayerTickEvent event)

if (BattlegearUtils.getOffhandEP(player).syncOffhand) {
if (!tickStartItems.containsKey(player.getUniqueID())) {
Backhand.packetHandler.sendPacketToAll(new BattlegearSyncItemPacket(player).generatePacket());
Backhand.packetHandler.sendPacketToAll(new OffhandSyncItemPacket(player).generatePacket());
}
BattlegearUtils.getOffhandEP(player).syncOffhand = false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package xonin.backhand.client;

import mods.battlegear2.packet.OffhandAttackPacket;
import mods.battlegear2.packet.OffhandToServerPacket;
import xonin.backhand.packet.OffhandAttackPacket;
import xonin.backhand.packet.OffhandToServerPacket;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.BlockLog;
import net.minecraft.block.material.Material;
Expand All @@ -21,7 +21,7 @@
import xonin.backhand.api.core.BattlegearUtils;
import xonin.backhand.api.core.IBattlePlayer;
import xonin.backhand.api.core.InventoryPlayerBattle;
import mods.battlegear2.packet.OffhandPlaceBlockPacket;
import xonin.backhand.packet.OffhandPlaceBlockPacket;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.PlayerControllerMP;
Expand All @@ -34,7 +34,6 @@
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.tclproject.mysteriumlib.asm.fixes.MysteriumPatchesFixesO;
import xonin.backhand.CommonProxy;
import xonin.backhand.client.ClientTickHandler;

public final class BackhandClientTickHandler {
public final Minecraft mc = Minecraft.getMinecraft();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/xonin/backhand/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import mods.battlegear2.packet.BattlegearAnimationPacket;
import xonin.backhand.packet.OffhandAnimationPacket;
import xonin.backhand.utils.EnumAnimations;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
Expand Down Expand Up @@ -39,7 +39,7 @@ public EntityPlayer getClientPlayer() {
public void sendAnimationPacket(EnumAnimations animation, EntityPlayer entityPlayer) {
if (entityPlayer instanceof EntityClientPlayerMP) {
((EntityClientPlayerMP) entityPlayer).sendQueue.addToSendQueue(
new BattlegearAnimationPacket(animation, entityPlayer).generatePacket());
new OffhandAnimationPacket(animation, entityPlayer).generatePacket());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xonin/backhand/client/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import invtweaks.InvTweaks;
import mods.battlegear2.BattlemodeHookContainerClass;
import xonin.backhand.api.core.BattlegearUtils;
import mods.battlegear2.packet.OffhandSwapPacket;
import xonin.backhand.packet.OffhandSwapPacket;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import io.netty.buffer.ByteBuf;
Expand All @@ -10,7 +10,7 @@
* Date: 26/06/13
* Time: 1:35 PM
*/
public abstract class AbstractMBPacket {
public abstract class AbstractPacket {

public final FMLProxyPacket generatePacket() {
ByteBuf buf = Unpooled.buffer();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import java.util.Hashtable;
import java.util.Map;
Expand All @@ -15,14 +15,14 @@
import net.minecraft.network.NetHandlerPlayServer;
import xonin.backhand.Backhand;

public final class BattlegearPacketHandler {
public final class BackhandPacketHandler {

public Map<String, AbstractMBPacket> map = new Hashtable<>();
public Map<String, AbstractPacket> map = new Hashtable<>();
public Map<String, FMLEventChannel> channels = new Hashtable<>();

public BattlegearPacketHandler() {
map.put(BattlegearSyncItemPacket.packetName, new BattlegearSyncItemPacket());
map.put(BattlegearAnimationPacket.packetName, new BattlegearAnimationPacket());
public BackhandPacketHandler() {
map.put(OffhandSyncItemPacket.packetName, new OffhandSyncItemPacket());
map.put(OffhandAnimationPacket.packetName, new OffhandAnimationPacket());
map.put(OffhandPlaceBlockPacket.packetName, new OffhandPlaceBlockPacket());
map.put(OffhandToServerPacket.packetName, new OffhandToServerPacket());
map.put(OffhandSwapPacket.packetName, new OffhandSwapPacket());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
Expand All @@ -12,18 +12,18 @@
* Date: 26/06/13
* Time: 1:47 PM
*/
public final class BattlegearAnimationPacket extends AbstractMBPacket {
public final class OffhandAnimationPacket extends AbstractPacket {

public static final String packetName = "MB2|Animation";
private EnumAnimations animation;
private String username;

public BattlegearAnimationPacket(EnumAnimations animation, EntityPlayer user) {
public OffhandAnimationPacket(EnumAnimations animation, EntityPlayer user) {
this.animation = animation;
this.username = user.getCommandSenderName();
}

public BattlegearAnimationPacket() {
public OffhandAnimationPacket() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
Expand All @@ -11,7 +11,7 @@
import net.minecraft.entity.projectile.EntityArrow;
import xonin.backhand.Backhand;

public class OffhandAttackPacket extends AbstractMBPacket {
public class OffhandAttackPacket extends AbstractPacket {
public static final String packetName = "MB2|Attack";
private String user;
private int targetId;
Expand Down Expand Up @@ -51,7 +51,7 @@ public void process(ByteBuf inputStream, EntityPlayer sender) {
return;
}
((IBattlePlayer) player).attackTargetEntityWithCurrentOffItem(target);
Backhand.packetHandler.sendPacketAround(player, 120, new BattlegearAnimationPacket(EnumAnimations.OffHandSwing, player).generatePacket());
Backhand.packetHandler.sendPacketAround(player, 120, new OffhandAnimationPacket(EnumAnimations.OffHandSwing, player).generatePacket());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

package mods.battlegear2.packet;
package xonin.backhand.packet;

import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerPlayer;
import net.tclproject.mysteriumlib.asm.fixes.MysteriumPatchesFixesO;
import xonin.backhand.Backhand;

public final class OffhandConfigSyncPacket extends AbstractMBPacket {
public final class OffhandConfigSyncPacket extends AbstractPacket {

public static final String packetName = "MB2|ConfigSync";
private EntityPlayer player;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.Event;
Expand All @@ -21,7 +21,7 @@
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;

public final class OffhandPlaceBlockPacket extends AbstractMBPacket{
public final class OffhandPlaceBlockPacket extends AbstractPacket {
public static final String packetName = "MB2|Place";
private int xPosition;
private int yPosition;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package mods.battlegear2.packet;
package xonin.backhand.packet;

import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
Expand All @@ -13,7 +13,7 @@
* Date: 26/06/13
* Time: 1:40 PM
*/
public final class OffhandSwapClientPacket extends AbstractMBPacket {
public final class OffhandSwapClientPacket extends AbstractPacket {

public static final String packetName = "MB2|SwapClient";
private String user;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
Expand All @@ -8,7 +8,7 @@
import net.minecraft.item.ItemStack;
import xonin.backhand.Backhand;

public class OffhandSwapPacket extends AbstractMBPacket {
public class OffhandSwapPacket extends AbstractPacket {
public static final String packetName = "MB2|Swap";

private String user;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
Expand All @@ -12,24 +12,24 @@
* Date: 26/06/13
* Time: 1:40 PM
*/
public final class BattlegearSyncItemPacket extends AbstractMBPacket {
public final class OffhandSyncItemPacket extends AbstractPacket {

public static final String packetName = "MB2|SyncItem";
private String user;
private InventoryPlayer inventory;
private EntityPlayer player;

public BattlegearSyncItemPacket(EntityPlayer player){
public OffhandSyncItemPacket(EntityPlayer player){
this(player.getCommandSenderName(), player.inventory, player);
}

public BattlegearSyncItemPacket(String user, InventoryPlayer inventory, EntityPlayer player) {
public OffhandSyncItemPacket(String user, InventoryPlayer inventory, EntityPlayer player) {
this.user = user;
this.inventory = inventory;
this.player = player;
}

public BattlegearSyncItemPacket() {
public OffhandSyncItemPacket() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import xonin.backhand.api.core.BattlegearUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

public class OffhandToServerPacket extends AbstractMBPacket {
public class OffhandToServerPacket extends AbstractPacket {
public static final String packetName = "MB2|OffhandToServer";

private ItemStack offhandItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package mods.battlegear2.packet;
package xonin.backhand.packet;

import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.tclproject.mysteriumlib.asm.fixes.MysteriumPatchesFixesO;

public class OffhandWorldHotswapPacket extends AbstractMBPacket {
public class OffhandWorldHotswapPacket extends AbstractPacket {
public static final String packetName = "MB2|WorldHotswap";

boolean ignoreSwitching;
Expand Down

0 comments on commit be00cc3

Please sign in to comment.