use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.
the class TileEntityFluidTransmitter method setNetwork.
@Override
public void setNetwork(IGridNetwork network) {
if (this.network == network) {
return;
}
if (this.worldObj.isRemote && this.network != null) {
FluidNetwork fluidNetwork = (FluidNetwork) this.network;
fluidNetwork.removeTransmitter(this);
if (fluidNetwork.getTransmitters().isEmpty()) {
fluidNetwork.unregister();
}
}
this.network = network;
if (this.worldObj.isRemote && this.network != null) {
((FluidNetwork) this.network).pipes.add(this);
}
}
use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.
the class PacketFluidNetworkUpdate method handleClientSide.
@Override
public void handleClientSide(EntityPlayer player) {
TileEntity tile = player.worldObj.getTileEntity(this.pos);
if (tile instanceof IBufferTransmitter) {
IBufferTransmitter<FluidStack> transmitter = (IBufferTransmitter<FluidStack>) tile;
switch(this.type) {
case ADD_TRANSMITTER:
{
FluidNetwork network = transmitter.hasNetwork() && !this.newNetwork ? (FluidNetwork) transmitter.getNetwork() : new FluidNetwork();
network.register();
transmitter.setNetwork(network);
for (BlockPos pos : this.transmittersCoords) {
TileEntity transmitterTile = player.worldObj.getTileEntity(pos);
if (transmitterTile instanceof IBufferTransmitter) {
((IBufferTransmitter) transmitterTile).setNetwork(network);
}
}
network.updateCapacity();
}
break;
case FLUID:
if (transmitter.getNetwork() != null) {
FluidNetwork network = (FluidNetwork) transmitter.getNetwork();
if (this.fluidType != null) {
network.refFluid = this.fluidType;
}
network.buffer = this.stack;
network.didTransfer = this.didTransfer;
}
break;
}
}
}
use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.
the class TickHandlerServer method onServerTick.
@SubscribeEvent
public void onServerTick(ServerTickEvent event) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
// Prevent issues when clients switch to LAN servers
if (server == null) {
return;
}
if (event.phase == Phase.START) {
if (timerHoustonCommand > 0) {
if (--timerHoustonCommand == 0) {
CommandGCHouston.reset();
}
}
for (ScheduledDimensionChange change : TickHandlerServer.scheduledDimensionChanges) {
try {
GCPlayerStats stats = GCPlayerStats.get(change.getPlayer());
final WorldProvider provider = WorldUtil.getProviderForNameServer(change.getDimensionName());
if (provider != null) {
final Integer dim = GCCoreUtil.getDimensionID(provider);
GCLog.info("Found matching world (" + dim.toString() + ") for name: " + change.getDimensionName());
if (change.getPlayer().worldObj instanceof WorldServer) {
final WorldServer world = (WorldServer) change.getPlayer().worldObj;
WorldUtil.transferEntityToDimension(change.getPlayer(), dim, world);
}
} else {
GCLog.severe("World not found when attempting to transfer entity to dimension: " + change.getDimensionName());
}
stats.setTeleportCooldown(10);
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_CLOSE_GUI, GCCoreUtil.getDimensionID(change.getPlayer().worldObj), new Object[] {}), change.getPlayer());
} catch (Exception e) {
GCLog.severe("Error occurred when attempting to transfer entity to dimension: " + change.getDimensionName());
e.printStackTrace();
}
}
TickHandlerServer.scheduledDimensionChanges.clear();
if (MapUtil.calculatingMap.get()) {
MapUtil.BiomeMapNextTick_MultiThreaded();
} else if (!MapUtil.doneOverworldTexture) {
MapUtil.makeOverworldTexture();
}
if (TickHandlerServer.spaceRaceData == null) {
World world = server.worldServerForDimension(0);
TickHandlerServer.spaceRaceData = (WorldDataSpaceRaces) world.getMapStorage().loadData(WorldDataSpaceRaces.class, WorldDataSpaceRaces.saveDataID);
if (TickHandlerServer.spaceRaceData == null) {
TickHandlerServer.spaceRaceData = new WorldDataSpaceRaces(WorldDataSpaceRaces.saveDataID);
world.getMapStorage().setData(WorldDataSpaceRaces.saveDataID, TickHandlerServer.spaceRaceData);
}
}
SpaceRaceManager.tick();
TileEntityOxygenSealer.onServerTick();
if (TickHandlerServer.tickCount % 33 == 0) {
WorldServer[] worlds = server.worldServers;
for (int i = worlds.length - 1; i >= 0; i--) {
WorldServer world = worlds[i];
TileEntityPainter.onServerTick(world);
}
}
if (TickHandlerServer.tickCount % 100 == 0) {
WorldServer[] worlds = server.worldServers;
for (int i = 0; i < worlds.length; i++) {
WorldServer world = worlds[i];
ChunkProviderServer chunkProviderServer = world.theChunkProviderServer;
Map<Long, List<Footprint>> footprintMap = TickHandlerServer.serverFootprintMap.get(GCCoreUtil.getDimensionID(world));
if (footprintMap != null) {
boolean mapChanged = false;
if (chunkProviderServer != null) {
Iterator iterator = chunkProviderServer.loadedChunks.iterator();
while (iterator.hasNext()) {
Chunk chunk = (Chunk) iterator.next();
long chunkKey = ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition);
List<Footprint> footprints = footprintMap.get(chunkKey);
if (footprints != null) {
List<Footprint> toRemove = new ArrayList<Footprint>();
for (int j = 0; j < footprints.size(); j++) {
footprints.get(j).age += 100;
if (footprints.get(j).age >= Footprint.MAX_AGE) {
toRemove.add(footprints.get(j));
}
}
if (!toRemove.isEmpty()) {
footprints.removeAll(toRemove);
}
footprintMap.put(chunkKey, footprints);
mapChanged = true;
GalacticraftCore.packetPipeline.sendToDimension(new PacketSimple(EnumSimplePacket.C_UPDATE_FOOTPRINT_LIST, GCCoreUtil.getDimensionID(worlds[i]), new Object[] { chunkKey, footprints.toArray(new Footprint[footprints.size()]) }), GCCoreUtil.getDimensionID(worlds[i]));
}
}
}
if (mapChanged) {
TickHandlerServer.serverFootprintMap.put(GCCoreUtil.getDimensionID(world), footprintMap);
}
}
}
}
if (!footprintBlockChanges.isEmpty()) {
for (BlockVec3Dim targetPoint : footprintBlockChanges) {
WorldServer[] worlds = server.worldServers;
for (int i = 0; i < worlds.length; i++) {
WorldServer world = worlds[i];
if (GCCoreUtil.getDimensionID(world) == targetPoint.dim) {
long chunkKey = ChunkCoordIntPair.chunkXZ2Int((int) targetPoint.x >> 4, (int) targetPoint.z >> 4);
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_FOOTPRINTS_REMOVED, GCCoreUtil.getDimensionID(world), new Object[] { chunkKey, new BlockVec3(targetPoint.x, targetPoint.y, targetPoint.z) }), new NetworkRegistry.TargetPoint(targetPoint.dim, targetPoint.x, targetPoint.y, targetPoint.z, 50));
// Map<Long, List<Footprint>> footprintMap = TickHandlerServer.serverFootprintMap.get(world.provider.dimensionId);
//
// if (footprintMap != null && !footprintMap.isEmpty())
// {
// List<Footprint> footprints = footprintMap.get(chunkKey);
// if (footprints != null)
// GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_UPDATE_FOOTPRINT_LIST, new Object[] { chunkKey, footprints.toArray(new Footprint[footprints.size()]) }), new NetworkRegistry.TargetPoint(targetPoint.dim, targetPoint.x, targetPoint.y, targetPoint.z, 50));
// }
}
}
}
footprintBlockChanges.clear();
}
if (tickCount % 20 == 0) {
if (!playersRequestingMapData.isEmpty()) {
File baseFolder = new File(DimensionManager.getCurrentSaveRootDirectory(), "galacticraft/overworldMap");
if (!baseFolder.exists() && !baseFolder.mkdirs()) {
GCLog.severe("Base folder(s) could not be created: " + baseFolder.getAbsolutePath());
} else {
ArrayList<EntityPlayerMP> copy = new ArrayList<EntityPlayerMP>(playersRequestingMapData);
BufferedImage reusable = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB);
for (EntityPlayerMP playerMP : copy) {
GCPlayerStats stats = GCPlayerStats.get(playerMP);
MapUtil.makeVanillaMap(playerMP.dimension, (int) Math.floor(stats.getCoordsTeleportedFromZ()) >> 4, (int) Math.floor(stats.getCoordsTeleportedFromZ()) >> 4, baseFolder, reusable);
}
playersRequestingMapData.removeAll(copy);
}
}
}
TickHandlerServer.tickCount++;
EnergyNetwork.tickCount++;
} else if (event.phase == Phase.END) {
for (FluidNetwork network : new ArrayList<>(fluidNetworks)) {
if (!network.pipes.isEmpty()) {
network.tickEnd();
} else {
fluidNetworks.remove(network);
}
}
int maxPasses = 10;
while (!TickHandlerServer.networkTicks.isEmpty()) {
LinkedList<EnergyNetwork> pass = new LinkedList<>();
pass.addAll(TickHandlerServer.networkTicks);
TickHandlerServer.networkTicks.clear();
for (EnergyNetwork grid : pass) {
grid.tickEnd();
}
if (--maxPasses <= 0) {
break;
}
}
maxPasses = 10;
while (!TickHandlerServer.oxygenTransmitterUpdates.isEmpty()) {
LinkedList<TileEntityFluidTransmitter> pass = new LinkedList<>();
pass.addAll(TickHandlerServer.oxygenTransmitterUpdates);
TickHandlerServer.oxygenTransmitterUpdates.clear();
for (TileEntityFluidTransmitter newTile : pass) {
if (!newTile.isInvalid()) {
newTile.refresh();
}
}
if (--maxPasses <= 0) {
break;
}
}
maxPasses = 10;
while (!TickHandlerServer.energyTransmitterUpdates.isEmpty()) {
LinkedList<TileBaseConductor> pass = new LinkedList<>();
pass.addAll(TickHandlerServer.energyTransmitterUpdates);
TickHandlerServer.energyTransmitterUpdates.clear();
for (TileBaseConductor newTile : pass) {
if (!newTile.isInvalid()) {
newTile.refresh();
}
}
if (--maxPasses <= 0) {
break;
}
}
}
}
use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.
the class PacketSimple method handleServerSide.
@Override
public void handleServerSide(EntityPlayer player) {
final EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
if (playerBase == null) {
return;
}
final MinecraftServer server = playerBase.mcServer;
final GCPlayerStats stats = GCPlayerStats.get(playerBase);
switch(this.type) {
case S_RESPAWN_PLAYER:
playerBase.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.getDifficulty(), player.worldObj.getWorldInfo().getTerrainType(), playerBase.theItemInWorldManager.getGameType()));
break;
case S_TELEPORT_ENTITY:
TickHandlerServer.scheduleNewDimensionChange(new ScheduledDimensionChange(playerBase, (String) PacketSimple.this.data.get(0)));
break;
case S_IGNITE_ROCKET:
if (!player.worldObj.isRemote && !player.isDead && player.ridingEntity != null && !player.ridingEntity.isDead && player.ridingEntity instanceof EntityTieredRocket) {
final EntityTieredRocket ship = (EntityTieredRocket) player.ridingEntity;
if (ship.launchPhase != EnumLaunchPhase.LANDING.ordinal()) {
if (ship.hasValidFuel()) {
ItemStack stack2 = stats.getExtendedInventory().getStackInSlot(4);
if (stack2 != null && stack2.getItem() instanceof ItemParaChute || stats.getLaunchAttempts() > 0) {
ship.igniteCheckingCooldown();
stats.setLaunchAttempts(0);
} else if (stats.getChatCooldown() == 0 && stats.getLaunchAttempts() == 0) {
player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.noparachute")));
stats.setChatCooldown(250);
stats.setLaunchAttempts(1);
}
} else if (stats.getChatCooldown() == 0) {
player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.nofuel")));
stats.setChatCooldown(250);
}
}
}
break;
case S_OPEN_SCHEMATIC_PAGE:
if (player != null) {
final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0));
player.openGui(GalacticraftCore.instance, page.getGuiID(), player.worldObj, (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3));
}
break;
case S_OPEN_FUEL_GUI:
if (player.ridingEntity instanceof EntityBuggy) {
GCCoreUtil.openBuggyInv(playerBase, (EntityBuggy) player.ridingEntity, ((EntityBuggy) player.ridingEntity).getType());
} else if (player.ridingEntity instanceof EntitySpaceshipBase) {
player.openGui(GalacticraftCore.instance, GuiIdsCore.ROCKET_INVENTORY, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
}
break;
case S_UPDATE_SHIP_YAW:
if (player.ridingEntity instanceof EntitySpaceshipBase) {
final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;
if (ship != null) {
ship.rotationYaw = (Float) this.data.get(0);
}
}
break;
case S_UPDATE_SHIP_PITCH:
if (player.ridingEntity instanceof EntitySpaceshipBase) {
final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;
if (ship != null) {
ship.rotationPitch = (Float) this.data.get(0);
}
}
break;
case S_SET_ENTITY_FIRE:
Entity entity = player.worldObj.getEntityByID((Integer) this.data.get(0));
if (entity instanceof EntityLivingBase) {
((EntityLivingBase) entity).setFire(3);
}
break;
case S_BIND_SPACE_STATION_ID:
int homeID = (Integer) this.data.get(0);
if ((!stats.getSpaceStationDimensionData().containsKey(homeID) || stats.getSpaceStationDimensionData().get(homeID) == -1 || stats.getSpaceStationDimensionData().get(homeID) == 0) && !ConfigManagerCore.disableSpaceStationCreation) {
if (playerBase.capabilities.isCreativeMode || WorldUtil.getSpaceStationRecipe(homeID).matches(playerBase, true)) {
WorldUtil.bindSpaceStationToNewDimension(playerBase.worldObj, playerBase, homeID);
}
}
break;
case S_UNLOCK_NEW_SCHEMATIC:
final Container container = player.openContainer;
if (container instanceof ContainerSchematic) {
final ContainerSchematic schematicContainer = (ContainerSchematic) container;
ItemStack stack = schematicContainer.craftMatrix.getStackInSlot(0);
if (stack != null) {
final ISchematicPage page = SchematicRegistry.getMatchingRecipeForItemStack(stack);
if (page != null) {
SchematicRegistry.unlockNewPage(playerBase, stack);
SpaceRaceManager.teamUnlockSchematic(playerBase, stack);
if (--stack.stackSize <= 0) {
stack = null;
}
schematicContainer.craftMatrix.setInventorySlotContents(0, stack);
schematicContainer.craftMatrix.markDirty();
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_ADD_NEW_SCHEMATIC, getDimensionID(), new Object[] { page.getPageID() }), playerBase);
}
}
}
break;
case S_UPDATE_DISABLEABLE_BUTTON:
final TileEntity tileAt = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
if (tileAt instanceof IDisableableMachine) {
final IDisableableMachine machine = (IDisableableMachine) tileAt;
machine.setDisabled((Integer) this.data.get(1), !machine.getDisabled((Integer) this.data.get(1)));
}
break;
case S_ON_FAILED_CHEST_UNLOCK:
if (stats.getChatCooldown() == 0) {
player.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.chest.warning.wrongkey", this.data.get(0))));
stats.setChatCooldown(100);
}
break;
case S_RENAME_SPACE_STATION:
final SpaceStationWorldData ssdata = SpaceStationWorldData.getStationData(playerBase.worldObj, (Integer) this.data.get(1), playerBase);
if (ssdata != null && ssdata.getOwner().equalsIgnoreCase(PlayerUtil.getName(player))) {
ssdata.setSpaceStationName((String) this.data.get(0));
ssdata.setDirty(true);
}
break;
case S_OPEN_EXTENDED_INVENTORY:
player.openGui(GalacticraftCore.instance, GuiIdsCore.EXTENDED_INVENTORY, player.worldObj, 0, 0, 0);
break;
case S_ON_ADVANCED_GUI_CLICKED_INT:
TileEntity tile1 = player.worldObj.getTileEntity((BlockPos) this.data.get(1));
switch((Integer) this.data.get(0)) {
case 0:
if (tile1 instanceof TileEntityAirLockController) {
TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
airlockController.redstoneActivation = (Integer) this.data.get(2) == 1;
}
break;
case 1:
if (tile1 instanceof TileEntityAirLockController) {
TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
airlockController.playerDistanceActivation = (Integer) this.data.get(2) == 1;
}
break;
case 2:
if (tile1 instanceof TileEntityAirLockController) {
TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
airlockController.playerDistanceSelection = (Integer) this.data.get(2);
}
break;
case 3:
if (tile1 instanceof TileEntityAirLockController) {
TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
airlockController.playerNameMatches = (Integer) this.data.get(2) == 1;
}
break;
case 4:
if (tile1 instanceof TileEntityAirLockController) {
TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
airlockController.invertSelection = (Integer) this.data.get(2) == 1;
}
break;
case 5:
if (tile1 instanceof TileEntityAirLockController) {
TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
airlockController.lastHorizontalModeEnabled = airlockController.horizontalModeEnabled;
airlockController.horizontalModeEnabled = (Integer) this.data.get(2) == 1;
}
break;
case 6:
if (tile1 instanceof IBubbleProvider) {
IBubbleProvider distributor = (IBubbleProvider) tile1;
distributor.setBubbleVisible((Integer) this.data.get(2) == 1);
}
break;
default:
break;
}
break;
case S_ON_ADVANCED_GUI_CLICKED_STRING:
TileEntity tile2 = player.worldObj.getTileEntity((BlockPos) this.data.get(1));
switch((Integer) this.data.get(0)) {
case 0:
if (tile2 instanceof TileEntityAirLockController) {
TileEntityAirLockController airlockController = (TileEntityAirLockController) tile2;
airlockController.playerToOpenFor = (String) this.data.get(2);
}
break;
default:
break;
}
break;
case S_UPDATE_SHIP_MOTION_Y:
int entityID = (Integer) this.data.get(0);
boolean up = (Boolean) this.data.get(1);
Entity entity2 = player.worldObj.getEntityByID(entityID);
if (entity2 instanceof EntityAutoRocket) {
EntityAutoRocket autoRocket = (EntityAutoRocket) entity2;
autoRocket.motionY += up ? 0.02F : -0.02F;
}
break;
case S_START_NEW_SPACE_RACE:
Integer teamID = (Integer) this.data.get(0);
String teamName = (String) this.data.get(1);
FlagData flagData = (FlagData) this.data.get(2);
Vector3 teamColor = (Vector3) this.data.get(3);
List<String> playerList = new ArrayList<String>();
for (int i = 4; i < this.data.size(); i++) {
playerList.add((String) this.data.get(i));
}
boolean previousData = SpaceRaceManager.getSpaceRaceFromID(teamID) != null;
SpaceRace newRace = new SpaceRace(playerList, teamName, flagData, teamColor);
if (teamID > 0) {
newRace.setSpaceRaceID(teamID);
}
SpaceRaceManager.addSpaceRace(newRace);
if (previousData) {
SpaceRaceManager.sendSpaceRaceData(server, null, SpaceRaceManager.getSpaceRaceFromPlayer(PlayerUtil.getName(playerBase)));
}
break;
case S_REQUEST_FLAG_DATA:
SpaceRaceManager.sendSpaceRaceData(server, playerBase, SpaceRaceManager.getSpaceRaceFromPlayer((String) this.data.get(0)));
break;
case S_INVITE_RACE_PLAYER:
EntityPlayerMP playerInvited = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, (String) this.data.get(0), true);
if (playerInvited != null) {
Integer teamInvitedTo = (Integer) this.data.get(1);
SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo);
if (race != null) {
GCPlayerStats.get(playerInvited).setSpaceRaceInviteTeamID(teamInvitedTo);
String dA = EnumColor.DARK_AQUA.getCode();
String bG = EnumColor.BRIGHT_GREEN.getCode();
String dB = EnumColor.PURPLE.getCode();
String teamNameTotal = "";
String[] teamNameSplit = race.getTeamName().split(" ");
for (String teamNamePart : teamNameSplit) {
teamNameTotal = teamNameTotal.concat(dB + teamNamePart + " ");
}
playerInvited.addChatMessage(new ChatComponentText(dA + GCCoreUtil.translateWithFormat("gui.space_race.chat.invite_received", bG + PlayerUtil.getName(player) + dA) + " " + GCCoreUtil.translateWithFormat("gui.space_race.chat.to_join", teamNameTotal, EnumColor.AQUA + "/joinrace" + dA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
}
}
break;
case S_REMOVE_RACE_PLAYER:
Integer teamInvitedTo = (Integer) this.data.get(1);
SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo);
if (race != null) {
String playerToRemove = (String) this.data.get(0);
if (!race.getPlayerNames().remove(playerToRemove)) {
player.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.space_race.chat.not_found", playerToRemove)));
} else {
SpaceRaceManager.onPlayerRemoval(server, playerToRemove, race);
}
}
break;
case S_ADD_RACE_PLAYER:
Integer teamToAddPlayer = (Integer) this.data.get(1);
SpaceRace spaceRaceToAddPlayer = SpaceRaceManager.getSpaceRaceFromID(teamToAddPlayer);
if (spaceRaceToAddPlayer != null) {
String playerToAdd = (String) this.data.get(0);
if (!spaceRaceToAddPlayer.getPlayerNames().contains(playerToAdd)) {
SpaceRace oldRace = null;
while ((oldRace = SpaceRaceManager.getSpaceRaceFromPlayer(playerToAdd)) != null) {
SpaceRaceManager.removeSpaceRace(oldRace);
}
spaceRaceToAddPlayer.getPlayerNames().add(playerToAdd);
SpaceRaceManager.sendSpaceRaceData(server, null, spaceRaceToAddPlayer);
for (String member : spaceRaceToAddPlayer.getPlayerNames()) {
EntityPlayerMP memberObj = PlayerUtil.getPlayerForUsernameVanilla(server, member);
if (memberObj != null) {
memberObj.addChatMessage(new ChatComponentText(EnumColor.DARK_AQUA + GCCoreUtil.translateWithFormat("gui.space_race.chat.add_success", EnumColor.BRIGHT_GREEN + playerToAdd + EnumColor.DARK_AQUA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
}
}
} else {
player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.space_race.chat.already_part")).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
}
}
break;
case S_COMPLETE_CBODY_HANDSHAKE:
String completeList = (String) this.data.get(0);
List<String> clientObjects = Arrays.asList(completeList.split(";"));
List<String> serverObjects = Lists.newArrayList();
String missingObjects = "";
for (CelestialBody cBody : GalaxyRegistry.getRegisteredPlanets().values()) {
serverObjects.add(cBody.getUnlocalizedName());
}
for (CelestialBody cBody : GalaxyRegistry.getRegisteredMoons().values()) {
serverObjects.add(cBody.getUnlocalizedName());
}
for (CelestialBody cBody : GalaxyRegistry.getRegisteredSatellites().values()) {
serverObjects.add(cBody.getUnlocalizedName());
}
for (SolarSystem solarSystem : GalaxyRegistry.getRegisteredSolarSystems().values()) {
serverObjects.add(solarSystem.getUnlocalizedName());
}
for (String str : serverObjects) {
if (!clientObjects.contains(str)) {
missingObjects = missingObjects.concat(str + "\n");
}
}
if (missingObjects.length() > 0) {
playerBase.playerNetServerHandler.kickPlayerFromServer("Missing Galacticraft Celestial Objects:\n\n " + missingObjects);
}
break;
case S_REQUEST_GEAR_DATA:
String name = (String) this.data.get(0);
EntityPlayerMP e = PlayerUtil.getPlayerBaseServerFromPlayerUsername(name, true);
if (e != null) {
GCPlayerHandler.checkGear(e, GCPlayerStats.get(e), true);
}
break;
case S_BUILDFLAGS_UPDATE:
stats.setBuildFlags((Integer) this.data.get(0));
break;
case S_REQUEST_OVERWORLD_IMAGE:
MapUtil.sendOverworldToClient(playerBase);
break;
case S_REQUEST_MAP_IMAGE:
int dim = (Integer) this.data.get(0);
int cx = (Integer) this.data.get(1);
int cz = (Integer) this.data.get(2);
MapUtil.sendOrCreateMap(WorldUtil.getProviderForDimensionServer(dim).worldObj, cx, cz, playerBase);
break;
case S_REQUEST_PLAYERSKIN:
String strName = (String) this.data.get(0);
EntityPlayerMP playerRequested = server.getConfigurationManager().getPlayerByUsername(strName);
// Player not online
if (playerRequested == null) {
return;
}
GameProfile gp = playerRequested.getGameProfile();
if (gp == null) {
return;
}
Property property = (Property) Iterables.getFirst(gp.getProperties().get("textures"), (Object) null);
if (property == null) {
return;
}
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_SEND_PLAYERSKIN, getDimensionID(), new Object[] { strName, property.getValue(), property.getSignature(), playerRequested.getUniqueID().toString() }), playerBase);
break;
case S_CONTROL_ENTITY:
if (player.ridingEntity != null && player.ridingEntity instanceof IControllableEntity) {
((IControllableEntity) player.ridingEntity).pressKey((Integer) this.data.get(0));
}
break;
case S_NOCLIP_PLAYER:
boolean noClip = (Boolean) this.data.get(0);
if (player instanceof GCEntityPlayerMP) {
GalacticraftCore.proxy.player.setNoClip((EntityPlayerMP) player, noClip);
if (noClip == false) {
player.fallDistance = 0.0F;
((EntityPlayerMP) player).playerNetServerHandler.floatingTickCount = 0;
}
} else if (player instanceof EntityPlayerMP) {
EntityPlayerMP emp = ((EntityPlayerMP) player);
try {
Field f = emp.theItemInWorldManager.getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "gameType" : "field_73091_c");
f.setAccessible(true);
if (noClip == false) {
emp.fallDistance = 0.0F;
emp.playerNetServerHandler.floatingTickCount = 0;
WorldSettings.GameType gt = savedSettings.get(emp);
if (gt != null) {
savedSettings.remove(emp);
f.set(emp.theItemInWorldManager, gt);
}
} else {
savedSettings.put(emp, emp.theItemInWorldManager.getGameType());
f.set(emp.theItemInWorldManager, WorldSettings.GameType.SPECTATOR);
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
break;
case S_REQUEST_DATA:
WorldServer worldServer = server.worldServerForDimension((Integer) this.data.get(0));
if (worldServer != null) {
TileEntity requestedTile = worldServer.getTileEntity((BlockPos) this.data.get(1));
if (requestedTile instanceof INetworkProvider) {
if (((INetworkProvider) requestedTile).getNetwork() instanceof FluidNetwork) {
FluidNetwork network = (FluidNetwork) ((INetworkProvider) requestedTile).getNetwork();
network.addUpdate(playerBase);
}
}
}
break;
case S_UPDATE_CHECKLIST:
ItemStack stack = player.getHeldItem();
if (stack != null && stack.getItem() == GCItems.prelaunchChecklist) {
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
}
NBTTagCompound tagCompoundRead = (NBTTagCompound) this.data.get(0);
tagCompound.setTag("checklistData", tagCompoundRead);
stack.setTagCompound(tagCompound);
}
break;
case S_REQUEST_MACHINE_DATA:
TileEntity tile3 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
if (tile3 instanceof ITileClientUpdates) {
((ITileClientUpdates) tile3).sendUpdateToClient(playerBase);
}
break;
default:
break;
}
}
use of micdoodle8.mods.galacticraft.core.fluid.FluidNetwork in project Galacticraft by micdoodle8.
the class TickHandlerClient method onClientTick.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
final Minecraft minecraft = FMLClientHandler.instance().getClient();
final WorldClient world = minecraft.theWorld;
final EntityPlayerSP player = minecraft.thePlayer;
if (teleportingGui != null) {
if (minecraft.currentScreen != teleportingGui) {
minecraft.currentScreen = teleportingGui;
}
}
if (menuReset) {
TickHandlerClient.resetClient();
menuReset = false;
}
if (event.phase == Phase.START && player != null) {
if (ClientProxyCore.playerHead == null && player.getGameProfile() != null) {
Map<Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(player.getGameProfile());
if (map.containsKey(Type.SKIN)) {
ClientProxyCore.playerHead = minecraft.getSkinManager().loadSkin((MinecraftProfileTexture) map.get(Type.SKIN), Type.SKIN);
} else {
ClientProxyCore.playerHead = DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(player.getGameProfile()));
}
}
TickHandlerClient.tickCount++;
if (!GalacticraftCore.proxy.isPaused()) {
Iterator<FluidNetwork> it = TickHandlerClient.fluidNetworks.iterator();
while (it.hasNext()) {
FluidNetwork network = it.next();
if (network.getTransmitters().size() == 0) {
it.remove();
} else {
network.clientTick();
}
}
}
if (TickHandlerClient.tickCount % 20 == 0) {
if (updateJEIhiding) {
updateJEIhiding = false;
if (CompressorRecipes.steelIngotsPresent) {
// Update JEI to hide the ingot compressor recipe for GC steel in hard mode
GalacticraftJEI.updateHiddenSteel(ConfigManagerCore.hardMode && !ConfigManagerCore.challengeRecipes);
}
// Update JEI to hide adventure mode recipes when not in adventure mode
GalacticraftJEI.updateHiddenAdventure(!ConfigManagerCore.challengeRecipes);
}
for (List<Footprint> fpList : FootprintRenderer.footprints.values()) {
Iterator<Footprint> fpIt = fpList.iterator();
while (fpIt.hasNext()) {
Footprint fp = fpIt.next();
fp.age += 20;
if (fp.age >= Footprint.MAX_AGE) {
fpIt.remove();
}
}
}
if (player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() instanceof ItemSensorGlasses) {
ClientProxyCore.valueableBlocks.clear();
for (int i = -4; i < 5; i++) {
int x = MathHelper.floor_double(player.posX + i);
for (int j = -4; j < 5; j++) {
int y = MathHelper.floor_double(player.posY + j);
for (int k = -4; k < 5; k++) {
int z = MathHelper.floor_double(player.posZ + k);
BlockPos pos = new BlockPos(x, y, z);
IBlockState state = player.worldObj.getBlockState(pos);
final Block block = state.getBlock();
if (block.getMaterial() != Material.air) {
int metadata = block.getMetaFromState(state);
boolean isDetectable = false;
for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks) {
if (blockMetaList.getBlock() == block && blockMetaList.getMetaList().contains(metadata)) {
isDetectable = true;
break;
}
}
if (isDetectable || (block instanceof IDetectableResource && ((IDetectableResource) block).isValueable(state))) {
ClientProxyCore.valueableBlocks.add(new BlockVec3(x, y, z));
}
}
}
}
}
TileEntityOxygenSealer nearestSealer = TileEntityOxygenSealer.getNearestSealer(world, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ));
if (nearestSealer != null && !nearestSealer.sealed) {
ClientProxyCore.leakTrace = nearestSealer.getLeakTraceClient();
} else {
ClientProxyCore.leakTrace = null;
}
} else {
ClientProxyCore.leakTrace = null;
}
if (world != null) {
if (MapUtil.resetClientFlag.getAndSet(false)) {
MapUtil.resetClientBody();
}
}
}
if (ClientProxyCore.leakTrace != null)
this.spawnLeakParticles();
if (world != null && TickHandlerClient.spaceRaceGuiScheduled && minecraft.currentScreen == null && ConfigManagerCore.enableSpaceRaceManagerPopup) {
player.openGui(GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_START, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
TickHandlerClient.spaceRaceGuiScheduled = false;
}
if (world != null && TickHandlerClient.checkedVersion) {
ThreadVersionCheck.startCheck();
TickHandlerClient.checkedVersion = false;
}
boolean inSpaceShip = false;
if (player.ridingEntity instanceof EntitySpaceshipBase) {
inSpaceShip = true;
EntitySpaceshipBase rocket = (EntitySpaceshipBase) player.ridingEntity;
if (rocket.prevRotationPitch != rocket.rotationPitch || rocket.prevRotationYaw != rocket.rotationYaw)
GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(player.ridingEntity));
}
if (world != null) {
if (world.provider instanceof WorldProviderSurface) {
if (world.provider.getSkyRenderer() == null && inSpaceShip && player.ridingEntity.posY > Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) {
world.provider.setSkyRenderer(new SkyProviderOverworld());
} else if (world.provider.getSkyRenderer() instanceof SkyProviderOverworld && player.posY <= Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) {
world.provider.setSkyRenderer(null);
}
} else if (world.provider instanceof WorldProviderSpaceStation) {
if (world.provider.getSkyRenderer() == null) {
((WorldProviderSpaceStation) world.provider).createSkyProvider();
}
} else if (world.provider instanceof WorldProviderMoon) {
if (world.provider.getSkyRenderer() == null) {
world.provider.setSkyRenderer(new SkyProviderMoon());
}
if (world.provider.getCloudRenderer() == null) {
world.provider.setCloudRenderer(new CloudRenderer());
}
}
}
if (inSpaceShip) {
final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;
boolean hasChanged = false;
if (minecraft.gameSettings.keyBindLeft.isKeyDown()) {
ship.turnYaw(-1.0F);
hasChanged = true;
}
if (minecraft.gameSettings.keyBindRight.isKeyDown()) {
ship.turnYaw(1.0F);
hasChanged = true;
}
if (minecraft.gameSettings.keyBindForward.isKeyDown()) {
if (ship.getLaunched()) {
ship.turnPitch(-0.7F);
hasChanged = true;
}
}
if (minecraft.gameSettings.keyBindBack.isKeyDown()) {
if (ship.getLaunched()) {
ship.turnPitch(0.7F);
hasChanged = true;
}
}
if (hasChanged) {
GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(ship));
}
}
if (world != null) {
List entityList = world.loadedEntityList;
for (Object e : entityList) {
if (e instanceof IEntityNoisy) {
IEntityNoisy vehicle = (IEntityNoisy) e;
if (vehicle.getSoundUpdater() == null) {
ISound noise = vehicle.setSoundUpdater(FMLClientHandler.instance().getClient().thePlayer);
if (noise != null) {
FMLClientHandler.instance().getClient().getSoundHandler().playSound(noise);
}
}
}
}
}
if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiCelestialSelection) {
player.motionY = 0;
}
if (world != null && world.provider instanceof IGalacticraftWorldProvider && OxygenUtil.noAtmosphericCombustion(world.provider) && ((IGalacticraftWorldProvider) world.provider).shouldDisablePrecipitation()) {
world.setRainStrength(0.0F);
}
boolean isPressed = KeyHandlerClient.spaceKey.isPressed();
if (!isPressed) {
ClientProxyCore.lastSpacebarDown = false;
}
if (player.ridingEntity != null && isPressed && !ClientProxyCore.lastSpacebarDown) {
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_IGNITE_ROCKET, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}));
ClientProxyCore.lastSpacebarDown = true;
}
if (!(this.screenConnectionsUpdateList.isEmpty())) {
HashSet<TileEntityScreen> updateListCopy = (HashSet<TileEntityScreen>) screenConnectionsUpdateList.clone();
screenConnectionsUpdateList.clear();
for (TileEntityScreen te : updateListCopy) {
if (te.getWorld().getBlockState(te.getPos()).getBlock() == GCBlocks.screen) {
if (te.refreshOnUpdate) {
te.refreshConnections(true);
}
te.getWorld().markBlockRangeForRenderUpdate(te.getPos(), te.getPos());
}
}
}
} else if (event.phase == Phase.END) {
if (world != null) {
for (GalacticraftPacketHandler handler : packetHandlers) {
handler.tick(world);
}
}
}
}
Aggregations