use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.
the class EntitySpaceshipBase method onUpdate.
@Override
public void onUpdate() {
this.ticks++;
super.onUpdate();
if (this.addToTelemetry) {
this.addToTelemetry = false;
for (BlockVec3Dim vec : new ArrayList<BlockVec3Dim>(this.telemetryList)) {
TileEntity t1 = vec.getTileEntityNoLoad();
if (t1 instanceof TileEntityTelemetry && !t1.isInvalid()) {
if (((TileEntityTelemetry) t1).linkedEntity == this)
((TileEntityTelemetry) t1).addTrackedEntity(this);
}
}
}
if (this.riddenByEntity != null) {
this.riddenByEntity.fallDistance = 0.0F;
}
if (this.posY > (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) && this.launchPhase != EnumLaunchPhase.LANDING.ordinal()) {
this.onReachAtmosphere();
// if (this.worldObj.isRemote)
// this.posY = 1 + (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200);
}
if (this.rollAmplitude > 0) {
this.rollAmplitude--;
}
if (this.shipDamage > 0) {
this.shipDamage--;
}
if (!this.worldObj.isRemote) {
if (this.posY < 0.0D) {
this.setDead();
} else if (this.posY > (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) + (this.launchPhase == EnumLaunchPhase.LANDING.ordinal() ? 355 : 100)) {
if (this.riddenByEntity instanceof EntityPlayerMP) {
GCPlayerStats stats = GCPlayerStats.get(this.riddenByEntity);
if (stats.isUsingPlanetSelectionGui()) {
this.setDead();
}
} else
this.setDead();
}
if (this.timeSinceLaunch > 50 && this.onGround) {
this.failRocket();
}
}
if (this.launchPhase == EnumLaunchPhase.UNIGNITED.ordinal()) {
this.timeUntilLaunch = this.getPreLaunchWait();
}
if (this.launchPhase >= EnumLaunchPhase.LAUNCHED.ordinal()) {
this.timeSinceLaunch++;
} else {
this.timeSinceLaunch = 0;
}
if (this.timeUntilLaunch > 0 && this.launchPhase == EnumLaunchPhase.IGNITED.ordinal()) {
this.timeUntilLaunch--;
}
AxisAlignedBB box = null;
box = this.getEntityBoundingBox().expand(0.2D, 0.2D, 0.2D);
final List<?> var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box);
if (var15 != null && !var15.isEmpty()) {
for (int var52 = 0; var52 < var15.size(); ++var52) {
final Entity var17 = (Entity) var15.get(var52);
if (var17 != this.riddenByEntity) {
var17.applyEntityCollision(this);
}
}
}
if (this.timeUntilLaunch == 0 && this.launchPhase == EnumLaunchPhase.IGNITED.ordinal()) {
this.setLaunchPhase(EnumLaunchPhase.LAUNCHED);
this.onLaunch();
}
if (this.rotationPitch > 90) {
this.rotationPitch = 90;
}
if (this.rotationPitch < -90) {
this.rotationPitch = -90;
}
this.motionX = -(50 * Math.cos(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * Math.sin(this.rotationPitch * 0.01 / Constants.RADIANS_TO_DEGREES_D));
this.motionZ = -(50 * Math.sin(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * Math.sin(this.rotationPitch * 0.01 / Constants.RADIANS_TO_DEGREES_D));
if (this.launchPhase < EnumLaunchPhase.LAUNCHED.ordinal()) {
this.motionX = this.motionY = this.motionZ = 0.0F;
}
if (this.worldObj.isRemote) {
this.setPosition(this.posX, this.posY, this.posZ);
if (this.shouldMoveClientSide()) {
this.moveEntity(this.motionX, this.motionY, this.motionZ);
}
} else {
this.moveEntity(this.motionX, this.motionY, this.motionZ);
}
this.setRotation(this.rotationYaw, this.rotationPitch);
if (this.worldObj.isRemote) {
this.setPosition(this.posX, this.posY, this.posZ);
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (!this.worldObj.isRemote && this.ticks % 3 == 0) {
GalacticraftCore.packetPipeline.sendToDimension(new PacketDynamic(this), this.worldObj.provider.getDimensionId());
// PacketDispatcher.sendPacketToAllInDimension(GCCorePacketManager.getPacket(GalacticraftCore.CHANNELENTITIES,
// this, this.getNetworkedData(new ArrayList())),
// this.worldObj.provider.getDimensionId());
}
}
use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.
the class TileEntityArclamp method onLoad.
@Override
public void onLoad() {
this.thisPos = new Vec3(this.getPos().getX() + 0.5D, this.getPos().getY() + 0.5D, this.getPos().getZ() + 0.5D);
this.ticks = 0;
this.thisAABB = null;
if (this.worldObj.isRemote) {
this.buckets = bucketsClient;
this.usingBuckets = usingBucketsClient;
if (lightUpdateBlockListClient == null) {
lightUpdateBlockListClient = new int[SIZELIST];
}
this.lightUpdateBlockList = lightUpdateBlockListClient;
this.usingLightList = usingLightListClient;
this.clientOnLoad();
GalacticraftCore.packetPipeline.sendToServer(new PacketDynamic(this));
} else {
this.buckets = bucketsServer;
this.usingBuckets = usingBucketsServer;
if (lightUpdateBlockListServer == null) {
lightUpdateBlockListServer = new int[SIZELIST];
}
this.lightUpdateBlockList = lightUpdateBlockListServer;
this.usingLightList = usingLightListServer;
this.isActive = this.pos.getX() >= -30000000 + 32 && this.pos.getZ() >= -30000000 + 32 && this.pos.getX() < 30000000 - 32 && this.pos.getZ() < 30000000 - 32;
}
}
use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.
the class TileEntityFluidTank method getDescriptionPacket.
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("net-type", "desc-packet");
PacketDynamic packet = new PacketDynamic(this);
ByteBuf buf = Unpooled.buffer();
packet.encodeInto(buf);
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
nbt.setByteArray("net-data", bytes);
S35PacketUpdateTileEntity tileUpdate = new S35PacketUpdateTileEntity(getPos(), 0, nbt);
return tileUpdate;
}
use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.
the class TileEntityFluidTank method onDataPacket.
@Override
@SideOnly(Side.CLIENT)
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
if (!worldObj.isRemote) {
return;
}
if (pkt.getNbtCompound() == null) {
throw new RuntimeException("[GC] Missing NBTTag compound!");
}
NBTTagCompound nbt = pkt.getNbtCompound();
try {
if ("desc-packet".equals(nbt.getString("net-type"))) {
byte[] bytes = nbt.getByteArray("net-data");
ByteBuf data = Unpooled.wrappedBuffer(bytes);
PacketDynamic packet = new PacketDynamic();
packet.decodeInto(data);
packet.handleClientSide(FMLClientHandler.instance().getClientPlayerEntity());
}
} catch (Throwable t) {
throw new RuntimeException("[GC] Failed to read a packet! (" + nbt.getTag("net-type") + ", " + nbt.getTag("net-data"), t);
}
}
use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.
the class TileEntityFluidTank method update.
@Override
public void update() {
super.update();
if (fluidTank.getFluid() != null) {
moveFluidDown();
}
if (!this.worldObj.isRemote && updateClient && delayTimer.markTimeIfDelay(this.worldObj)) {
PacketDynamic packet = new PacketDynamic(this);
GalacticraftCore.packetPipeline.sendToAllAround(packet, new NetworkRegistry.TargetPoint(GCCoreUtil.getDimensionID(this.worldObj), getPos().getX(), getPos().getY(), getPos().getZ(), this.getPacketRange()));
this.updateClient = false;
}
}
Aggregations