import com.seodisparate.TurnBasedMinecraft.common.Battle;
import com.seodisparate.TurnBasedMinecraft.common.Combatant;
+import com.seodisparate.TurnBasedMinecraft.common.Config;
import com.seodisparate.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleDecision;
public class BattleGui extends GuiScreen
{
- public AtomicInteger timeRemaining;
- public long lastInstant;
- public long elapsedTime;
+ private AtomicInteger timeRemaining;
+ private long lastInstant;
+ private long elapsedTime;
private MenuState state;
private boolean stateChanged;
private String info;
public BattleGui()
{
- timeRemaining = new AtomicInteger(TurnBasedMinecraftMod.getBattleDurationSeconds());
+ timeRemaining = new AtomicInteger((int)(Config.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L));
lastInstant = System.nanoTime();
elapsedTime = 0;
state = MenuState.MAIN_MENU;
public void turnBegin()
{
- if(TurnBasedMinecraftMod.commonProxy.getLocalBattle() != null)
+ if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
{
- TurnBasedMinecraftMod.commonProxy.getLocalBattle().setState(Battle.State.ACTION);
+ TurnBasedMinecraftMod.proxy.getLocalBattle().setState(Battle.State.ACTION);
}
setState(MenuState.WAITING);
}
public void turnEnd()
{
- if(TurnBasedMinecraftMod.commonProxy.getLocalBattle() != null)
+ if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
{
- TurnBasedMinecraftMod.commonProxy.getLocalBattle().setState(Battle.State.DECISION);
+ TurnBasedMinecraftMod.proxy.getLocalBattle().setState(Battle.State.DECISION);
}
- timeRemaining.set(TurnBasedMinecraftMod.getBattleDurationSeconds());
+ timeRemaining.set(TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationSeconds());
elapsedTime = 0;
lastInstant = System.nanoTime();
setState(MenuState.MAIN_MENU);
{
case MAIN_MENU:
info = "What will you do?";
- buttonList.add(new GuiButton(ButtonAction.ATTACK.getValue(), width*3/7 - 25, height - 90, 50, 20, "Attack"));
- buttonList.add(new GuiButton(ButtonAction.DEFEND.getValue(), width*4/7 - 25, height - 90, 50, 20, "Defend"));
- buttonList.add(new GuiButton(ButtonAction.ITEM.getValue(), width*3/7 - 25, height - 70, 50, 20, "Item"));
- buttonList.add(new GuiButton(ButtonAction.FLEE.getValue(), width*4/7 - 25, height - 70, 50, 20, "Flee"));
+ buttonList.add(new GuiButton(ButtonAction.ATTACK.getValue(), width*3/7 - 25, 40, 50, 20, "Attack"));
+ buttonList.add(new GuiButton(ButtonAction.DEFEND.getValue(), width*4/7 - 25, 40, 50, 20, "Defend"));
+ buttonList.add(new GuiButton(ButtonAction.ITEM.getValue(), width*3/7 - 25, 60, 50, 20, "Item"));
+ buttonList.add(new GuiButton(ButtonAction.FLEE.getValue(), width*4/7 - 25, 60, 50, 20, "Flee"));
break;
case ATTACK_TARGET:
info = "Who will you attack?";
int y = 30;
- for(Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.commonProxy.getLocalBattle().getSideAEntrySet())
+ for(Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle().getSideAEntrySet())
{
if(e.getValue().entity != null)
{
y += 20;
}
y = 30;
- for(Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.commonProxy.getLocalBattle().getSideBEntrySet())
+ for(Map.Entry<Integer, Combatant> e : TurnBasedMinecraftMod.proxy.getLocalBattle().getSideBEntrySet())
{
if(e.getValue().entity != null)
{
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
- if(TurnBasedMinecraftMod.commonProxy.getLocalBattle() == null)
+ if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
{
drawHoveringText("Waiting...", width / 2 - 50, height / 2);
return;
}
- if(TurnBasedMinecraftMod.commonProxy.getLocalBattle().getState() == Battle.State.DECISION && timeRemaining.get() > 0)
+ if(TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION && timeRemaining.get() > 0)
{
long nextInstant = System.nanoTime();
elapsedTime += nextInstant - lastInstant;
setState(MenuState.ATTACK_TARGET);
break;
case DEFEND:
- TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.commonProxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0));
+ TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0));
setState(MenuState.WAITING);
break;
case ITEM:
setState(MenuState.ITEM_ACTION);
break;
case FLEE:
- TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.commonProxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0));
+ TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0));
setState(MenuState.WAITING);
break;
case ATTACK_TARGET:
if(button instanceof EntitySelectionButton)
{
- TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.commonProxy.getLocalBattle().getId(), Battle.Decision.ATTACK, ((EntitySelectionButton)button).entityID));
+ TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.ATTACK, ((EntitySelectionButton)button).entityID));
setState(MenuState.WAITING);
}
else
case DO_ITEM_SWITCH:
if(button instanceof ItemSelectionButton)
{
- TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.commonProxy.getLocalBattle().getId(), Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton)button).itemStackID));
+ TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().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;
case DO_USE_ITEM:
if(button instanceof ItemSelectionButton)
{
- TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.commonProxy.getLocalBattle().getId(), Battle.Decision.USE_ITEM, ((ItemSelectionButton)button).itemStackID));
+ TurnBasedMinecraftMod.NWINSTANCE.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.USE_ITEM, ((ItemSelectionButton)button).itemStackID));
setState(MenuState.WAITING);
}
else
super.keyTyped(typedChar, keyCode);
}
}
+
+ public void setTimeRemaining(int remaining)
+ {
+ timeRemaining.set(remaining);
+ }
}
package com.seodisparate.TurnBasedMinecraft.client;
-import org.apache.logging.log4j.Logger;
-
import com.seodisparate.TurnBasedMinecraft.common.Battle;
import com.seodisparate.TurnBasedMinecraft.common.CommonProxy;
-import com.seodisparate.TurnBasedMinecraft.common.Config;
-import com.seodisparate.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
public class ClientProxy extends CommonProxy
{
- private BattleGui battleGui;
- private BattleMusic battleMusic;
- private Logger logger;
- private Config config;
- private int battleMusicCount;
- private int sillyMusicCount;
- private Battle localBattle;
+ private BattleGui battleGui = null;
+ private BattleMusic battleMusic = null;
+ private int battleMusicCount = 0;
+ private int sillyMusicCount = 0;
+ private Battle localBattle = null;
@Override
public void initialize()
{
+ super.initialize();
battleGui = new BattleGui();
battleMusic = null; // will be initialized in postInit()
battleMusicCount = 0;
@Override
public void setBattleGuiTime(int timeRemaining)
{
- battleGui.timeRemaining.set(timeRemaining);
+ battleGui.setTimeRemaining(timeRemaining);
}
@Override
@Override
public void postInit()
{
- battleMusic = new BattleMusic(logger);
- }
-
- @Override
- public void setLogger(Logger logger)
- {
- this.logger = logger;
+ super.postInit();
+ battleMusic = new BattleMusic(getLogger());
}
@Override
{
return;
}
- if(type == null || type.isEmpty() || config.isBattleMusicType(type))
+ if(type == null || type.isEmpty() || getConfig().isBattleMusicType(type))
{
++battleMusicCount;
}
- else if(config.isSillyMusicType(type))
+ else if(getConfig().isSillyMusicType(type))
{
++sillyMusicCount;
}
{
return;
}
- if(type == null || type.isEmpty() || config.isBattleMusicType(type))
+ if(type == null || type.isEmpty() || getConfig().isBattleMusicType(type))
{
--battleMusicCount;
}
- else if(config.isSillyMusicType(type))
+ else if(getConfig().isSillyMusicType(type))
{
--sillyMusicCount;
}
checkBattleTypes();
}
- @Override
- public void setConfig(Config config)
- {
- this.config = config;
- }
-
@Override
public void displayString(String message)
{
percentage = 100.0f * (float)sillyMusicCount / (float)(sillyMusicCount + battleMusicCount);
}
- if(percentage >= (float)TurnBasedMinecraftMod.getConfig().getSillyMusicThreshold())
+ if(percentage >= (float)getConfig().getSillyMusicThreshold())
{
if(battleMusic.isPlaying())
{
{
return false;
}
- else if(event.getSource().getTrueSource().equals(TurnBasedMinecraftMod.attackingEntity))
+ else if(event.getSource().getTrueSource().equals(TurnBasedMinecraftMod.proxy.getAttackingEntity()))
{
return true;
}
Queue<AttackerViaBow> removeQueue = new ArrayDeque<AttackerViaBow>();
final long now = System.nanoTime();
boolean isValid = false;
- synchronized(TurnBasedMinecraftMod.attackerViaBow)
+ synchronized(TurnBasedMinecraftMod.proxy.getAttackerViaBowSet())
{
- for(AttackerViaBow attacker : TurnBasedMinecraftMod.attackerViaBow)
+ for(AttackerViaBow attacker : TurnBasedMinecraftMod.proxy.getAttackerViaBowSet())
{
if(now - attacker.attackTime >= AttackerViaBow.ATTACK_TIMEOUT)
{
removeQueue.add(attacker);
if(!isValid)
{
- Battle b = TurnBasedMinecraftMod.battleManager.getBattleByID(attacker.battleID);
+ Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(attacker.battleID);
if(b != null)
{
b.sendMessageToAllPlayers(PacketBattleMessage.MessageType.ARROW_HIT, attacker.entity.getEntityId(), event.getEntity().getEntityId(), 0);
}
for(AttackerViaBow next = removeQueue.poll(); next != null; next = removeQueue.poll())
{
- TurnBasedMinecraftMod.attackerViaBow.remove(next);
+ TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().remove(next);
}
}
return isValid;
return;
}
- if(!isAttackerValid(event) && event.getEntity() != null && event.getSource().getTrueSource() != null && TurnBasedMinecraftMod.battleManager.checkAttack(event))
+ if(!isAttackerValid(event) && event.getEntity() != null && event.getSource().getTrueSource() != null && TurnBasedMinecraftMod.proxy.getBattleManager().checkAttack(event))
{
-// TurnBasedMinecraftMod.logger.debug("Canceled LivingAttackEvent between " + TurnBasedMinecraftMod.attackingEntity + " and " + event.getEntity());
+// TurnBasedMinecraftMod.logger.debug("Canceled LivingAttackEvent between " + TurnBasedMinecraftMod.commonProxy.getAttackingEntity() + " and " + event.getEntity());
event.setCanceled(true);
}
else
{
// TurnBasedMinecraftMod.logger.debug("Did not cancel attack");
}
- if(TurnBasedMinecraftMod.attackingDamage < (int) event.getAmount())
+ if(TurnBasedMinecraftMod.proxy.getAttackingDamage() < (int) event.getAmount())
{
- TurnBasedMinecraftMod.attackingDamage = (int) event.getAmount();
+ TurnBasedMinecraftMod.proxy.setAttackingDamage((int) event.getAmount());
}
}
}
{
for(Entity e : sideA)
{
- EntityInfo entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(e);
- if(entityInfo == null && !(e instanceof EntityPlayer) && TurnBasedMinecraftMod.commonProxy.isServerRunning())
+ EntityInfo entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
+ if(entityInfo == null && !(e instanceof EntityPlayer) && TurnBasedMinecraftMod.proxy.isServerRunning())
{
continue;
}
playerCount.incrementAndGet();
players.put(e.getEntityId(), newCombatant);
}
- if(TurnBasedMinecraftMod.config.isFreezeCombatantsEnabled())
+ if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{
newCombatant.x = e.posX;
newCombatant.z = e.posZ;
{
for(Entity e : sideB)
{
- EntityInfo entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(e);
- if(entityInfo == null && !(e instanceof EntityPlayer) && TurnBasedMinecraftMod.commonProxy.isServerRunning())
+ EntityInfo entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
+ if(entityInfo == null && !(e instanceof EntityPlayer) && TurnBasedMinecraftMod.proxy.isServerRunning())
{
continue;
}
playerCount.incrementAndGet();
players.put(e.getEntityId(), newCombatant);
}
- if(TurnBasedMinecraftMod.config.isFreezeCombatantsEnabled())
+ if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{
newCombatant.x = e.posX;
newCombatant.z = e.posZ;
lastInstant = System.nanoTime();
state = State.DECISION;
undecidedCount.set(playerCount.get());
- timer = TurnBasedMinecraftMod.getBattleDurationNanos();
+ timer = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos();
battleEnded = false;
notifyPlayersBattleInfo();
public void addCombatantToSideA(Entity e)
{
- EntityInfo entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(e);
- if(entityInfo == null && !(e instanceof EntityPlayer) && TurnBasedMinecraftMod.commonProxy.isServerRunning())
+ EntityInfo entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
+ if(entityInfo == null && !(e instanceof EntityPlayer) && TurnBasedMinecraftMod.proxy.isServerRunning())
{
return;
}
undecidedCount.incrementAndGet();
}
}
- if(TurnBasedMinecraftMod.config.isFreezeCombatantsEnabled())
+ if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{
newCombatant.x = e.posX;
newCombatant.z = e.posZ;
public void addCombatantToSideB(Entity e)
{
- EntityInfo entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(e);
- if(entityInfo == null && !(e instanceof EntityPlayer) && TurnBasedMinecraftMod.commonProxy.isServerRunning())
+ EntityInfo entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(e);
+ if(entityInfo == null && !(e instanceof EntityPlayer) && TurnBasedMinecraftMod.proxy.isServerRunning())
{
return;
}
undecidedCount.incrementAndGet();
}
}
- if(TurnBasedMinecraftMod.config.isFreezeCombatantsEnabled())
+ if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{
newCombatant.x = e.posX;
newCombatant.z = e.posZ;
combatantsChanged = true;
}
}
- if(TurnBasedMinecraftMod.config.isFreezeCombatantsEnabled())
+ if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{
enforceFreezePositions();
}
}
}
state = State.ACTION;
- timer = TurnBasedMinecraftMod.getBattleDurationNanos();
+ timer = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos();
sendMessageToAllPlayers(PacketBattleMessage.MessageType.TURN_BEGIN, 0, 0, 0);
turnOrderQueue.clear();
for(Combatant c : sideA.values())
final Entity targetEntity = target.entity;
final float yawDirection = Utility.yawDirection(next.entity.posX, next.entity.posZ, target.entity.posX, target.entity.posZ);
final float pitchDirection = Utility.pitchDirection(next.entity.posX, next.entity.posY, next.entity.posZ, target.entity.posX, target.entity.posY, target.entity.posZ);
- if(TurnBasedMinecraftMod.config.isFreezeCombatantsEnabled())
+ if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{
next.yaw = yawDirection;
next.pitch = pitchDirection;
// have player look at attack target
((EntityPlayerMP)nextEntity).connection.setPlayerLocation(nextEntity.posX, nextEntity.posY, nextEntity.posZ, yawDirection, pitchDirection);
ItemBow itemBow = (ItemBow)heldItemStack.getItem();
- synchronized(TurnBasedMinecraftMod.attackerViaBow)
+ synchronized(TurnBasedMinecraftMod.proxy.getAttackerViaBowSet())
{
- TurnBasedMinecraftMod.attackerViaBow.add(new AttackerViaBow(nextEntity, getId()));
+ TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId()));
}
itemBow.onPlayerStoppedUsing(((EntityPlayer)nextEntity).getHeldItemMainhand(), nextEntity.getEntityWorld(), (EntityLivingBase)nextEntity, (int)(Math.random() * (itemBow.getMaxItemUseDuration(heldItemStack)) / 3));
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getEntityId(), targetEntity.getEntityId(), 0);
}
continue;
}
- int hitChance = TurnBasedMinecraftMod.config.getPlayerAttackProbability();
+ int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
if(target.entity instanceof EntityPlayer)
{
- hitChance -= TurnBasedMinecraftMod.config.getPlayerEvasion();
+ hitChance -= TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion();
}
else
{
hitChance -= target.entityInfo.evasion;
}
- if(hitChance < TurnBasedMinecraftMod.config.getMinimumHitPercentage())
+ if(hitChance < TurnBasedMinecraftMod.proxy.getConfig().getMinimumHitPercentage())
{
- hitChance = TurnBasedMinecraftMod.config.getMinimumHitPercentage();
+ hitChance = TurnBasedMinecraftMod.proxy.getConfig().getMinimumHitPercentage();
}
if((int)(Math.random() * 100) < hitChance)
{
final EntityInfo targetEntityInfo = target.entityInfo;
final float yawDirection = Utility.yawDirection(next.entity.posX, next.entity.posZ, target.entity.posX, target.entity.posZ);
final float pitchDirection = Utility.pitchDirection(next.entity.posX, next.entity.posY, next.entity.posZ, target.entity.posX, target.entity.posY, target.entity.posZ);
- if(TurnBasedMinecraftMod.config.isFreezeCombatantsEnabled())
+ if(TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled())
{
next.yaw = yawDirection;
next.pitch = pitchDirection;
next.entity.getServer().addScheduledTask(() -> {
// have player look at attack target
((EntityPlayerMP)nextEntity).connection.setPlayerLocation(nextEntity.posX, nextEntity.posY, nextEntity.posZ, yawDirection, pitchDirection);
- TurnBasedMinecraftMod.attackingEntity = nextEntity;
- TurnBasedMinecraftMod.attackingDamage = 0;
+ TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
+ TurnBasedMinecraftMod.proxy.setAttackingDamage(0);
((EntityPlayer)nextEntity).attackTargetEntityWithCurrentItem(targetEntity);
- TurnBasedMinecraftMod.attackingEntity = null;
- sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getEntityId(), targetEntity.getEntityId(), TurnBasedMinecraftMod.attackingDamage);
+ TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
+ sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getEntityId(), targetEntity.getEntityId(), TurnBasedMinecraftMod.proxy.getAttackingDamage());
if(!(targetEntity instanceof EntityPlayer) && targetEntityInfo.defenseDamage > 0)
{
if((int)(Math.random() * 100) < targetEntityInfo.defenseDamageProbability)
{
// defense damage
DamageSource defenseDamageSource = DamageSource.causeMobDamage((EntityLivingBase)targetEntity);
- TurnBasedMinecraftMod.attackingEntity = targetEntity;
+ TurnBasedMinecraftMod.proxy.setAttackingEntity(targetEntity);
nextEntity.attackEntityFrom(defenseDamageSource, targetEntityInfo.defenseDamage);
- TurnBasedMinecraftMod.attackingEntity = null;
+ TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENSE_DAMAGE, targetEntity.getEntityId(), nextEntity.getEntityId(), targetEntityInfo.defenseDamage);
}
}
int hitChance = next.entityInfo.attackProbability;
if(target.entity instanceof EntityPlayer)
{
- hitChance -= TurnBasedMinecraftMod.config.getPlayerEvasion();
+ hitChance -= TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion();
}
else
{
hitChance -= target.entityInfo.evasion;
}
- if(hitChance < TurnBasedMinecraftMod.config.getMinimumHitPercentage())
+ if(hitChance < TurnBasedMinecraftMod.proxy.getConfig().getMinimumHitPercentage())
{
- hitChance = TurnBasedMinecraftMod.config.getMinimumHitPercentage();
+ hitChance = TurnBasedMinecraftMod.proxy.getConfig().getMinimumHitPercentage();
}
if((int)(Math.random() * 100) < hitChance)
{
final EntityInfo targetEntityInfo = target.entityInfo;
final int finalDamageAmount = damageAmount;
next.entity.getServer().addScheduledTask(() -> {
- TurnBasedMinecraftMod.attackingEntity = nextEntity;
+ TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
targetEntity.attackEntityFrom(damageSource, finalDamageAmount);
- TurnBasedMinecraftMod.attackingEntity = null;
+ TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getEntityId(), targetEntity.getEntityId(), finalDamageAmount);
if(!(targetEntity instanceof EntityPlayer) && targetEntityInfo.defenseDamage > 0)
{
{
// defense damage
DamageSource defenseDamageSource = DamageSource.causeMobDamage((EntityLivingBase)targetEntity);
- TurnBasedMinecraftMod.attackingEntity = targetEntity;
+ TurnBasedMinecraftMod.proxy.setAttackingEntity(targetEntity);
nextEntity.attackEntityFrom(defenseDamageSource, targetEntityInfo.defenseDamage);
- TurnBasedMinecraftMod.attackingEntity = null;
+ TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENSE_DAMAGE, targetEntity.getEntityId(), nextEntity.getEntityId(), targetEntityInfo.defenseDamage);
}
}
}
break;
case DEFEND:
- next.remainingDefenses = TurnBasedMinecraftMod.config.getDefenseDuration();
+ next.remainingDefenses = TurnBasedMinecraftMod.proxy.getConfig().getDefenseDuration();
sendMessageToAllPlayers(PacketBattleMessage.MessageType.DEFENDING, next.entity.getEntityId(), 0, 0);
break;
case FLEE:
{
if(c.entity instanceof EntityPlayer)
{
- if(TurnBasedMinecraftMod.config.getPlayerSpeed() > fastestEnemySpeed)
+ if(TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed() > fastestEnemySpeed)
{
- fastestEnemySpeed = TurnBasedMinecraftMod.config.getPlayerSpeed();
+ fastestEnemySpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
}
}
else
{
if(c.entity instanceof EntityPlayer)
{
- if(TurnBasedMinecraftMod.config.getPlayerSpeed() > fastestEnemySpeed)
+ if(TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed() > fastestEnemySpeed)
{
- fastestEnemySpeed = TurnBasedMinecraftMod.config.getPlayerSpeed();
+ fastestEnemySpeed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
}
}
else
int fleeProbability = 0;
if(next.entity instanceof EntityPlayer)
{
- if(fastestEnemySpeed >= TurnBasedMinecraftMod.config.getPlayerSpeed())
+ if(fastestEnemySpeed >= TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed())
{
- fleeProbability = TurnBasedMinecraftMod.config.getFleeBadProbability();
+ fleeProbability = TurnBasedMinecraftMod.proxy.getConfig().getFleeBadProbability();
}
else
{
- fleeProbability = TurnBasedMinecraftMod.config.getFleeGoodProbability();
+ fleeProbability = TurnBasedMinecraftMod.proxy.getConfig().getFleeGoodProbability();
}
}
else
{
if(fastestEnemySpeed >= next.entityInfo.speed)
{
- fleeProbability = TurnBasedMinecraftMod.config.getFleeBadProbability();
+ fleeProbability = TurnBasedMinecraftMod.proxy.getConfig().getFleeBadProbability();
}
else
{
- fleeProbability = TurnBasedMinecraftMod.config.getFleeGoodProbability();
+ fleeProbability = TurnBasedMinecraftMod.proxy.getConfig().getFleeGoodProbability();
}
}
if((int)(Math.random() * 100) < fleeProbability)
public boolean checkAttack(final LivingAttackEvent event)
{
// verify that both entities are EntityPlayer and not in creative or has a corresponding EntityInfo
- if(!((event.getEntity() instanceof EntityPlayer && !((EntityPlayer)event.getEntity()).isCreative()) || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getEntity().getClass().getName()) != null)
- || !((event.getSource().getTrueSource() instanceof EntityPlayer && !((EntityPlayer)event.getSource().getTrueSource()).isCreative()) || TurnBasedMinecraftMod.config.getEntityInfoReference(event.getSource().getTrueSource().getClass().getName()) != null))
+ if(!((event.getEntity() instanceof EntityPlayer && !((EntityPlayer)event.getEntity()).isCreative()) || TurnBasedMinecraftMod.proxy.getConfig().getEntityInfoReference(event.getEntity().getClass().getName()) != null)
+ || !((event.getSource().getTrueSource() instanceof EntityPlayer && !((EntityPlayer)event.getSource().getTrueSource()).isCreative()) || TurnBasedMinecraftMod.proxy.getConfig().getEntityInfoReference(event.getSource().getTrueSource().getClass().getName()) != null))
{
return false;
}
// check if ignore battle in config
- EntityInfo entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(event.getEntity());
- if(entityInfo != null && (TurnBasedMinecraftMod.config.isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
+ EntityInfo entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getEntity());
+ if(entityInfo != null && (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
{
// attacked entity ignores battle
for(Battle b : battleMap.values())
// logger.debug("Attack Not Canceled: attacked ignores battle");
return false;
}
- entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(event.getSource().getTrueSource());
- if(entityInfo != null && (TurnBasedMinecraftMod.config.isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
+ entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getSource().getTrueSource());
+ if(entityInfo != null && (TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(entityInfo.category) || entityInfo.ignoreBattle))
{
// attacker entity ignores battle
for(Battle b : battleMap.values())
}
// at this point only one entity is in battle, so add entity to other side
- if(battle.getSize() >= TurnBasedMinecraftMod.config.getMaxInBattle())
+ if(battle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle())
{
// battle limit reached, cannot add to battle
return true;
}
if(isHaste && !isSlow)
{
- c0.entityInfo.speed = TurnBasedMinecraftMod.config.getPlayerHasteSpeed();
+ c0.entityInfo.speed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerHasteSpeed();
}
else if(isSlow && !isHaste)
{
- c0.entityInfo.speed = TurnBasedMinecraftMod.config.getPlayerSlowSpeed();
+ c0.entityInfo.speed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSlowSpeed();
}
else
{
- c0.entityInfo.speed = TurnBasedMinecraftMod.config.getPlayerSpeed();
+ c0.entityInfo.speed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
}
}
}
if(isHaste && !isSlow)
{
- c1.entityInfo.speed = TurnBasedMinecraftMod.config.getPlayerHasteSpeed();
+ c1.entityInfo.speed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerHasteSpeed();
}
else if(isSlow && !isHaste)
{
- c1.entityInfo.speed = TurnBasedMinecraftMod.config.getPlayerSlowSpeed();
+ c1.entityInfo.speed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSlowSpeed();
}
else
{
- c1.entityInfo.speed = TurnBasedMinecraftMod.config.getPlayerSpeed();
+ c1.entityInfo.speed = TurnBasedMinecraftMod.proxy.getConfig().getPlayerSpeed();
}
}
package com.seodisparate.TurnBasedMinecraft.common;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.logging.log4j.Logger;
import net.minecraft.entity.Entity;
public class CommonProxy
{
- public void initialize() {}
+ private Set<AttackerViaBow> attackerViaBow = null;
+ private BattleManager battleManager = null;
+ private Entity attackingEntity = null;
+ private int attackingDamage = 0;
+ private Config config = null;
+ private Logger logger = null;
+
+ public void initialize()
+ {
+ attackerViaBow = new HashSet<AttackerViaBow>();
+ }
- public boolean initializeBattleManager()
+ public final boolean initializeBattleManager()
{
- if(TurnBasedMinecraftMod.battleManager == null)
+ if(battleManager == null)
{
- TurnBasedMinecraftMod.battleManager = new BattleManager(TurnBasedMinecraftMod.logger);
+ battleManager = new BattleManager(TurnBasedMinecraftMod.logger);
return true;
}
return false;
}
- public boolean cleanupBattleManager ()
+ public final boolean cleanupBattleManager ()
{
- if(TurnBasedMinecraftMod.battleManager != null)
+ if(battleManager != null)
{
- TurnBasedMinecraftMod.battleManager.cleanup();
- TurnBasedMinecraftMod.battleManager = null;
+ battleManager.cleanup();
+ battleManager = null;
return true;
}
return false;
public void battleEnded() {}
- public void postInit() {}
+ public void postInit()
+ {
+ config = new Config(logger);
+ }
- public void setLogger(Logger logger) {}
+ public final void setLogger(Logger logger)
+ {
+ this.logger = logger;
+ }
public void playBattleMusic() {}
public void typeLeftBattle(String type) {}
- public void setConfig(Config config) {}
-
public void displayString(String message) {}
public Entity getEntityByID(int id)
return FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getEntityByID(id);
}
- public boolean isServerRunning()
+ public final boolean isServerRunning()
{
- return TurnBasedMinecraftMod.battleManager != null;
+ return battleManager != null;
}
public Battle getLocalBattle()
}
public void createLocalBattle(int id) {}
+
+ public final Set<AttackerViaBow> getAttackerViaBowSet()
+ {
+ return attackerViaBow;
+ }
+
+ public final BattleManager getBattleManager()
+ {
+ return battleManager;
+ }
+
+ protected final void setAttackingEntity(Entity entity)
+ {
+ attackingEntity = entity;
+ }
+
+ protected final Entity getAttackingEntity()
+ {
+ return attackingEntity;
+ }
+
+ protected final void setAttackingDamage(int damage)
+ {
+ attackingDamage = damage;
+ }
+
+ protected final int getAttackingDamage()
+ {
+ return attackingDamage;
+ }
+
+ protected final Logger getLogger()
+ {
+ return logger;
+ }
+
+ public final Config getConfig()
+ {
+ return config;
+ }
}
public class Config
{
+ public static final long BATTLE_DECISION_DURATION_NANO_MIN = 5000000000L;
+ public static final long BATTLE_DECISION_DURATION_NANO_MAX = 60000000000L;
+ public static final long BATTLE_DECISION_DURATION_NANO_DEFAULT = 15000000000L;
+ private long battleDecisionDurationNanos = BATTLE_DECISION_DURATION_NANO_DEFAULT;
private Map<String, EntityInfo> entityInfoMap;
private Set<String> ignoreBattleTypes;
private Logger logger;
private Set<String> musicSillyTypes;
private boolean freezeCombatantsInBattle = false;
private int sillyMusicThreshold = 40;
+ private int configVersion = 0;
public Config(Logger logger)
{
}
else
{
- TurnBasedMinecraftMod.setConfigVersion(internalVersion);
+ configVersion = internalVersion;
}
try
}
int configVersion = getConfigFileVersion(configFile);
- if(configVersion < TurnBasedMinecraftMod.getConfigVersion())
+ if(configVersion < this.configVersion)
{
logger.warn("Config file " + TurnBasedMinecraftMod.CONFIG_FILENAME + " is older version, renaming...");
moveOldConfig();
}
else if(xmlReader.getLocalName().equals("BattleTurnTimeSeconds"))
{
- int seconds = TurnBasedMinecraftMod.getBattleDurationSeconds();
try
{
- seconds = Integer.parseInt(xmlReader.getElementText());
- TurnBasedMinecraftMod.setBattleDurationSeconds(seconds);
+ int seconds = Integer.parseInt(xmlReader.getElementText());
+ battleDecisionDurationNanos = (long)(seconds) * 1000000000L;
+ if(battleDecisionDurationNanos < BATTLE_DECISION_DURATION_NANO_MIN)
+ {
+ battleDecisionDurationNanos = BATTLE_DECISION_DURATION_NANO_MIN;
+ }
+ else if(battleDecisionDurationNanos > BATTLE_DECISION_DURATION_NANO_MAX)
+ {
+ battleDecisionDurationNanos = BATTLE_DECISION_DURATION_NANO_MAX;
+ }
} catch (Throwable t)
{
logger.warn("Unable to get value for \"BattleTurnTimeSeconds\" from config, using default");
- TurnBasedMinecraftMod.setBattleDurationSeconds(TurnBasedMinecraftMod.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L);
+ battleDecisionDurationNanos = BATTLE_DECISION_DURATION_NANO_DEFAULT;
}
}
else if(xmlReader.getLocalName().equals("SillyMusicThreshold"))
{
return sillyMusicThreshold;
}
+
+ public int getConfigVersion()
+ {
+ return configVersion;
+ }
+
+ public long getDecisionDurationNanos()
+ {
+ return battleDecisionDurationNanos;
+ }
+
+ public int getDecisionDurationSeconds()
+ {
+ return (int)(battleDecisionDurationNanos / 1000000000L);
+ }
}
package com.seodisparate.TurnBasedMinecraft.common;
-import java.util.HashSet;
-import java.util.Set;
-
import org.apache.logging.log4j.Logger;
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleDecision;
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleMessage;
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleRequestInfo;
-import net.minecraft.entity.Entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/";
public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/";
- 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;
private static int packetHandlerID = 0;
- protected static Entity attackingEntity;
- protected static int attackingDamage = 0;
- protected static Set<AttackerViaBow> attackerViaBow;
- protected static Config config;
- public static final long BATTLE_DECISION_DURATION_NANO_MIN = 5000000000L;
- public static final long BATTLE_DECISION_DURATION_NANO_MAX = 60000000000L;
- public static final long BATTLE_DECISION_DURATION_NANO_DEFAULT = 15000000000L;
- private static long BATTLE_DECISION_DURATION_NANOSECONDS = BATTLE_DECISION_DURATION_NANO_DEFAULT;
@SidedProxy(modId=MODID, serverSide="com.seodisparate.TurnBasedMinecraft.common.CommonProxy", clientSide="com.seodisparate.TurnBasedMinecraft.client.ClientProxy")
- public static CommonProxy commonProxy;
+ public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
+ proxy.setLogger(logger);
}
@EventHandler
public void init(FMLInitializationEvent event)
{
- commonProxy.initialize();
- battleManager = null;
- attackerViaBow = new HashSet<AttackerViaBow>();
- commonProxy.setLogger(logger);
+ proxy.initialize();
// register packets
NWINSTANCE.registerMessage(
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
- config = new Config(logger);
- commonProxy.setConfig(config);
- commonProxy.postInit();
+ proxy.postInit();
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
logger.debug("About to initialize BattleManager");
- if(commonProxy.initializeBattleManager())
+ if(proxy.initializeBattleManager())
{
logger.debug("Initialized BattleManager");
}
public void serverStopping(FMLServerStoppingEvent event)
{
logger.debug("About to cleanup BattleManager");
- if(commonProxy.cleanupBattleManager())
+ if(proxy.cleanupBattleManager())
{
logger.debug("Cleaned up BattleManager");
}
}
-
- public static BattleManager getBattleManager()
- {
- return battleManager;
- }
-
- public static void setConfigVersion(int version)
- {
- CONFIG_FILE_VERSION = version;
- }
-
- public static int getConfigVersion()
- {
- return CONFIG_FILE_VERSION;
- }
-
- public static long getBattleDurationNanos()
- {
- return BATTLE_DECISION_DURATION_NANOSECONDS;
- }
-
- public static int getBattleDurationSeconds()
- {
- return (int)(BATTLE_DECISION_DURATION_NANOSECONDS / 1000000000L);
- }
-
- protected static void setBattleDurationSeconds(long seconds)
- {
- BATTLE_DECISION_DURATION_NANOSECONDS = seconds * 1000000000L;
- if(BATTLE_DECISION_DURATION_NANOSECONDS < BATTLE_DECISION_DURATION_NANO_MIN)
- {
- BATTLE_DECISION_DURATION_NANOSECONDS = BATTLE_DECISION_DURATION_NANO_MIN;
- }
- else if(BATTLE_DECISION_DURATION_NANOSECONDS > BATTLE_DECISION_DURATION_NANO_MAX)
- {
- BATTLE_DECISION_DURATION_NANOSECONDS = BATTLE_DECISION_DURATION_NANO_MAX;
- }
- }
-
- public static Config getConfig()
- {
- return config;
- }
}
@Override
public IMessage onMessage(PacketBattleDecision message, MessageContext ctx)
{
- Battle b = TurnBasedMinecraftMod.getBattleManager().getBattleByID(message.battleID);
+ Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(message.battleID);
if(b != null)
{
EntityPlayerMP player = ctx.getServerHandler().player;
{
sideA = new ArrayList<Integer>();
sideB = new ArrayList<Integer>();
- decisionNanos = TurnBasedMinecraftMod.getBattleDurationNanos();
+ decisionNanos = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos();
}
public PacketBattleInfo(Collection<Integer> sideA, Collection<Integer> sideB, long decisionNanos)
@Override
public IMessage onMessage(PacketBattleInfo message, MessageContext ctx)
{
- if(TurnBasedMinecraftMod.commonProxy.getLocalBattle() == null)
+ if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
{
return null;
}
- TurnBasedMinecraftMod.commonProxy.getLocalBattle().clearCombatants();
+ TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
for(Integer id : message.sideA)
{
- TurnBasedMinecraftMod.commonProxy.getLocalBattle().addCombatantToSideA(Minecraft.getMinecraft().world.getEntityByID(id));
+ TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(Minecraft.getMinecraft().world.getEntityByID(id));
}
for(Integer id : message.sideB)
{
- TurnBasedMinecraftMod.commonProxy.getLocalBattle().addCombatantToSideB(Minecraft.getMinecraft().world.getEntityByID(id));
+ TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(Minecraft.getMinecraft().world.getEntityByID(id));
}
- TurnBasedMinecraftMod.commonProxy.setBattleGuiTime((int)(message.decisionNanos / 1000000000L));
- TurnBasedMinecraftMod.commonProxy.setBattleGuiBattleChanged();
+ TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(message.decisionNanos / 1000000000L));
+ TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
return null;
}
}
import java.util.HashMap;
import java.util.Map;
-import com.seodisparate.TurnBasedMinecraft.common.Battle;
import com.seodisparate.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import io.netty.buffer.ByteBuf;
@Override
public IMessage onMessage(PacketBattleMessage message, MessageContext ctx)
{
- Entity fromEntity = TurnBasedMinecraftMod.commonProxy.getEntityByID(message.entityIDFrom);
+ Entity fromEntity = TurnBasedMinecraftMod.proxy.getEntityByID(message.entityIDFrom);
String from = "Unknown";
if(fromEntity != null)
{
from = fromEntity.getName();
}
}
- else if(TurnBasedMinecraftMod.commonProxy.getLocalBattle() != null)
+ else if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
{
- fromEntity = TurnBasedMinecraftMod.commonProxy.getLocalBattle().getCombatantEntity(message.entityIDFrom);
+ fromEntity = TurnBasedMinecraftMod.proxy.getLocalBattle().getCombatantEntity(message.entityIDFrom);
if(fromEntity != null)
{
if(fromEntity.hasCustomName())
}
}
}
- Entity toEntity = TurnBasedMinecraftMod.commonProxy.getEntityByID(message.entityIDTo);
+ Entity toEntity = TurnBasedMinecraftMod.proxy.getEntityByID(message.entityIDTo);
String to = "Unknown";
if(toEntity != null)
{
to = toEntity.getName();
}
}
- else if(TurnBasedMinecraftMod.commonProxy.getLocalBattle() != null)
+ else if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
{
- toEntity = TurnBasedMinecraftMod.commonProxy.getLocalBattle().getCombatantEntity(message.entityIDTo);
+ toEntity = TurnBasedMinecraftMod.proxy.getLocalBattle().getCombatantEntity(message.entityIDTo);
if(toEntity != null)
{
if(toEntity.hasCustomName())
switch(message.messageType)
{
case ENTERED:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " entered battle!");
- if(TurnBasedMinecraftMod.commonProxy.getLocalBattle() == null || TurnBasedMinecraftMod.commonProxy.getLocalBattle().getId() != message.amount)
+ TurnBasedMinecraftMod.proxy.displayString(from + " entered battle!");
+ if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null || TurnBasedMinecraftMod.proxy.getLocalBattle().getId() != message.amount)
{
- TurnBasedMinecraftMod.commonProxy.createLocalBattle(message.amount);
+ TurnBasedMinecraftMod.proxy.createLocalBattle(message.amount);
}
- TurnBasedMinecraftMod.commonProxy.battleStarted();
- TurnBasedMinecraftMod.commonProxy.typeEnteredBattle(message.custom);
+ TurnBasedMinecraftMod.proxy.battleStarted();
+ TurnBasedMinecraftMod.proxy.typeEnteredBattle(message.custom);
break;
case FLEE:
if(message.amount != 0)
{
- TurnBasedMinecraftMod.commonProxy.displayString(from + " fled battle!");
- TurnBasedMinecraftMod.commonProxy.typeLeftBattle(message.custom);
+ TurnBasedMinecraftMod.proxy.displayString(from + " fled battle!");
+ TurnBasedMinecraftMod.proxy.typeLeftBattle(message.custom);
}
else
{
- TurnBasedMinecraftMod.commonProxy.displayString(from + " tried to flee battle but failed!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " tried to flee battle but failed!");
}
break;
case DIED:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " died in battle!");
- TurnBasedMinecraftMod.commonProxy.typeLeftBattle(message.custom);
+ TurnBasedMinecraftMod.proxy.displayString(from + " died in battle!");
+ TurnBasedMinecraftMod.proxy.typeLeftBattle(message.custom);
break;
case ENDED:
- TurnBasedMinecraftMod.commonProxy.displayString("Battle has ended!");
- TurnBasedMinecraftMod.commonProxy.battleEnded();
+ TurnBasedMinecraftMod.proxy.displayString("Battle has ended!");
+ TurnBasedMinecraftMod.proxy.battleEnded();
break;
case ATTACK:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " attacked " + to + " and dealt " + message.amount + " damage!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " attacked " + to + " and dealt " + message.amount + " damage!");
break;
case DEFEND:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " blocked " + to + "'s attack!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " blocked " + to + "'s attack!");
break;
case DEFENSE_DAMAGE:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " retaliated from " + to + "'s attack and dealt " + message.amount + " damage!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " retaliated from " + to + "'s attack and dealt " + message.amount + " damage!");
break;
case MISS:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " attacked " + to + " but missed!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " attacked " + to + " but missed!");
break;
case DEFENDING:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " is defending!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " is defending!");
break;
case DID_NOTHING:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " did nothing!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " did nothing!");
break;
case USED_ITEM:
switch(UsedItemAction.valueOf(message.amount))
{
case USED_NOTHING:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " tried to use nothing!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " tried to use nothing!");
break;
case USED_INVALID:
if(message.custom.length() > 0)
{
- TurnBasedMinecraftMod.commonProxy.displayString(from + " tried to consume " + message.custom + " and failed!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " tried to consume " + message.custom + " and failed!");
}
else
{
- TurnBasedMinecraftMod.commonProxy.displayString(from + " tried to consume an invalid item and failed!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " tried to consume an invalid item and failed!");
}
break;
case USED_FOOD:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " ate a " + message.custom + "!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " ate a " + message.custom + "!");
break;
case USED_POTION:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " drank a " + message.custom + "!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " drank a " + message.custom + "!");
break;
}
break;
case TURN_BEGIN:
- TurnBasedMinecraftMod.commonProxy.displayString("The turn begins!");
- TurnBasedMinecraftMod.commonProxy.battleGuiTurnBegin();
+ TurnBasedMinecraftMod.proxy.displayString("The turn begins!");
+ TurnBasedMinecraftMod.proxy.battleGuiTurnBegin();
break;
case TURN_END:
- if(TurnBasedMinecraftMod.commonProxy.getLocalBattle() != null)
+ if(TurnBasedMinecraftMod.proxy.getLocalBattle() != null)
{
- TurnBasedMinecraftMod.commonProxy.displayString("The turn ended!");
+ TurnBasedMinecraftMod.proxy.displayString("The turn ended!");
}
- TurnBasedMinecraftMod.commonProxy.battleGuiTurnEnd();
+ TurnBasedMinecraftMod.proxy.battleGuiTurnEnd();
break;
case SWITCHED_ITEM:
if(message.amount != 0)
{
- TurnBasedMinecraftMod.commonProxy.displayString(from + " switched to a different item!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " switched to a different item!");
}
else
{
- TurnBasedMinecraftMod.commonProxy.displayString(from + " switched to a different item but failed because it was invalid!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " switched to a different item but failed because it was invalid!");
}
break;
case WAS_AFFECTED:
- TurnBasedMinecraftMod.commonProxy.displayString(to + " was " + message.custom + " by " + from + "!");
+ TurnBasedMinecraftMod.proxy.displayString(to + " was " + message.custom + " by " + from + "!");
break;
case BECAME_CREATIVE:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " entered creative mode and left battle!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " entered creative mode and left battle!");
break;
case FIRED_ARROW:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " let loose an arrow towards " + to + "!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " let loose an arrow towards " + to + "!");
break;
case ARROW_HIT:
- TurnBasedMinecraftMod.commonProxy.displayString(to + " was hit by " + from + "'s arrow!");
+ TurnBasedMinecraftMod.proxy.displayString(to + " was hit by " + from + "'s arrow!");
break;
case BOW_NO_AMMO:
- TurnBasedMinecraftMod.commonProxy.displayString(from + " tried to use their bow but ran out of ammo!");
+ TurnBasedMinecraftMod.proxy.displayString(from + " tried to use their bow but ran out of ammo!");
break;
}
return null;
@Override
public PacketBattleInfo onMessage(PacketBattleRequestInfo message, MessageContext ctx)
{
- Battle b = TurnBasedMinecraftMod.getBattleManager().getBattleByID(message.battleID);
+ Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(message.battleID);
if(b == null)
{
return null;