use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class CommonProxyCore method getGearData.
public PlayerGearData getGearData(EntityPlayer player) {
GCPlayerStats stats = GCPlayerStats.get(player);
int mask = stats.getMaskInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getMaskInSlot(), EnumExtendedInventorySlot.MASK);
int gear = stats.getGearInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getGearInSlot(), EnumExtendedInventorySlot.GEAR);
int leftTank = stats.getTankInSlot1() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getTankInSlot1(), EnumExtendedInventorySlot.LEFT_TANK);
int rightTank = stats.getTankInSlot2() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getTankInSlot2(), EnumExtendedInventorySlot.RIGHT_TANK);
int frequencyModule = stats.getFrequencyModuleInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getFrequencyModuleInSlot(), EnumExtendedInventorySlot.FREQUENCY_MODULE);
int[] thermalPadding = new int[4];
thermalPadding[0] = stats.getThermalHelmetInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getThermalHelmetInSlot(), EnumExtendedInventorySlot.THERMAL_HELMET);
thermalPadding[1] = stats.getThermalChestplateInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getThermalChestplateInSlot(), EnumExtendedInventorySlot.THERMAL_CHESTPLATE);
thermalPadding[2] = stats.getThermalLeggingsInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getThermalLeggingsInSlot(), EnumExtendedInventorySlot.THERMAL_LEGGINGS);
thermalPadding[3] = stats.getThermalBootsInSlot() == null ? GCPlayerHandler.GEAR_NOT_PRESENT : GalacticraftRegistry.findMatchingGearID(stats.getThermalBootsInSlot(), EnumExtendedInventorySlot.THERMAL_BOOTS);
// TODO: Parachute
return new PlayerGearData(player, mask, gear, leftTank, rightTank, frequencyModule, thermalPadding);
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class TileEntityTelemetry method update.
@Override
public void update() {
if (!this.world.isRemote && ++this.ticks % 2 == 0) {
if (this.toUpdate != null) {
this.addTrackedEntity(this.toUpdate);
this.toUpdate = null;
}
String name = null;
int[] data = { -1, -1, -1, -1, -1 };
String strUUID = "";
if (linkedEntity != null) {
// Help the Garbage Collector
if (linkedEntity.isDead) {
linkedEntity = null;
name = "";
// TODO: track players after death and respawn? or not?
} else {
if (linkedEntity instanceof EntityPlayerMP) {
name = "$" + linkedEntity.getName();
} else {
EntityEntry entityEntry = EntityRegistry.getEntry(linkedEntity.getClass());
if (entityEntry != null && entityEntry.getRegistryName() != null) {
name = entityEntry.getRegistryName().toString();
}
}
if (name == null) {
GCLog.info("Telemetry Unit: Error finding name for " + linkedEntity.getClass().getSimpleName());
name = "";
}
double xmotion = linkedEntity.motionX;
double ymotion = linkedEntity instanceof EntityLivingBase ? linkedEntity.motionY + 0.078D : linkedEntity.motionY;
double zmotion = linkedEntity.motionZ;
data[2] = (int) (MathHelper.sqrt(xmotion * xmotion + ymotion * ymotion + zmotion * zmotion) * 2000D);
if (linkedEntity instanceof ITelemetry) {
((ITelemetry) linkedEntity).transmitData(data);
} else if (linkedEntity instanceof EntityLivingBase) {
EntityLivingBase eLiving = (EntityLivingBase) linkedEntity;
data[0] = eLiving.hurtTime;
// Calculate a "pulse rate" based on motion and taking damage
this.pulseRate--;
if (eLiving.hurtTime > this.lastHurttime) {
this.pulseRate += 100;
}
this.lastHurttime = eLiving.hurtTime;
if (eLiving.getRidingEntity() != null) {
// reduced pulse effect if riding a vehicle
data[2] /= 4;
} else if (data[2] > 1) {
this.pulseRate += 2;
}
this.pulseRate += Math.max(data[2] - pulseRate, 0) / 4;
if (this.pulseRate > 2000) {
this.pulseRate = 2000;
}
if (this.pulseRate < 400) {
this.pulseRate = 400;
}
data[2] = this.pulseRate / 10;
data[1] = (int) (eLiving.getHealth() * 100 / eLiving.getMaxHealth());
if (eLiving instanceof EntityPlayerMP) {
data[3] = ((EntityPlayerMP) eLiving).getFoodStats().getFoodLevel() * 5;
GCPlayerStats stats = GCPlayerStats.get(eLiving);
data[4] = stats.getAirRemaining() * 4096 + stats.getAirRemaining2();
UUID uuid = ((EntityPlayerMP) eLiving).getUniqueID();
if (uuid != null) {
strUUID = uuid.toString();
}
} else if (eLiving instanceof EntityHorse) {
// data[3] = ((EntityHorse) eLiving).getType().ordinal();
data[4] = ((EntityHorse) eLiving).getHorseVariant();
} else if (eLiving instanceof EntityVillager) {
data[3] = ((EntityVillager) eLiving).getProfession();
data[4] = ((EntityVillager) eLiving).getGrowingAge();
} else if (eLiving instanceof EntityWolf) {
data[3] = ((EntityWolf) eLiving).getCollarColor().getDyeDamage();
data[4] = ((EntityWolf) eLiving).isBegging() ? 1 : 0;
} else if (eLiving instanceof EntitySheep) {
data[3] = ((EntitySheep) eLiving).getFleeceColor().getDyeDamage();
data[4] = ((EntitySheep) eLiving).getSheared() ? 1 : 0;
} else if (eLiving instanceof EntityOcelot) {
data[3] = ((EntityOcelot) eLiving).getTameSkin();
} else if (eLiving instanceof EntitySkeleton) {
// data[3] = ((EntitySkeleton) eLiving).getSkeletonType().ordinal();
} else if (eLiving instanceof EntityZombie) {
// data[3] = ((EntityZombie) eLiving).isVillager() ? 1 : 0; TODO Fix for MC 1.10
data[4] = ((EntityZombie) eLiving).isChild() ? 1 : 0;
}
}
}
} else {
name = "";
}
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_UPDATE_TELEMETRY, this.world.provider.getDimension(), new Object[] { this.getPos(), name, data[0], data[1], data[2], data[3], data[4], strUUID }), new TargetPoint(this.world.provider.getDimension(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 320D));
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class WorldUtil method teleportEntitySimple.
public static Entity teleportEntitySimple(World worldNew, int dimID, EntityPlayerMP player, Vector3 spawnPos) {
if (player.getRidingEntity() != null) {
player.getRidingEntity().setDead();
player.dismountRidingEntity();
}
World worldOld = player.world;
int oldDimID = GCCoreUtil.getDimensionID(worldOld);
boolean dimChange = worldOld != worldNew;
// Make sure the entity is added to the correct chunk in the OLD world so that it will be properly removed later if it needs to be unloaded from that world
worldOld.updateEntityWithOptionalForce(player, false);
if (dimChange) {
player.dimension = dimID;
if (ConfigManagerCore.enableDebug) {
GCLog.info("DEBUG: Sending respawn packet to player for dim " + dimID);
}
player.connection.sendPacket(new SPacketRespawn(dimID, player.world.getDifficulty(), player.world.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
if (worldNew.provider instanceof WorldProviderSpaceStation) {
if (WorldUtil.registeredSpaceStations.containsKey(dimID)) // TODO This has never been effective before due to the earlier bug - what does it actually do?
{
NBTTagCompound var2 = new NBTTagCompound();
SpaceStationWorldData.getStationData(worldNew, dimID, player).writeToNBT(var2);
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SPACESTATION_DATA, GCCoreUtil.getDimensionID(player.world), new Object[] { dimID, var2 }), player);
}
}
removeEntityFromWorld(worldOld, player, true);
forceMoveEntityToPos(player, (WorldServer) worldNew, spawnPos, true);
GCLog.info("Server attempting to transfer player " + PlayerUtil.getName(player) + " to dimension " + GCCoreUtil.getDimensionID(worldNew));
player.mcServer.getPlayerList().preparePlayer(player, (WorldServer) worldOld);
player.interactionManager.setWorld((WorldServer) worldNew);
player.mcServer.getPlayerList().updateTimeAndWeatherForPlayer(player, (WorldServer) worldNew);
player.mcServer.getPlayerList().syncPlayerInventory(player);
for (Object o : player.getActivePotionEffects()) {
PotionEffect var10 = (PotionEffect) o;
player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), var10));
}
player.connection.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
FMLCommonHandler.instance().firePlayerChangedDimensionEvent((EntityPlayerMP) player, oldDimID, dimID);
} else {
forceMoveEntityToPos(player, (WorldServer) worldNew, spawnPos, false);
GCLog.info("Server attempting to transfer player " + PlayerUtil.getName(player) + " within same dimension " + GCCoreUtil.getDimensionID(worldNew));
}
player.capabilities.isFlying = false;
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RESET_THIRD_PERSON, GCCoreUtil.getDimensionID(player.world), new Object[] {}), player);
// Update PlayerStatsGC
GCPlayerStats stats = GCPlayerStats.get(player);
GCPlayerHandler.setUsingParachute(player, stats, false);
return player;
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class AsteroidsTickHandlerServer method removeChunkData.
public static void removeChunkData(GCPlayerStats stats, EntityAstroMiner entityToRemove) {
int index = 0;
for (EntityAstroMiner miner : activeMiners) {
if (// Found it in the list here
miner == entityToRemove) {
List<BlockVec3> list = stats.getActiveAstroMinerChunks();
Iterator<BlockVec3> it = list.iterator();
while (it.hasNext()) {
BlockVec3 data = it.next();
if (// Found it in the player's stats
data.sideDoneBits == index) {
it.remove();
return;
}
}
return;
}
index++;
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class ItemThermalPadding method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
if (player instanceof EntityPlayerMP) {
GCPlayerStats stats = GCPlayerStats.get(player);
ItemStack gear = stats.getExtendedInventory().getStackInSlot(6);
ItemStack gear1 = stats.getExtendedInventory().getStackInSlot(7);
ItemStack gear2 = stats.getExtendedInventory().getStackInSlot(8);
ItemStack gear3 = stats.getExtendedInventory().getStackInSlot(9);
if (itemStack.getItemDamage() == 0) {
if (gear.isEmpty()) {
stats.getExtendedInventory().setInventorySlotContents(6, itemStack.copy());
itemStack.setCount(0);
}
} else if (itemStack.getItemDamage() == 1) {
if (gear1.isEmpty()) {
stats.getExtendedInventory().setInventorySlotContents(7, itemStack.copy());
itemStack.setCount(0);
}
} else if (itemStack.getItemDamage() == 2) {
if (gear2.isEmpty()) {
stats.getExtendedInventory().setInventorySlotContents(8, itemStack.copy());
itemStack.setCount(0);
}
} else if (itemStack.getItemDamage() == 3) {
if (gear3.isEmpty()) {
stats.getExtendedInventory().setInventorySlotContents(9, itemStack.copy());
itemStack.setCount(0);
}
}
}
return new ActionResult<>(EnumActionResult.PASS, itemStack);
}
Aggregations