use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.
the class TileEntityOxygenDistributor method invalidate.
@Override
public void invalidate() {
if (!this.worldObj.isRemote) /* && this.oxygenBubble != null*/
{
int bubbleR = MathHelper.ceiling_double_int(bubbleSize);
int bubbleR2 = (int) (bubbleSize * bubbleSize);
final int xMin = this.getPos().getX() - bubbleR;
final int xMax = this.getPos().getX() + bubbleR;
final int yMin = this.getPos().getY() - bubbleR;
final int yMax = this.getPos().getY() + bubbleR;
final int zMin = this.getPos().getZ() - bubbleR;
final int zMax = this.getPos().getZ() + bubbleR;
for (int x = xMin; x < xMax; x++) {
for (int z = zMin; z < zMax; z++) {
// Doing y as the inner loop allows BlockVec3 to cache the chunks more efficiently
for (int y = yMin; y < yMax; y++) {
Block block = new BlockVec3(x, y, z).getBlockID(this.worldObj);
if (block instanceof IOxygenReliantBlock && this.getDistanceFromServer(x, y, z) <= bubbleR2) {
this.worldObj.scheduleUpdate(new BlockPos(x, y, z), block, 0);
}
}
}
}
// this.oxygenBubble.setDead();
TileEntityOxygenDistributor.loadedTiles.remove(new BlockVec3Dim(this));
}
super.invalidate();
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.
the class TileEntityOxygenDistributor method readExtraNetworkedData.
@Override
public void readExtraNetworkedData(ByteBuf dataStream) {
if (this.worldObj.isRemote) {
// if (dataStream.readBoolean())
// {
// this.oxygenBubble = (EntityBubble) worldObj.getEntityByID(dataStream.readInt());
// }
int size = dataStream.readInt();
if (size >= 0) {
loadedTiles.clear();
for (int i = 0; i < size; ++i) {
int i1 = dataStream.readInt();
int i2 = dataStream.readInt();
int i3 = dataStream.readInt();
int i4 = dataStream.readInt();
if (i1 == -1 && i2 == -1 && i3 == -1 && i4 == -1) {
continue;
}
loadedTiles.add(new BlockVec3Dim(i1, i2, i3, i4));
}
}
this.bubbleSize = dataStream.readFloat();
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim 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.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.
the class EntitySpaceshipBase method writeEntityToNBT.
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
nbt.setInteger("launchPhase", this.launchPhase + 1);
nbt.setInteger("timeUntilLaunch", this.timeUntilLaunch);
if (telemetryList.size() > 0) {
NBTTagList teleNBTList = new NBTTagList();
for (BlockVec3Dim vec : new ArrayList<BlockVec3Dim>(this.telemetryList)) {
NBTTagCompound tag = new NBTTagCompound();
vec.writeToNBT(tag);
teleNBTList.appendTag(tag);
}
nbt.setTag("telemetryList", teleNBTList);
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.
the class BlockBasicMoon method breakBlock.
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
super.breakBlock(worldIn, pos, state);
EnumBlockBasicMoon type = ((EnumBlockBasicMoon) state.getValue(BASIC_TYPE_MOON));
if (!worldIn.isRemote && type == EnumBlockBasicMoon.MOON_TURF) {
Map<Long, List<Footprint>> footprintChunkMap = TickHandlerServer.serverFootprintMap.get(GCCoreUtil.getDimensionID(worldIn));
if (footprintChunkMap != null) {
long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.getX() >> 4, pos.getZ() >> 4);
List<Footprint> footprintList = footprintChunkMap.get(chunkKey);
if (footprintList != null && !footprintList.isEmpty()) {
List<Footprint> toRemove = new ArrayList<Footprint>();
for (Footprint footprint : footprintList) {
if (footprint.position.x > pos.getX() && footprint.position.x < pos.getX() + 1 && footprint.position.z > pos.getZ() && footprint.position.z < pos.getZ() + 1) {
toRemove.add(footprint);
}
}
if (!toRemove.isEmpty()) {
footprintList.removeAll(toRemove);
}
}
}
TickHandlerServer.footprintBlockChanges.add(new BlockVec3Dim(pos, GCCoreUtil.getDimensionID(worldIn)));
}
}
Aggregations