use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class TileEntitySolarArrayController method update.
@Override
public void update() {
if (!this.initialised) {
this.storage.setCapacity(50000);
this.initialised = true;
}
if (!this.world.isRemote) {
this.receiveEnergyGC(null, this.generateWatts, false);
EnumSet<EnumFacing> outputDirections = EnumSet.noneOf(EnumFacing.class);
outputDirections.addAll(Arrays.asList(EnumFacing.HORIZONTALS));
outputDirections.removeAll(this.getElectricalOutputDirections());
BlockVec3 thisVec = new BlockVec3(this);
solarArray.clear();
for (EnumFacing direction : outputDirections) {
TileEntity tileAdj = thisVec.getTileEntityOnSide(this.world, direction);
if (tileAdj != null) {
if (tileAdj instanceof INetworkProvider) {
if (tileAdj instanceof ITransmitter) {
if (((ITransmitter) tileAdj).canConnect(direction.getOpposite(), NetworkType.SOLAR_MODULE)) {
if (((INetworkProvider) tileAdj).getNetwork() instanceof SolarModuleNetwork) {
solarArray.addAll(((SolarModuleNetwork) ((INetworkProvider) tileAdj).getNetwork()).getTransmitters());
}
}
} else {
if (((INetworkProvider) tileAdj).getNetwork() instanceof SolarModuleNetwork) {
solarArray.addAll(((SolarModuleNetwork) ((INetworkProvider) tileAdj).getNetwork()).getTransmitters());
}
}
}
}
}
}
super.update();
if (!this.world.isRemote) {
this.recharge(this.getInventory().get(0));
if (this.disableCooldown > 0) {
this.disableCooldown--;
}
if (!this.getDisabled(0) && this.ticks % 20 == 0) {
this.solarStrength = 0;
int arraySizeWithinRange = 0;
if (this.world.isDaytime() && (this.world.provider instanceof IGalacticraftWorldProvider || !this.world.isRaining() && !this.world.isThundering())) {
for (ITransmitter transmitter : solarArray) {
TileEntity tile = (TileEntity) transmitter;
Vec3i diff = tile.getPos().subtract(this.getPos());
if (Math.abs(diff.getX()) <= 16 && diff.getY() == 0 && Math.abs(diff.getZ()) <= 16) {
arraySizeWithinRange++;
if (this.world.canBlockSeeSky(tile.getPos())) {
boolean valid = true;
for (int y = this.getPos().getY() + 1; y < 256; y++) {
IBlockState state = this.world.getBlockState(this.getPos().add(0, y, 0));
if (state.getBlock().isOpaqueCube(state)) {
valid = false;
break;
}
}
if (valid) {
this.solarStrength++;
}
}
}
}
}
connectedInfo = solarStrength << 16 | arraySizeWithinRange;
}
}
float angle = this.world.getCelestialAngle(1.0F) - 0.7845194F < 0 ? 1.0F - 0.7845194F : -0.7845194F;
float celestialAngle = (this.world.getCelestialAngle(1.0F) + angle) * 360.0F;
if (!(this.world.provider instanceof WorldProviderSpaceStation))
celestialAngle += 12.5F;
if (this.world.provider instanceof WorldProviderVenus)
celestialAngle = 180F - celestialAngle;
celestialAngle %= 360;
boolean isDaytime = this.world.isDaytime() && (celestialAngle < 180.5F || celestialAngle > 359.5F) || this.world.provider instanceof WorldProviderSpaceStation;
if (!this.world.isRemote) {
int generated = this.getGenerate();
if (generated > 0) {
this.generateWatts = Math.min(Math.max(generated, 0), TileEntitySolarArrayController.MAX_GENERATE_WATTS);
} else {
this.generateWatts = 0;
}
}
this.produce();
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class BlockUnlitTorch method onOxygenAdded.
@Override
public void onOxygenAdded(World world, BlockPos pos, IBlockState state) {
if (world.provider instanceof IGalacticraftWorldProvider) {
EnumFacing enumfacing = state.getValue(FACING);
world.setBlockState(pos, this.litVersion.getDefaultState().withProperty(FACING, enumfacing), 2);
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class TileEntityOxygenDetector method update.
@Override
public void update() {
if (!this.world.isRemote && ++this.ticks == 50) {
this.ticks = 0;
if (this.getBlockType() instanceof BlockOxygenDetector) {
boolean oxygenFound = false;
if (this.world.provider instanceof IGalacticraftWorldProvider && !((IGalacticraftWorldProvider) this.world.provider).hasBreathableAtmosphere()) {
oxygenFound = OxygenUtil.isAABBInBreathableAirBlock(this.world, this.oxygenSearch, false);
} else {
for (EnumFacing side : EnumFacing.VALUES) {
BlockPos offset = this.pos.offset(side, 1);
IBlockState bs = this.world.getBlockState(offset);
if (!bs.getBlock().isSideSolid(bs, world, offset, side.getOpposite())) {
oxygenFound = true;
break;
}
}
}
((BlockOxygenDetector) this.blockType).updateOxygenState(this.world, this.getPos(), oxygenFound);
}
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class EntityAutoRocket method onLaunch.
@Override
public void onLaunch() {
if (!(this.world.provider.getDimension() == GalacticraftCore.planetOverworld.getDimensionID() || this.world.provider instanceof IGalacticraftWorldProvider)) {
if (ConfigManagerCore.disableRocketLaunchAllNonGC) {
this.cancelLaunch();
return;
}
// No rocket flight in the Nether, the End etc
for (int i = ConfigManagerCore.disableRocketLaunchDimensions.length - 1; i >= 0; i--) {
if (ConfigManagerCore.disableRocketLaunchDimensions[i] == this.world.provider.getDimension()) {
this.cancelLaunch();
return;
}
}
}
super.onLaunch();
if (!this.world.isRemote) {
GCPlayerStats stats = null;
if (!this.getPassengers().isEmpty()) {
for (Entity player : this.getPassengers()) {
if (player instanceof EntityPlayerMP) {
stats = GCPlayerStats.get(player);
stats.setLaunchpadStack(null);
if (!(this.world.provider instanceof IOrbitDimension)) {
stats.setCoordsTeleportedFromX(player.posX);
stats.setCoordsTeleportedFromZ(player.posZ);
}
}
}
Entity playerMain = this.getPassengers().get(0);
if (playerMain instanceof EntityPlayerMP)
stats = GCPlayerStats.get(playerMain);
}
int amountRemoved = 0;
PADSEARCH: for (int x = MathHelper.floor(this.posX) - 1; x <= MathHelper.floor(this.posX) + 1; x++) {
for (int y = MathHelper.floor(this.posY) - 3; y <= MathHelper.floor(this.posY) + 1; y++) {
for (int z = MathHelper.floor(this.posZ) - 1; z <= MathHelper.floor(this.posZ) + 1; z++) {
BlockPos pos = new BlockPos(x, y, z);
final Block block = this.world.getBlockState(pos).getBlock();
if (block != null && block instanceof BlockLandingPadFull) {
if (amountRemoved < 9) {
EventLandingPadRemoval event = new EventLandingPadRemoval(this.world, pos);
MinecraftForge.EVENT_BUS.post(event);
if (event.allow) {
this.world.setBlockToAir(pos);
amountRemoved = 9;
}
break PADSEARCH;
}
}
}
}
}
// Set the player's launchpad item for return on landing - or null if launchpads not removed
if (stats != null && amountRemoved == 9) {
stats.setLaunchpadStack(new ItemStack(GCBlocks.landingPad, 9, 0));
}
this.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class LayerThermalPadding method renderArmorLayer.
private void renderArmorLayer(EntityLivingBase entityLivingBaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, EntityEquipmentSlot slotIn) {
ItemStack itemstack = this.getItemStackFromSlot(entityLivingBaseIn, slotIn);
if (itemstack != null) {
ModelBiped model = this.getModelFromSlot(slotIn);
model.setModelAttributes(this.renderer.getMainModel());
model.setLivingAnimations(entityLivingBaseIn, limbSwing, limbSwingAmount, partialTicks);
this.setModelSlotVisible(model, slotIn);
this.renderer.bindTexture(itemstack.getItem() instanceof ItemThermalPaddingTier2 ? RenderPlayerGC.thermalPaddingTexture1_T2 : RenderPlayerGC.thermalPaddingTexture1);
model.render(entityLivingBaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
// Start alpha render
GlStateManager.disableLighting();
Minecraft.getMinecraft().renderEngine.bindTexture(RenderPlayerGC.thermalPaddingTexture0);
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
float time = entityLivingBaseIn.ticksExisted / 10.0F;
float sTime = (float) Math.sin(time) * 0.5F + 0.5F;
float r = 0.2F * sTime;
float g = 1.0F * sTime;
float b = 0.2F * sTime;
if (entityLivingBaseIn.world.provider instanceof IGalacticraftWorldProvider) {
float modifier = ((IGalacticraftWorldProvider) entityLivingBaseIn.world.provider).getThermalLevelModifier();
if (modifier > 0) {
b = g;
g = r;
} else if (modifier < 0) {
r = g;
g = b;
}
}
GlStateManager.color(r, g, b, 0.4F * sTime);
model.render(entityLivingBaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
GlStateManager.color(1, 1, 1, 1);
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableLighting();
}
}
Aggregations