2018-09-12 06:39:55 +00:00
|
|
|
package com.seodisparate.TurnBasedMinecraft.client;
|
|
|
|
|
2018-09-14 05:14:10 +00:00
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
2018-09-12 06:39:55 +00:00
|
|
|
import com.seodisparate.TurnBasedMinecraft.common.CommonProxy;
|
2018-09-14 05:14:10 +00:00
|
|
|
import com.seodisparate.TurnBasedMinecraft.common.Config;
|
2018-09-14 03:44:45 +00:00
|
|
|
import com.seodisparate.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
2018-09-12 06:39:55 +00:00
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
2018-09-17 04:27:13 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.util.text.TextComponentString;
|
2018-09-12 06:39:55 +00:00
|
|
|
|
|
|
|
public class ClientProxy extends CommonProxy
|
|
|
|
{
|
|
|
|
private BattleGui battleGui;
|
2018-09-14 05:14:10 +00:00
|
|
|
private BattleMusic battleMusic;
|
|
|
|
private Logger logger;
|
|
|
|
private Config config;
|
2018-09-12 06:39:55 +00:00
|
|
|
|
|
|
|
public ClientProxy()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
battleGui = new BattleGui();
|
2018-09-14 05:14:10 +00:00
|
|
|
battleMusic = null; // will be initialized in postInit()
|
2018-09-12 06:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setBattleGuiTime(int timeRemaining)
|
|
|
|
{
|
|
|
|
battleGui.timeRemaining.set(timeRemaining);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setBattleGuiBattleChanged()
|
|
|
|
{
|
|
|
|
battleGui.battleChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setBattleGuiAsGui()
|
|
|
|
{
|
|
|
|
Minecraft.getMinecraft().addScheduledTask(() -> {
|
|
|
|
if(Minecraft.getMinecraft().currentScreen != battleGui)
|
|
|
|
{
|
|
|
|
battleGui.turnEnd();
|
|
|
|
Minecraft.getMinecraft().displayGuiScreen(battleGui);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void battleGuiTurnBegin()
|
|
|
|
{
|
|
|
|
battleGui.turnBegin();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void battleGuiTurnEnd()
|
|
|
|
{
|
|
|
|
battleGui.turnEnd();
|
|
|
|
}
|
2018-09-14 03:44:45 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void battleEnded()
|
|
|
|
{
|
|
|
|
TurnBasedMinecraftMod.currentBattle = null;
|
|
|
|
Minecraft.getMinecraft().addScheduledTask(() -> {
|
|
|
|
Minecraft.getMinecraft().displayGuiScreen(null);
|
|
|
|
Minecraft.getMinecraft().setIngameFocus();
|
|
|
|
});
|
|
|
|
}
|
2018-09-14 05:14:10 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void postInit()
|
|
|
|
{
|
|
|
|
battleMusic = new BattleMusic(logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setLogger(Logger logger)
|
|
|
|
{
|
|
|
|
this.logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void playBattleMusic()
|
|
|
|
{
|
|
|
|
battleMusic.playBattle();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void playSillyMusic()
|
|
|
|
{
|
|
|
|
battleMusic.playSilly();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void stopMusic()
|
|
|
|
{
|
|
|
|
battleMusic.stopMusic();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets what music to play based on type and loaded Config
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void typeEnteredBattle(String type)
|
|
|
|
{
|
|
|
|
if(type == null || type.isEmpty() || config.isBattleMusicType(type))
|
|
|
|
{
|
|
|
|
if(battleMusic.isPlaying())
|
|
|
|
{
|
|
|
|
if(battleMusic.isPlayingSilly())
|
|
|
|
{
|
|
|
|
stopMusic();
|
|
|
|
playBattleMusic();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
playBattleMusic();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(config.isSillyMusicType(type))
|
|
|
|
{
|
|
|
|
if(battleMusic.isPlaying())
|
|
|
|
{
|
|
|
|
if(!battleMusic.isPlayingSilly())
|
|
|
|
{
|
|
|
|
stopMusic();
|
|
|
|
playSillyMusic();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
playSillyMusic();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setConfig(Config config)
|
|
|
|
{
|
|
|
|
this.config = config;
|
|
|
|
}
|
2018-09-17 04:27:13 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void displayString(String message)
|
|
|
|
{
|
|
|
|
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(message));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Entity getEntityByID(int id)
|
|
|
|
{
|
|
|
|
return Minecraft.getMinecraft().world.getEntityByID(id);
|
|
|
|
}
|
2018-09-12 06:39:55 +00:00
|
|
|
}
|