2019-11-25 06:29:25 +00:00
|
|
|
package com.burnedkirby.TurnBasedMinecraft.common;
|
2018-09-12 06:39:55 +00:00
|
|
|
|
2022-06-03 05:49:59 +00:00
|
|
|
import net.minecraft.network.chat.Component;
|
2022-05-17 05:47:42 +00:00
|
|
|
import net.minecraft.resources.ResourceKey;
|
|
|
|
import net.minecraft.world.entity.Entity;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
|
|
|
import net.minecraft.world.level.Level;
|
|
|
|
import net.minecraftforge.network.NetworkEvent;
|
|
|
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
2018-09-14 05:14:10 +00:00
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
2022-05-17 05:47:42 +00:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Hashtable;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.function.Supplier;
|
2018-09-17 04:27:13 +00:00
|
|
|
|
2018-09-12 06:39:55 +00:00
|
|
|
public class CommonProxy
|
|
|
|
{
|
2018-09-28 08:45:32 +00:00
|
|
|
private Set<AttackerViaBow> attackerViaBow = null;
|
|
|
|
private BattleManager battleManager = null;
|
|
|
|
private Entity attackingEntity = null;
|
|
|
|
private int attackingDamage = 0;
|
|
|
|
private Config config = null;
|
2019-11-29 09:52:28 +00:00
|
|
|
protected Logger logger = null;
|
2018-10-24 08:20:04 +00:00
|
|
|
private Map<Integer, EditingInfo> editingPlayers;
|
2018-09-28 08:45:32 +00:00
|
|
|
|
2018-10-04 03:07:26 +00:00
|
|
|
public final void initialize()
|
2018-09-28 08:45:32 +00:00
|
|
|
{
|
|
|
|
attackerViaBow = new HashSet<AttackerViaBow>();
|
2018-10-24 08:20:04 +00:00
|
|
|
editingPlayers = new Hashtable<Integer, EditingInfo>();
|
2018-10-04 03:07:26 +00:00
|
|
|
initializeClient();
|
2019-11-28 07:32:34 +00:00
|
|
|
logger.debug("Init proxy for com_burnedkirby_turnbasedminecraft");
|
2018-09-28 08:45:32 +00:00
|
|
|
}
|
2018-09-20 06:15:34 +00:00
|
|
|
|
2018-10-04 03:07:26 +00:00
|
|
|
protected void initializeClient() {}
|
|
|
|
|
2018-09-28 08:45:32 +00:00
|
|
|
public final boolean initializeBattleManager()
|
2018-09-20 06:15:34 +00:00
|
|
|
{
|
2018-09-28 08:45:32 +00:00
|
|
|
if(battleManager == null)
|
2018-09-20 06:15:34 +00:00
|
|
|
{
|
2018-09-28 08:45:32 +00:00
|
|
|
battleManager = new BattleManager(TurnBasedMinecraftMod.logger);
|
2018-09-20 06:15:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-28 08:45:32 +00:00
|
|
|
public final boolean cleanupBattleManager ()
|
2018-09-20 06:15:34 +00:00
|
|
|
{
|
2018-09-28 08:45:32 +00:00
|
|
|
if(battleManager != null)
|
2018-09-20 06:15:34 +00:00
|
|
|
{
|
2018-09-28 08:45:32 +00:00
|
|
|
battleManager.cleanup();
|
|
|
|
battleManager = null;
|
2018-09-20 06:15:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-12 06:39:55 +00:00
|
|
|
public void setBattleGuiTime(int timeRemaining) {}
|
|
|
|
|
|
|
|
public void setBattleGuiBattleChanged() {}
|
|
|
|
|
|
|
|
public void setBattleGuiAsGui() {}
|
2022-07-21 03:57:10 +00:00
|
|
|
|
|
|
|
public void setBattleGuiTurnTimerEnabled(boolean enabled) {}
|
2022-07-21 05:01:34 +00:00
|
|
|
|
|
|
|
public void setBattleGuiTurnTimerMax(int timeMax) {}
|
2018-09-12 06:39:55 +00:00
|
|
|
|
|
|
|
public void battleGuiTurnBegin() {}
|
|
|
|
|
|
|
|
public void battleGuiTurnEnd() {}
|
2018-09-14 03:44:45 +00:00
|
|
|
|
2018-09-18 07:58:01 +00:00
|
|
|
public void battleStarted() {}
|
|
|
|
|
2018-09-14 03:44:45 +00:00
|
|
|
public void battleEnded() {}
|
2018-09-14 05:14:10 +00:00
|
|
|
|
2018-10-04 03:07:26 +00:00
|
|
|
public final void postInit()
|
2018-09-28 08:45:32 +00:00
|
|
|
{
|
|
|
|
config = new Config(logger);
|
2018-10-04 03:07:26 +00:00
|
|
|
postInitClient();
|
2019-11-28 07:32:34 +00:00
|
|
|
logger.debug("postInit proxy for com_burnedkirby_turnbasedminecraft");
|
2018-09-28 08:45:32 +00:00
|
|
|
}
|
2018-09-14 05:14:10 +00:00
|
|
|
|
2018-10-04 03:07:26 +00:00
|
|
|
protected void postInitClient() {}
|
2021-05-23 04:22:18 +00:00
|
|
|
|
2018-09-28 08:45:32 +00:00
|
|
|
public final void setLogger(Logger logger)
|
|
|
|
{
|
|
|
|
this.logger = logger;
|
|
|
|
}
|
2018-09-14 05:14:10 +00:00
|
|
|
|
|
|
|
public void playBattleMusic() {}
|
|
|
|
|
|
|
|
public void playSillyMusic() {}
|
|
|
|
|
2018-09-27 07:44:28 +00:00
|
|
|
public void stopMusic(boolean resumeMCSounds) {}
|
2018-09-14 05:14:10 +00:00
|
|
|
|
|
|
|
public void typeEnteredBattle(String type) {}
|
|
|
|
|
2018-09-27 09:09:40 +00:00
|
|
|
public void typeLeftBattle(String type) {}
|
|
|
|
|
2018-09-17 04:27:13 +00:00
|
|
|
public void displayString(String message) {}
|
2018-10-24 08:20:04 +00:00
|
|
|
|
2022-06-03 05:49:59 +00:00
|
|
|
public void displayComponent(Component textComponent) {}
|
2018-09-17 04:27:13 +00:00
|
|
|
|
2018-09-28 08:45:32 +00:00
|
|
|
public final boolean isServerRunning()
|
2018-09-25 05:55:24 +00:00
|
|
|
{
|
2018-09-28 08:45:32 +00:00
|
|
|
return battleManager != null;
|
2018-09-25 05:55:24 +00:00
|
|
|
}
|
2018-09-28 03:13:07 +00:00
|
|
|
|
|
|
|
public Battle getLocalBattle()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void createLocalBattle(int id) {}
|
2018-09-28 08:45:32 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-10-24 08:20:04 +00:00
|
|
|
|
|
|
|
protected final EditingInfo getEditingInfo(int id)
|
|
|
|
{
|
|
|
|
return editingPlayers.get(id);
|
|
|
|
}
|
|
|
|
|
2022-05-17 05:47:42 +00:00
|
|
|
protected final EditingInfo setEditingPlayer(Player player)
|
2018-10-24 08:20:04 +00:00
|
|
|
{
|
2021-05-21 05:44:31 +00:00
|
|
|
return editingPlayers.put(player.getId(), new EditingInfo(player));
|
2018-10-24 08:20:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected final EditingInfo removeEditingInfo(int id)
|
|
|
|
{
|
|
|
|
return editingPlayers.remove(id);
|
|
|
|
}
|
2019-11-29 09:52:28 +00:00
|
|
|
|
2022-05-17 05:47:42 +00:00
|
|
|
public Entity getEntity(int id, ResourceKey<Level> dim) {
|
2021-05-21 05:44:31 +00:00
|
|
|
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
2019-11-29 09:52:28 +00:00
|
|
|
}
|
2022-05-17 05:47:42 +00:00
|
|
|
|
|
|
|
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {}
|
2018-09-12 06:39:55 +00:00
|
|
|
}
|