use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.
the class PacketSimpleAsteroids method handleServerSide.
@Override
public void handleServerSide(EntityPlayer player) {
EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
switch(this.type) {
case S_UPDATE_ADVANCED_GUI:
TileEntity tile = player.worldObj.getTileEntity((BlockPos) this.data.get(1));
switch((Integer) this.data.get(0)) {
case 0:
if (tile instanceof TileEntityShortRangeTelepad) {
TileEntityShortRangeTelepad launchController = (TileEntityShortRangeTelepad) tile;
launchController.setAddress((Integer) this.data.get(2));
}
break;
case 1:
if (tile instanceof TileEntityShortRangeTelepad) {
TileEntityShortRangeTelepad launchController = (TileEntityShortRangeTelepad) tile;
launchController.setTargetAddress((Integer) this.data.get(2));
}
break;
default:
break;
}
break;
default:
break;
}
}
use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.
the class TileEntityShortRangeTelepad method update.
@Override
public void update() {
if (this.ticks % 40 == 0 && !worldObj.isRemote) {
this.setAddress(this.address);
this.setTargetAddress(this.targetAddress);
}
if (!this.worldObj.isRemote) {
if (this.targetAddressResult == EnumTelepadSearchResult.VALID && (this.ticks % 5 == 0 || teleporting)) {
List containedEntities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.fromBounds(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.getPos().getX() + 1, this.getPos().getY() + 2, this.getPos().getZ() + 1));
if (containedEntities.size() > 0 && this.getEnergyStoredGC() >= ENERGY_USE_ON_TELEPORT) {
ShortRangeTelepadHandler.TelepadEntry entry = ShortRangeTelepadHandler.getLocationFromAddress(this.targetAddress);
if (entry != null) {
teleporting = true;
}
} else {
teleporting = false;
}
}
if (this.teleporting) {
this.teleportTime++;
if (teleportTime >= MAX_TELEPORT_TIME) {
ShortRangeTelepadHandler.TelepadEntry entry = ShortRangeTelepadHandler.getLocationFromAddress(this.targetAddress);
BlockVec3 finalPos = (entry == null) ? null : entry.position;
if (finalPos != null) {
TileEntity tileAt = finalPos.getTileEntity(this.worldObj);
List<EntityLivingBase> containedEntities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.fromBounds(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.getPos().getX() + 1, this.getPos().getY() + 2, this.getPos().getZ() + 1));
if (tileAt != null && tileAt instanceof TileEntityShortRangeTelepad) {
TileEntityShortRangeTelepad destTelepad = (TileEntityShortRangeTelepad) tileAt;
int teleportResult = destTelepad.canTeleportHere();
if (teleportResult == 0) {
for (EntityLivingBase e : containedEntities) {
e.setPosition(finalPos.x + 0.5F, finalPos.y + 1.0F, finalPos.z + 0.5F);
this.worldObj.updateEntityWithOptionalForce(e, true);
if (e instanceof EntityPlayerMP) {
((EntityPlayerMP) e).playerNetServerHandler.setPlayerLocation(finalPos.x, finalPos.y, finalPos.z, e.rotationYaw, e.rotationPitch);
}
GalacticraftCore.packetPipeline.sendToDimension(new PacketSimpleAsteroids(PacketSimpleAsteroids.EnumSimplePacketAsteroids.C_TELEPAD_SEND, GCCoreUtil.getDimensionID(this.worldObj), new Object[] { finalPos, e.getEntityId() }), GCCoreUtil.getDimensionID(this.worldObj));
}
if (containedEntities.size() > 0) {
this.storage.setEnergyStored(this.storage.getEnergyStoredGC() - ENERGY_USE_ON_TELEPORT);
destTelepad.storage.setEnergyStored(this.storage.getEnergyStoredGC() - ENERGY_USE_ON_TELEPORT);
}
} else {
switch(teleportResult) {
case -1:
for (EntityLivingBase e : containedEntities) {
if (e instanceof EntityPlayer) {
// No need for translation, since this should never happen
((EntityPlayer) e).addChatComponentMessage(new ChatComponentText("Cannot Send client-side"));
}
}
break;
case 1:
for (EntityLivingBase e : containedEntities) {
if (e instanceof EntityPlayer) {
// No need for translation, since this should never happen
((EntityPlayer) e).addChatComponentMessage(new ChatComponentText("Target address invalid"));
}
}
break;
case 2:
for (EntityLivingBase e : containedEntities) {
if (e instanceof EntityPlayer) {
((EntityPlayer) e).addChatComponentMessage(new ChatComponentText(GCCoreUtil.translate("gui.message.target_no_energy.name")));
}
}
break;
}
}
}
}
this.teleportTime = 0;
this.teleporting = false;
}
} else {
this.teleportTime = Math.max(--this.teleportTime, 0);
}
}
super.update();
}
use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.
the class ShortRangeTelepadHandler method addShortRangeTelepad.
public static void addShortRangeTelepad(TileEntityShortRangeTelepad telepad) {
if (!telepad.getWorld().isRemote) {
if (telepad.addressValid) {
TelepadEntry newEntry = new TelepadEntry(GCCoreUtil.getDimensionID(telepad.getWorld()), new BlockVec3(telepad));
TelepadEntry previous = tileMap.put(telepad.address, newEntry);
if (previous == null || !previous.equals(newEntry)) {
AsteroidsTickHandlerServer.spaceRaceData.setDirty(true);
}
}
}
}
use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.
the class EntityFXTeleport method onUpdate.
@Override
public void onUpdate() {
TileEntityShortRangeTelepad telepad1 = this.telepad.get();
if (telepad1 != null) {
Vector3 color = telepad1.getParticleColor(this.rand, this.direction);
this.particleRed = color.floatX();
this.particleGreen = color.floatY();
this.particleBlue = color.floatZ();
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
float f = (float) this.particleAge / (float) this.particleMaxAge;
float f1 = f;
f = -f + f * f * 2.0F;
f = 1.0F - f;
this.posX = this.portalPosX + this.motionX * f;
this.posY = this.portalPosY + this.motionY * f + (1.0F - f1);
this.posZ = this.portalPosZ + this.motionZ * f;
if (this.particleAge++ >= this.particleMaxAge) {
this.setDead();
}
}
use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.
the class AsteroidsModuleClient method spawnParticle.
@Override
public void spawnParticle(String particleID, Vector3 position, Vector3 motion, Object... extraData) {
Minecraft mc = FMLClientHandler.instance().getClient();
if (mc != null && mc.getRenderViewEntity() != null && mc.effectRenderer != null) {
double dX = mc.getRenderViewEntity().posX - position.x;
double dY = mc.getRenderViewEntity().posY - position.y;
double dZ = mc.getRenderViewEntity().posZ - position.z;
EntityFX particle = null;
double viewDistance = 64.0D;
if (dX * dX + dY * dY + dZ * dZ < viewDistance * viewDistance) {
if (particleID.equals("portalBlue")) {
particle = new EntityFXTeleport(mc.theWorld, position, motion, (TileEntityShortRangeTelepad) extraData[0], (Boolean) extraData[1]);
} else if (particleID.equals("cryoFreeze")) {
particle = new EntityCryoFX(mc.theWorld, position, motion);
}
}
if (particle != null) {
particle.prevPosX = particle.posX;
particle.prevPosY = particle.posY;
particle.prevPosZ = particle.posZ;
mc.effectRenderer.addEffect(particle);
}
}
}
Aggregations