use of micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket in project Galacticraft by micdoodle8.
the class EntityAutoRocket method onUpdate.
@Override
public void onUpdate() {
// Weird, huh?
if (this.worldObj.isRemote && this.addedToChunk) {
Chunk chunk = this.worldObj.getChunkFromChunkCoords(this.chunkCoordX, this.chunkCoordZ);
int cx = MathHelper.floor_double(this.posX) >> 4;
int cz = MathHelper.floor_double(this.posZ) >> 4;
if (chunk.isChunkLoaded && this.chunkCoordX == cx && this.chunkCoordZ == cz) {
boolean thisfound = false;
ClassInheritanceMultiMap<Entity> mapEntities = chunk.getEntityLists()[this.chunkCoordY];
for (Entity ent : mapEntities) {
if (ent == this) {
thisfound = true;
break;
}
}
if (!thisfound) {
chunk.addEntity(this);
}
}
}
if (this.launchPhase == EnumLaunchPhase.LANDING.ordinal() && this.hasValidFuel()) {
if (this.targetVec != null) {
double yDiff = this.posY - this.getOnPadYOffset() - this.targetVec.getY();
this.motionY = Math.max(-2.0, (yDiff - 0.04) / -55.0);
// Some lateral motion in case not exactly on target (happens if rocket was moving laterally during launch)
double diff = this.posX - this.targetVec.getX() - 0.5D;
double motX, motZ;
if (diff > 0D) {
motX = Math.max(-0.1, diff / -100.0D);
} else if (diff < 0D) {
motX = Math.min(0.1, diff / -100.0D);
} else
motX = 0D;
diff = this.posZ - this.targetVec.getZ() - 0.5D;
if (diff > 0D) {
motZ = Math.max(-0.1, diff / -100.0D);
} else if (diff < 0D) {
motZ = Math.min(0.1, diff / -100.0D);
} else
motZ = 0D;
if (motZ != 0D || motX != 0D) {
double angleYaw = Math.atan(motZ / motX);
double signed = motX < 0 ? 50D : -50D;
double anglePitch = Math.atan(Math.sqrt(motZ * motZ + motX * motX) / signed) * 100D;
this.rotationYaw = (float) angleYaw * Constants.RADIANS_TO_DEGREES;
this.rotationPitch = (float) anglePitch * Constants.RADIANS_TO_DEGREES;
} else
this.rotationPitch = 0F;
if (yDiff > 1D && yDiff < 4D) {
for (Object o : this.worldObj.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().offset(0D, -3D, 0D), EntitySpaceshipBase.rocketSelector)) {
if (o instanceof EntitySpaceshipBase) {
((EntitySpaceshipBase) o).dropShipAsItem();
((EntitySpaceshipBase) o).setDead();
}
}
}
if (yDiff < 0.4) {
int yMin = MathHelper.floor_double(this.getEntityBoundingBox().minY - this.getOnPadYOffset() - 0.45D) - 2;
int yMax = MathHelper.floor_double(this.getEntityBoundingBox().maxY) + 1;
int zMin = MathHelper.floor_double(this.posZ) - 1;
int zMax = MathHelper.floor_double(this.posZ) + 1;
for (int x = MathHelper.floor_double(this.posX) - 1; x <= MathHelper.floor_double(this.posX) + 1; x++) {
for (int z = zMin; z <= zMax; z++) {
// Doing y as the inner loop may help with cacheing of chunks
for (int y = yMin; y <= yMax; y++) {
if (this.worldObj.getTileEntity(new BlockPos(x, y, z)) instanceof IFuelDock) {
// Land the rocket on the pad found
this.rotationPitch = 0F;
this.failRocket();
}
}
}
}
}
}
}
super.onUpdate();
if (!this.worldObj.isRemote) {
if (this.statusMessageCooldown > 0) {
this.statusMessageCooldown--;
}
if (this.statusMessageCooldown == 0 && this.lastStatusMessageCooldown > 0 && this.statusValid) {
this.autoLaunch();
}
if (this.autoLaunchCountdown > 0 && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
if (--this.autoLaunchCountdown <= 0) {
this.autoLaunch();
}
}
if (this.autoLaunchSetting == EnumAutoLaunch.ROCKET_IS_FUELED && this.fuelTank.getFluidAmount() == this.fuelTank.getCapacity() && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
this.autoLaunch();
}
if (this.autoLaunchSetting == EnumAutoLaunch.INSTANT) {
if (this.autoLaunchCountdown == 0 && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
this.autoLaunch();
}
}
if (this.autoLaunchSetting == EnumAutoLaunch.REDSTONE_SIGNAL) {
if (this.ticks % 11 == 0 && this.activeLaunchController != null) {
if (RedstoneUtil.isBlockReceivingRedstone(this.worldObj, this.activeLaunchController.toBlockPos())) {
this.autoLaunch();
}
}
}
if (this.launchPhase >= EnumLaunchPhase.LAUNCHED.ordinal()) {
this.setPad(null);
} else {
if (this.launchPhase == EnumLaunchPhase.UNIGNITED.ordinal() && this.landingPad != null && this.ticks % 17 == 0) {
this.updateControllerSettings(this.landingPad);
}
}
this.lastStatusMessageCooldown = this.statusMessageCooldown;
}
if (this.launchPhase >= EnumLaunchPhase.IGNITED.ordinal()) {
if (this.rocketSoundUpdater != null) {
this.rocketSoundUpdater.update();
this.rocketSoundToStop = true;
}
} else {
// Not ignited - either because not yet launched, or because it has landed
if (this.rocketSoundToStop) {
this.stopRocketSound();
this.rocketSoundUpdater = null;
}
}
}
use of micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket 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.api.prefab.entity.EntityTieredRocket in project Galacticraft by micdoodle8.
the class GuiHandler method getClientGuiElement.
@SideOnly(Side.CLIENT)
private Object getClientGuiElement(int ID, EntityPlayer player, World world, BlockPos position) {
EntityPlayerSP playerClient = PlayerUtil.getPlayerBaseClientFromPlayer(player, false);
if (ID == GuiIdsCore.GALAXY_MAP) {
return new GuiCelestialSelection(true, null);
} else if (ID == GuiIdsCore.ROCKET_INVENTORY && player.ridingEntity instanceof EntityTieredRocket) {
return new GuiRocketInventory(player.inventory, (EntityTieredRocket) player.ridingEntity, ((EntityTieredRocket) player.ridingEntity).getType());
} else if (ID == GuiIdsCore.EXTENDED_INVENTORY) {
return new GuiExtendedInventory(player, ClientProxyCore.dummyInventory);
} else if (ID == GuiIdsCore.SPACE_RACE_START) {
return new GuiNewSpaceRace(player);
} else if (ID == GuiIdsCore.SPACE_RACE_JOIN) {
return new GuiJoinSpaceRace(playerClient);
} else if (ID == GuiIdsCore.PRE_LAUNCH_CHECKLIST) {
return new GuiPreLaunchChecklist(WorldUtil.getAllChecklistKeys(), player.getHeldItem().hasTagCompound() ? (NBTTagCompound) player.getHeldItem().getTagCompound().getTag("checklistData") : null);
}
TileEntity tile = world.getTileEntity(position);
if (tile != null) {
if (tile instanceof TileEntityCrafting) {
return new GuiCrafting(player.inventory, (TileEntityCrafting) tile);
} else if (tile instanceof TileEntityRefinery) {
return new GuiRefinery(player.inventory, (TileEntityRefinery) world.getTileEntity(position));
} else if (tile instanceof TileEntityOxygenCollector) {
return new GuiOxygenCollector(player.inventory, (TileEntityOxygenCollector) tile);
} else if (tile instanceof TileEntityOxygenDistributor) {
return new GuiOxygenDistributor(player.inventory, (TileEntityOxygenDistributor) tile);
} else if (tile instanceof TileEntityFuelLoader) {
return new GuiFuelLoader(player.inventory, (TileEntityFuelLoader) tile);
} else if (tile instanceof TileEntityOxygenSealer) {
return new GuiOxygenSealer(player.inventory, (TileEntityOxygenSealer) tile);
} else if (tile instanceof TileEntityCargoLoader) {
return new GuiCargoLoader(player.inventory, (TileEntityCargoLoader) tile);
} else if (tile instanceof TileEntityCargoUnloader) {
return new GuiCargoUnloader(player.inventory, (TileEntityCargoUnloader) tile);
} else if (tile instanceof TileEntityParaChest) {
return new GuiParaChest(player.inventory, (TileEntityParaChest) tile);
} else if (tile instanceof TileEntitySolar) {
return new GuiSolar(player.inventory, (TileEntitySolar) tile);
} else if (tile instanceof TileEntityAirLockController) {
return new GuiAirLockController((TileEntityAirLockController) tile);
} else if (tile instanceof TileEntityEnergyStorageModule) {
return new GuiEnergyStorageModule(player.inventory, (TileEntityEnergyStorageModule) tile);
} else if (tile instanceof TileEntityCoalGenerator) {
return new GuiCoalGenerator(player.inventory, (TileEntityCoalGenerator) tile);
} else if (tile instanceof TileEntityElectricFurnace) {
return new GuiElectricFurnace(player.inventory, (TileEntityElectricFurnace) tile);
} else if (tile instanceof TileEntityIngotCompressor) {
return new GuiIngotCompressor(player.inventory, (TileEntityIngotCompressor) tile);
} else if (tile instanceof TileEntityElectricIngotCompressor) {
return new GuiElectricIngotCompressor(player.inventory, (TileEntityElectricIngotCompressor) tile);
} else if (tile instanceof TileEntityCircuitFabricator) {
return new GuiCircuitFabricator(player.inventory, (TileEntityCircuitFabricator) tile);
} else if (tile instanceof TileEntityOxygenStorageModule) {
return new GuiOxygenStorageModule(player.inventory, (TileEntityOxygenStorageModule) tile);
} else if (tile instanceof TileEntityOxygenCompressor) {
return new GuiOxygenCompressor(player.inventory, (TileEntityOxygenCompressor) tile);
} else if (tile instanceof TileEntityOxygenDecompressor) {
return new GuiOxygenDecompressor(player.inventory, (TileEntityOxygenDecompressor) tile);
} else if (tile instanceof TileEntityDeconstructor) {
return new GuiDeconstructor(player.inventory, (TileEntityDeconstructor) tile);
} else if (tile instanceof TileEntityPainter) {
return new GuiPainter(player.inventory, (TileEntityPainter) tile);
}
}
if (playerClient != null) {
GCPlayerStatsClient stats = GCPlayerStatsClient.get(playerClient);
for (ISchematicPage page : stats.getUnlockedSchematics()) {
if (ID == page.getGuiID()) {
GuiScreen screen = page.getResultScreen(playerClient, position);
if (screen instanceof ISchematicResultPage) {
((ISchematicResultPage) screen).setPageIndex(page.getPageID());
}
return screen;
}
}
}
return null;
}
use of micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket in project Galacticraft by micdoodle8.
the class GuiHandler method getServerGuiElement.
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
if (playerBase == null) {
player.addChatMessage(new ChatComponentText("Galacticraft player instance null server-side. This is a bug."));
return null;
}
GCPlayerStats stats = GCPlayerStats.get(playerBase);
if (ID == GuiIdsCore.ROCKET_INVENTORY && player.ridingEntity instanceof EntityTieredRocket) {
return new ContainerRocketInventory(player.inventory, (EntityTieredRocket) player.ridingEntity, ((EntityTieredRocket) player.ridingEntity).getType(), player);
} else if (ID == GuiIdsCore.EXTENDED_INVENTORY) {
return new ContainerExtendedInventory(player, stats.getExtendedInventory());
}
BlockPos pos = new BlockPos(x, y, z);
TileEntity tile = world.getTileEntity(pos);
if (tile != null) {
if (tile instanceof TileEntityCrafting) {
return new ContainerCrafting(player.inventory, (TileEntityCrafting) tile);
} else if (tile instanceof TileEntityRefinery) {
return new ContainerRefinery(player.inventory, (TileEntityRefinery) tile, player);
} else if (tile instanceof TileEntityOxygenCollector) {
return new ContainerOxygenCollector(player.inventory, (TileEntityOxygenCollector) tile);
} else if (tile instanceof TileEntityOxygenDistributor) {
return new ContainerOxygenDistributor(player.inventory, (TileEntityOxygenDistributor) tile);
} else if (tile instanceof TileEntityFuelLoader) {
return new ContainerFuelLoader(player.inventory, (TileEntityFuelLoader) tile);
} else if (tile instanceof TileEntityOxygenSealer) {
return new ContainerOxygenSealer(player.inventory, (TileEntityOxygenSealer) tile);
} else if (tile instanceof TileEntityCargoLoader) {
return new ContainerCargoLoader(player.inventory, (TileEntityCargoLoader) tile);
} else if (tile instanceof TileEntityCargoUnloader) {
return new ContainerCargoLoader(player.inventory, (TileEntityCargoUnloader) tile);
} else if (tile instanceof TileEntityParaChest) {
return new ContainerParaChest(player.inventory, (TileEntityParaChest) tile, player);
} else if (tile instanceof TileEntitySolar) {
return new ContainerSolar(player.inventory, (TileEntitySolar) tile);
} else if (tile instanceof TileEntityEnergyStorageModule) {
return new ContainerEnergyStorageModule(player.inventory, (TileEntityEnergyStorageModule) tile);
} else if (tile instanceof TileEntityCoalGenerator) {
return new ContainerCoalGenerator(player.inventory, (TileEntityCoalGenerator) tile);
} else if (tile instanceof TileEntityElectricFurnace) {
return new ContainerElectricFurnace(player.inventory, (TileEntityElectricFurnace) tile);
} else if (tile instanceof TileEntityIngotCompressor) {
return new ContainerIngotCompressor(player.inventory, (TileEntityIngotCompressor) tile);
} else if (tile instanceof TileEntityElectricIngotCompressor) {
return new ContainerElectricIngotCompressor(player.inventory, (TileEntityElectricIngotCompressor) tile);
} else if (tile instanceof TileEntityCircuitFabricator) {
return new ContainerCircuitFabricator(player.inventory, (TileEntityCircuitFabricator) tile);
} else if (tile instanceof TileEntityOxygenStorageModule) {
return new ContainerOxygenStorageModule(player.inventory, (TileEntityOxygenStorageModule) tile);
} else if (tile instanceof TileEntityOxygenCompressor) {
return new ContainerOxygenCompressor(player.inventory, (TileEntityOxygenCompressor) tile, player);
} else if (tile instanceof TileEntityOxygenDecompressor) {
return new ContainerOxygenDecompressor(player.inventory, (TileEntityOxygenDecompressor) tile, player);
} else if (tile instanceof TileEntityDeconstructor) {
return new ContainerDeconstructor(player.inventory, (TileEntityDeconstructor) tile);
} else if (tile instanceof TileEntityPainter) {
return new ContainerPainter(player.inventory, (TileEntityPainter) tile);
}
}
for (ISchematicPage page : stats.getUnlockedSchematics()) {
if (ID == page.getGuiID()) {
return page.getResultContainer(playerBase, new BlockPos(x, y, z));
}
}
return null;
}
use of micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket in project Galacticraft by micdoodle8.
the class ModelBipedGC method setRotationAngles.
public static void setRotationAngles(ModelBiped biped, float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {
if (!(par7Entity instanceof EntityPlayer))
return;
final EntityPlayer player = (EntityPlayer) par7Entity;
final ItemStack currentItemStack = player.inventory.getCurrentItem();
final float floatPI = 3.1415927F;
if (!par7Entity.onGround && par7Entity.worldObj.provider instanceof IGalacticraftWorldProvider && par7Entity.ridingEntity == null && !(currentItemStack != null && currentItemStack.getItem() instanceof IHoldableItem)) {
float speedModifier = 0.1162F * 2;
float angularSwingArm = MathHelper.cos(par1 * (speedModifier / 2));
float rightMod = biped.heldItemRight != 0 ? 1 : 2;
biped.bipedRightArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * rightMod * par2 * 0.5F;
biped.bipedLeftArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
biped.bipedRightArm.rotateAngleX += -angularSwingArm * 4.0F * par2 * 0.5F;
biped.bipedLeftArm.rotateAngleX += angularSwingArm * 4.0F * par2 * 0.5F;
biped.bipedLeftLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * 1.4F * par2;
biped.bipedLeftLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2 + floatPI) * 1.4F * par2;
biped.bipedRightLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
biped.bipedRightLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2) * 1.4F * par2;
}
PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
if (gearData != null) {
if (gearData.getParachute() != null) {
// Parachute is equipped
biped.bipedLeftArm.rotateAngleX += floatPI;
biped.bipedLeftArm.rotateAngleZ += floatPI / 10;
biped.bipedRightArm.rotateAngleX += floatPI;
biped.bipedRightArm.rotateAngleZ -= floatPI / 10;
}
}
if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof IHoldableItem && !(player.ridingEntity instanceof ICameraZoomEntity)) {
Item heldItem = player.inventory.getCurrentItem().getItem();
IHoldableItem holdableItem = (IHoldableItem) heldItem;
IHoldableItemCustom holdableItemCustom = heldItem instanceof IHoldableItemCustom ? (IHoldableItemCustom) heldItem : null;
if (holdableItem.shouldHoldLeftHandUp(player)) {
Vector3 angle = null;
if (holdableItemCustom != null) {
angle = holdableItemCustom.getLeftHandRotation(player);
}
if (angle == null) {
angle = new Vector3(floatPI + 0.3F, 0.0F, floatPI / 10.0F);
}
biped.bipedLeftArm.rotateAngleX = angle.floatX();
biped.bipedLeftArm.rotateAngleY = angle.floatY();
biped.bipedLeftArm.rotateAngleZ = angle.floatZ();
}
if (holdableItem.shouldHoldRightHandUp(player)) {
Vector3 angle = null;
if (holdableItemCustom != null) {
angle = holdableItemCustom.getRightHandRotation(player);
}
if (angle == null) {
angle = new Vector3(floatPI + 0.3F, 0.0F, (float) -Math.PI / 10.0F);
}
biped.bipedRightArm.rotateAngleX = angle.floatX();
biped.bipedRightArm.rotateAngleY = angle.floatY();
biped.bipedRightArm.rotateAngleZ = angle.floatZ();
}
}
final List<?> l = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.fromBounds(player.posX - 20, 0, player.posZ - 20, player.posX + 20, 200, player.posZ + 20));
for (int i = 0; i < l.size(); i++) {
final Entity e = (Entity) l.get(i);
if (e instanceof EntityTieredRocket) {
final EntityTieredRocket ship = (EntityTieredRocket) e;
if (ship.riddenByEntity != null && !(ship.riddenByEntity).equals(player) && (ship.getLaunched() || ship.timeUntilLaunch < 390)) {
biped.bipedRightArm.rotateAngleZ -= floatPI / 8F + MathHelper.sin(par3 * 0.9F) * 0.2F;
biped.bipedRightArm.rotateAngleX = floatPI;
break;
}
}
}
if (player.isPlayerSleeping() && GalacticraftCore.isPlanetsLoaded) {
RenderPlayerGC.RotatePlayerEvent event = new RenderPlayerGC.RotatePlayerEvent((AbstractClientPlayer) player);
MinecraftForge.EVENT_BUS.post(event);
if (event.vanillaOverride && (event.shouldRotate == null || event.shouldRotate)) {
biped.bipedHead.rotateAngleX = (float) (20.0F - Math.sin(player.ticksExisted / 10.0F) / 7.0F);
biped.bipedHead.rotateAngleY = 0.0F;
biped.bipedHead.rotateAngleZ = 0.0F;
biped.bipedLeftArm.rotateAngleX = 0.0F;
biped.bipedLeftArm.rotateAngleY = 0.0F;
biped.bipedLeftArm.rotateAngleZ = 0.0F;
biped.bipedRightArm.rotateAngleX = 0.0F;
biped.bipedRightArm.rotateAngleY = 0.0F;
biped.bipedRightArm.rotateAngleZ = 0.0F;
}
}
if (biped instanceof ModelPlayer) {
ModelBiped.copyModelAngles(biped.bipedHead, ((ModelPlayer) biped).bipedHeadwear);
}
}
Aggregations