Fix for server/client setups
This commit is contained in:
parent
5eba2dd41b
commit
2872543c93
3 changed files with 19 additions and 18 deletions
|
@ -9,7 +9,6 @@ import com.seodisparate.TurnBasedMinecraft.common.Battle;
|
|||
import com.seodisparate.TurnBasedMinecraft.common.Combatant;
|
||||
import com.seodisparate.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleDecision;
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketHandler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
@ -271,20 +270,20 @@ public class BattleGui extends GuiScreen
|
|||
setState(MenuState.ATTACK_TARGET);
|
||||
break;
|
||||
case DEFEND:
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.DEFEND, 0));
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.DEFEND, 0));
|
||||
setState(MenuState.WAITING);
|
||||
break;
|
||||
case ITEM:
|
||||
setState(MenuState.ITEM_ACTION);
|
||||
break;
|
||||
case FLEE:
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.FLEE, 0));
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.FLEE, 0));
|
||||
setState(MenuState.WAITING);
|
||||
break;
|
||||
case ATTACK_TARGET:
|
||||
if(button instanceof EntitySelectionButton)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.ATTACK, ((EntitySelectionButton)button).entityID));
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.ATTACK, ((EntitySelectionButton)button).entityID));
|
||||
setState(MenuState.WAITING);
|
||||
}
|
||||
else
|
||||
|
@ -304,7 +303,7 @@ public class BattleGui extends GuiScreen
|
|||
case DO_ITEM_SWITCH:
|
||||
if(button instanceof ItemSelectionButton)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton)button).itemStackID));
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton)button).itemStackID));
|
||||
if(((ItemSelectionButton)button).itemStackID >= 0 && ((ItemSelectionButton)button).itemStackID < 9)
|
||||
{
|
||||
Minecraft.getMinecraft().player.inventory.currentItem = ((ItemSelectionButton)button).itemStackID;
|
||||
|
@ -319,7 +318,7 @@ public class BattleGui extends GuiScreen
|
|||
case DO_USE_ITEM:
|
||||
if(button instanceof ItemSelectionButton)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.USE_ITEM, ((ItemSelectionButton)button).itemStackID));
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.currentBattle.getId(), Battle.Decision.USE_ITEM, ((ItemSelectionButton)button).itemStackID));
|
||||
setState(MenuState.WAITING);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -13,7 +13,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleInfo;
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketHandler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -368,7 +367,7 @@ public class Battle
|
|||
PacketBattleInfo infoPacket = new PacketBattleInfo(getSideAIDs(), getSideBIDs(), timer);
|
||||
for(Combatant p : players.values())
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(infoPacket, (EntityPlayerMP)p.entity);
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(infoPacket, (EntityPlayerMP)p.entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +381,7 @@ public class Battle
|
|||
{
|
||||
if(p.entity.isEntityAlive())
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketBattleMessage(type, from, to, amount), (EntityPlayerMP)p.entity);
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketBattleMessage(type, from, to, amount), (EntityPlayerMP)p.entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +396,7 @@ public class Battle
|
|||
{
|
||||
if(p.entity.isEntityAlive())
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketBattleMessage(type, from, to, amount, custom), (EntityPlayerMP)p.entity);
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketBattleMessage(type, from, to, amount, custom), (EntityPlayerMP)p.entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -415,7 +414,7 @@ public class Battle
|
|||
removeQueue.add(c.entity.getEntityId());
|
||||
if(c.entity instanceof EntityPlayer)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, c.entity.getEntityId(), 0, 0), (EntityPlayerMP)c.entity);
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, c.entity.getEntityId(), 0, 0), (EntityPlayerMP)c.entity);
|
||||
}
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DIED, c.entity.getEntityId(), 0, 0);
|
||||
}
|
||||
|
@ -427,7 +426,7 @@ public class Battle
|
|||
removeQueue.add(c.entity.getEntityId());
|
||||
if(c.entity instanceof EntityPlayer)
|
||||
{
|
||||
PacketHandler.INSTANCE.sendTo(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, c.entity.getEntityId(), 0, 0), (EntityPlayerMP)c.entity);
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, c.entity.getEntityId(), 0, 0), (EntityPlayerMP)c.entity);
|
||||
}
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DIED, c.entity.getEntityId(), 0, 0);
|
||||
}
|
||||
|
@ -792,7 +791,7 @@ public class Battle
|
|||
{
|
||||
players.remove(next.entity.getEntityId());
|
||||
playerCount.decrementAndGet();
|
||||
PacketHandler.INSTANCE.sendTo(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, 0), (EntityPlayerMP)next.entity);
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, 0), (EntityPlayerMP)next.entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleDecisio
|
|||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleInfo;
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleRequestInfo;
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketHandler;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -18,6 +17,8 @@ import net.minecraftforge.fml.common.SidedProxy;
|
|||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
@Mod(modid = TurnBasedMinecraftMod.MODID, name = TurnBasedMinecraftMod.NAME, version = TurnBasedMinecraftMod.VERSION)
|
||||
|
@ -33,6 +34,8 @@ public class TurnBasedMinecraftMod
|
|||
public static final String CONFIG_INTERNAL_PATH = "/assets/TurnBasedMinecraft/" + CONFIG_FILENAME;
|
||||
|
||||
private static int CONFIG_FILE_VERSION = 0;
|
||||
|
||||
public static final SimpleNetworkWrapper NWINSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel("seodisparate.tbmc");
|
||||
|
||||
protected static Logger logger;
|
||||
protected static BattleManager battleManager;
|
||||
|
@ -61,22 +64,22 @@ public class TurnBasedMinecraftMod
|
|||
config = new Config(logger);
|
||||
|
||||
// register packets
|
||||
PacketHandler.INSTANCE.registerMessage(
|
||||
NWINSTANCE.registerMessage(
|
||||
PacketBattleInfo.HandlerBattleInfo.class,
|
||||
PacketBattleInfo.class,
|
||||
packetHandlerID++,
|
||||
Side.CLIENT);
|
||||
PacketHandler.INSTANCE.registerMessage(
|
||||
NWINSTANCE.registerMessage(
|
||||
PacketBattleRequestInfo.HandlerBattleRequestInfo.class,
|
||||
PacketBattleRequestInfo.class,
|
||||
packetHandlerID++,
|
||||
Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(
|
||||
NWINSTANCE.registerMessage(
|
||||
PacketBattleDecision.HandleBattleDecision.class,
|
||||
PacketBattleDecision.class,
|
||||
packetHandlerID++,
|
||||
Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(
|
||||
NWINSTANCE.registerMessage(
|
||||
PacketBattleMessage.HandlerBattleMessage.class,
|
||||
PacketBattleMessage.class,
|
||||
packetHandlerID++,
|
||||
|
|
Loading…
Reference in a new issue