use of micdoodle8.mods.galacticraft.planets.venus.tile.TileEntityLaserTurret in project Galacticraft by micdoodle8.
the class TileEntityLaserTurretRenderer method render.
@Override
public void render(TileEntityLaserTurret tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
GlStateManager.pushMatrix();
GlStateManager.translate((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GlStateManager.pushMatrix();
RenderHelper.disableStandardItemLighting();
this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(GL11.GL_SMOOTH);
} else {
GlStateManager.shadeModel(GL11.GL_FLAT);
}
this.updateModels();
GlStateManager.scale(1 / 16.0F, 1 / 16.0F, 1 / 16.0F);
GlStateManager.pushMatrix();
GlStateManager.scale(0.9F, 1.0F, 0.9F);
ClientUtil.drawBakedModel(laserBase);
GlStateManager.popMatrix();
GlStateManager.rotate(tile.yaw, 0.0F, 1.0F, 0.0F);
// Interpolate between yaw and targetYaw
float partialRot = Math.signum(tile.pitch) * tile.pitch * (tile.pitch / 120.0F);
GlStateManager.rotate(partialRot, 0.0F, 0.0F, -1.0F);
GlStateManager.pushMatrix();
GlStateManager.scale(1.1F, 1.0F, 1.0F);
ClientUtil.drawBakedModel(laserPhalange);
GlStateManager.popMatrix();
GlStateManager.rotate(tile.pitch - partialRot, 0.0F, 0.0F, -1.0F);
ClientUtil.drawBakedModel(laserPhalangeAxle);
ClientUtil.drawBakedModel(tile.active ? laserTurrets : laserTurretsOff);
GlStateManager.popMatrix();
Tessellator tess = Tessellator.getInstance();
float inv = (float) (Math.pow(tile.chargeLevel / 5.0F + 1.0F, 2.5F) * 1.0F);
float invNext = (float) (Math.pow((tile.chargeLevel + 1) / 5.0F + 1.0F, 2.5F) * 1.0F);
float rotate = inv + (invNext - inv) * partialTicks;
float lightMapSaveX = OpenGlHelper.lastBrightnessX;
float lightMapSaveY = OpenGlHelper.lastBrightnessY;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
if (tile.chargeLevel > 0) {
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.rotate(tile.yaw, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(tile.pitch, 0.0F, 0.0F, -1.0F);
GlStateManager.translate(-0.6F, 0.28F, 0.0F);
GlStateManager.disableTexture2D();
tess.getBuffer().begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION_COLOR);
tess.getBuffer().pos(0.09F, 0.0F, 0.275F).color(0.0F, 1.0F, 0.0F, 1.0F).endVertex();
tess.getBuffer().pos(0.0F, 0.0F, 0.0F).color(0.0F, 1.0F, 0.0F, 1.0F).endVertex();
tess.getBuffer().pos(0.09F, 0.0F, -0.275F).color(0.0F, 1.0F, 0.0F, 1.0F).endVertex();
tess.draw();
GlStateManager.enableTexture2D();
float scale = tile.chargeLevel / 600.0F;
GlStateManager.scale(0.01F + scale, 0.01F + scale, 0.01F + scale);
GlStateManager.rotate(rotate, 0.0F, 1.0F, 0.0F);
ClientUtil.drawBakedModel(orb1);
GlStateManager.rotate(rotate, 0.0F, 1.0F, 0.0F);
ClientUtil.drawBakedModel(orb2);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
if (tile.timeSinceShot > 0 && tile.timeSinceShot < 5) {
Entity e = tile.getWorld().getEntityByID(tile.targettedEntity);
if (e != null) {
GlStateManager.disableTexture2D();
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.disableCull();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.rotate(tile.yaw, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(tile.pitch, 0.0F, 0.0F, -1.0F);
GlStateManager.translate(-0.6F, 0.28F, 0.0F);
BufferBuilder bb = tess.getBuffer();
bb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
Vector3 vec = new Vector3(e.posX, e.posY + e.getEyeHeight(), e.posZ);
vec.translate(new Vector3(-(tile.getPos().getX() + 0.5F), -(tile.getPos().getY() + 1.78F), -(tile.getPos().getZ() + 0.5F)));
float dist = (float) vec.getMagnitude() - 0.8F;
float shotTimer = (float) (Math.pow((5.0F - tile.timeSinceShot) / 5.0F + 1.0F, 2.5F) * 0.5F);
float shotTimerNext = (float) (Math.pow((5.0F - (tile.timeSinceShot + 1)) / 5.0F + 1.0F, 2.5F) * 0.5F);
float fade = shotTimer + (shotTimerNext - shotTimer) * partialTicks;
float yMin = -0.101F * fade;
float yMax = 0.101F * fade;
float yMin1 = -0.15F * fade;
float yMax1 = 0.15F * fade;
tess.getBuffer().pos(0.0F, yMax, yMax).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(0.0F, yMin, yMin).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(-dist, yMin * 0.4F, yMin * 0.4F).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(-dist, yMax * 0.4F, yMax * 0.4F).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(0.0F, yMax, yMin).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(0.0F, yMin, yMax).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(-dist, yMin * 0.4F, yMax * 0.4F).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(-dist, yMax * 0.4F, yMin * 0.4F).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(0.0F, yMax1, yMax1).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(0.0F, yMin1, yMin1).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(-dist, yMin1 * 0.4F, yMin1 * 0.4F).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(-dist, yMax1 * 0.4F, yMax1 * 0.4F).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(0.0F, yMax1, yMin1).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(0.0F, yMin1, yMax1).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(-dist, yMin1 * 0.4F, yMax1 * 0.4F).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.getBuffer().pos(-dist, yMax1 * 0.4F, yMin1 * 0.4F).color(0.0F, 1.0F, 0.0F, 0.5F).endVertex();
tess.draw();
GlStateManager.enableCull();
GlStateManager.enableTexture2D();
GlStateManager.popMatrix();
}
}
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightMapSaveX, lightMapSaveY);
GlStateManager.popMatrix();
}
use of micdoodle8.mods.galacticraft.planets.venus.tile.TileEntityLaserTurret in project Galacticraft by micdoodle8.
the class VenusModule method getGuiElement.
@Override
public Object getGuiElement(Side side, int ID, EntityPlayer player, World world, int x, int y, int z) {
BlockPos pos = new BlockPos(x, y, z);
TileEntity tile = world.getTileEntity(pos);
if (ID == GuiIdsPlanets.MACHINE_VENUS) {
if (tile instanceof TileEntityGeothermalGenerator) {
return new ContainerGeothermal(player.inventory, (TileEntityGeothermalGenerator) tile);
} else if (tile instanceof TileEntityCrashedProbe) {
return new ContainerCrashedProbe(player.inventory, (TileEntityCrashedProbe) tile);
} else if (tile instanceof TileEntitySolarArrayController) {
return new ContainerSolarArrayController(player.inventory, (TileEntitySolarArrayController) tile);
} else if (tile instanceof TileEntityLaserTurret) {
return new ContainerLaserTurret(player.inventory, (TileEntityLaserTurret) tile);
}
}
return null;
}
use of micdoodle8.mods.galacticraft.planets.venus.tile.TileEntityLaserTurret in project Galacticraft by micdoodle8.
the class BlockLaserTurret method breakBlock.
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityLaserTurret) {
((TileEntityLaserTurret) tile).onDestroy(tile);
}
super.breakBlock(worldIn, pos, state);
}
use of micdoodle8.mods.galacticraft.planets.venus.tile.TileEntityLaserTurret in project MorePlanets by SteveKunG.
the class StructureAbandonedSatellitePieces method addComponentParts.
@Override
public boolean addComponentParts(World world, Random rand, StructureBoundingBox structureBoundingBox) {
if (!this.offsetToAverageGroundLevel(world, structureBoundingBox, -1)) {
return false;
} else {
StructureBoundingBox box = this.getBoundingBox();
BlockPos pos = new BlockPos(box.minX, box.minY, box.minZ);
Rotation[] arotation = CachedEnum.rotationValues;
Rotation rotation = arotation[rand.nextInt(arotation.length)];
MinecraftServer server = world.getMinecraftServer();
TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
PlacementSettings settings = new PlacementSettings().setRotation(rotation).setReplacedBlock(Blocks.STRUCTURE_VOID).setBoundingBox(box);
settings.setIntegrity(0.85F);
Template template = manager.getTemplate(server, SATELLITE_BASE_ID);
Template template1 = manager.getTemplate(server, SATELLITE_DISH_BASE_ID);
Template template2 = manager.getTemplate(server, SATELLITE_DISH_ID);
this.addBlocksToWorldChunk(template, world, pos, settings);
BlockPos blockpos1 = template.calculateConnectedPos(settings, new BlockPos(0, 4, 0), settings, new BlockPos(-1, 0, -1));
this.addBlocksToWorldChunk(template1, world, pos.add(blockpos1), settings);
BlockPos blockpos4 = pos.add(template.calculateConnectedPos(settings, new BlockPos(0, 8, 0), settings, new BlockPos(0, 0, 4)));
this.addBlocksToWorldChunk(template2, world, blockpos4, settings);
Map<BlockPos, String> map = template.getDataBlocks(pos, settings);
for (Map.Entry<BlockPos, String> entry : map.entrySet()) {
if ("laser_turret".equals(entry.getValue())) {
BlockPos blockpos2 = entry.getKey();
world.setBlockState(blockpos2, VenusBlocks.laserTurret.getDefaultState().withProperty(BlockLaserTurret.FACING, rotation.rotate(EnumFacing.NORTH)), 3);
TileEntity tile = world.getTileEntity(blockpos2);
if (tile instanceof TileEntityLaserTurret) {
TileEntityLaserTurret turret = (TileEntityLaserTurret) tile;
turret.setOwnerUUID(UUID.randomUUID());
turret.addPlayer("");
turret.targetMeteors = false;
turret.getPositions(blockpos2, new ArrayList<>());
turret.onCreate(world, blockpos2);
}
} else if ("chest_and_wire".equals(entry.getValue())) {
BlockPos blockpos2 = entry.getKey();
world.setBlockState(blockpos2, GCBlocks.sealableBlock.getDefaultState().withProperty(BlockEnclosed.TYPE, BlockEnclosed.EnumEnclosedBlockType.ALUMINUM_WIRE_HEAVY), 3);
TileEntity tile = world.getTileEntity(blockpos2.down());
if (tile instanceof TileEntityChestMP) {
((TileEntityChestMP) tile).setLootTable(MPLootTables.CRASHED_ALIEN_PROBE, rand.nextLong());
}
} else if ("energy_storage".equals(entry.getValue())) {
BlockPos blockpos2 = entry.getKey();
world.setBlockState(blockpos2, GCBlocks.machineTiered.getDefaultState().withProperty(BlockMachineTiered.TYPE, BlockMachineTiered.EnumTieredMachineType.STORAGE_MODULE).withProperty(BlockMachineBase.FACING, rotation.rotate(EnumFacing.SOUTH)), 3);
TileEntity tile = world.getTileEntity(blockpos2);
if (tile instanceof TileEntityEnergyStorageModule) {
TileEntityEnergyStorageModule module = (TileEntityEnergyStorageModule) tile;
module.storage.setEnergyStored(500000.0F);
module.setInventorySlotContents(1, new ItemStack(VenusItems.atomicBattery));
}
}
}
return true;
}
}
use of micdoodle8.mods.galacticraft.planets.venus.tile.TileEntityLaserTurret in project Galacticraft by micdoodle8.
the class BlockLaserTurret method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityLaserTurret) {
((TileEntityLaserTurret) tile).setOwnerUUID(placer.getUniqueID());
((TileEntityLaserTurret) tile).addPlayer(placer.getName());
}
int angle = MathHelper.floor(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
int change = EnumFacing.getHorizontal(angle).getOpposite().getHorizontalIndex();
worldIn.setBlockState(pos, getStateFromMeta(change), 3);
BlockMulti.onPlacement(worldIn, pos, placer, this);
}
Aggregations