summaryrefslogtreecommitdiff
path: root/ihl/enviroment
diff options
context:
space:
mode:
authorFoghrye4 <foghrye4@gmail.com>2017-04-22 14:31:54 +0300
committerFoghrye4 <foghrye4@gmail.com>2017-04-22 14:31:54 +0300
commitb67ac617dc9c5f43b911158a281c3c61ced5ea5a (patch)
tree649b4553f8b2e673b0c4b12e470feb7e7628de8e /ihl/enviroment
parentaa42aedecd2d2842351088085e8fd9d69ec79565 (diff)
NEI titles translation
Diffstat (limited to 'ihl/enviroment')
-rw-r--r--ihl/enviroment/LightBulbBlock.java157
-rw-r--r--ihl/enviroment/LightBulbModel.java51
-rw-r--r--ihl/enviroment/LightBulbRender.java77
-rw-r--r--ihl/enviroment/LightBulbTileEntity.java273
-rw-r--r--ihl/enviroment/LightHandler.java166
-rw-r--r--ihl/enviroment/LightSource.java183
-rw-r--r--ihl/enviroment/SpotlightBlock.java147
-rw-r--r--ihl/enviroment/SpotlightModel.java71
-rw-r--r--ihl/enviroment/SpotlightRender.java110
-rw-r--r--ihl/enviroment/SpotlightTileEntity.java212
10 files changed, 0 insertions, 1447 deletions
diff --git a/ihl/enviroment/LightBulbBlock.java b/ihl/enviroment/LightBulbBlock.java
deleted file mode 100644
index 7c95001..0000000
--- a/ihl/enviroment/LightBulbBlock.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package ihl.enviroment;
-
-import java.util.List;
-import java.util.Random;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ihl.IHLCreativeTab;
-import ihl.flexible_cable.AnchorTileEntity;
-import ihl.items_blocks.IHLItemBlock;
-import net.minecraft.block.Block;
-import net.minecraft.block.ITileEntityProvider;
-import net.minecraft.block.material.Material;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemDye;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.IBlockAccess;
-import net.minecraft.world.World;
-
-public class LightBulbBlock extends Block implements ITileEntityProvider {
-
- public LightBulbBlock(String unlocalizedName1) {
- super(Material.glass);
- this.setStepSound(soundTypeGlass);
- this.setBlockName(unlocalizedName1);
- GameRegistry.registerBlock(this, IHLItemBlock.class, unlocalizedName1);
- this.setHardness(0.3F);
- this.setResistance(0.5F);
- this.setCreativeTab(IHLCreativeTab.tab);
- this.setBlockTextureName("glass");
- this.setLightOpacity(0);
- }
-
- @Override
- public boolean hasTileEntity(int metadata) {
- return true;
- }
-
- public static void init() {
- new LightBulbBlock("lightBulb");
- new SpotlightBlock("spotlight");
- GameRegistry.registerTileEntity(LightBulbTileEntity.class, "lightBulb");
- GameRegistry.registerTileEntity(SpotlightTileEntity.class, "spotlight");
- }
-
- @Override
- public void onBlockPreDestroy(World world, int x, int y, int z, int meta) {
- if (world.isRemote) {
- TileEntity te = world.getTileEntity(x, y, z);
- if (te != null && te instanceof LightBulbTileEntity) {
- LightBulbTileEntity ate = (LightBulbTileEntity) te;
- ate.invalidate();
- }
- }
- super.onBlockPreDestroy(world, x, y, z, meta);
- }
-
- /**
- * Returns the quantity of items to drop on block destruction.
- */
- @Override
- public int quantityDropped(Random random) {
- return 0;
- }
-
- @Override
- public boolean renderAsNormalBlock() {
- return false;
- }
-
- /**
- * The type of render function that is called for this block
- */
- @Override
- public int getRenderType() {
- return -2;
- }
-
- @Override
- public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) {
- TileEntity te = iBlockAccess.getTileEntity(x, y, z);
- if (te != null && te instanceof LightBulbTileEntity) {
- LightBulbTileEntity ate = (LightBulbTileEntity) te;
- setBlockBoundsBasedOnFacing(ate.getFacing());
- }
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @SideOnly(Side.CLIENT)
- public void getSubBlocks(Item item, CreativeTabs tab, List itemlist) {
- for (int colour : ItemDye.field_150922_c) {
- ItemStack stack = new ItemStack(item);
- stack.stackTagCompound = new NBTTagCompound();
- stack.stackTagCompound.setInteger("colour", colour);
- itemlist.add(stack);
- }
- }
-
- @Override
- public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
- super.onBlockPlacedBy(world, x, y, z, player, stack);
- if (!world.isRemote) {
- TileEntity tile = world.getTileEntity(x, y, z);
- if (tile instanceof LightBulbTileEntity && stack.stackTagCompound != null)
- ((LightBulbTileEntity)tile).colour=stack.stackTagCompound.getInteger("colour");
- }
- }
-
- private void setBlockBoundsBasedOnFacing(int facing) {
- int var2 = facing & 7;
- float var6 = 0.1875F;
- float var7 = 0.5F;
-
- if (var2 == 0) {
- this.setBlockBounds(0.5F - var6, 1.0F - var7, 0.5F - var6, 0.5F + var6, 1.0F, 0.5F + var6);
- } else if (var2 == 1) {
- this.setBlockBounds(0.5F - var6, 0.0F, 0.5F - var6, 0.5F + var6, var7, 0.5F + var6);
- } else if (var2 == 2) {
- this.setBlockBounds(0.5F - var6, 0.5F - var6, 1.0F - var7, 0.5F + var6, 0.5F + var6, 1.0F);
- } else if (var2 == 3) {
- this.setBlockBounds(0.5F - var6, 0.5F - var6, 0.0F, 0.5F + var6, 0.5F + var6, var7);
- } else if (var2 == 4) {
- this.setBlockBounds(1.0F - var7, 0.5F - var6, 0.5F - var6, 1.0F, 0.5F + var6, 0.5F + var6);
- } else if (var2 == 5) {
- this.setBlockBounds(0.0F, 0.5F - var6, 0.5F - var6, var7, 0.5F + var6, 0.5F + var6);
- }
- }
-
- @Override
- public boolean isOpaqueCube() {
- return false;
- }
-
- @Override
- public boolean isNormalCube() {
- return false;
- }
-
- @Override
- public TileEntity createNewTileEntity(World arg0, int arg1) {
- return new LightBulbTileEntity();
- }
-
- public int getLightValue(IBlockAccess world, int x, int y, int z) {
- TileEntity te = world.getTileEntity(x, y, z);
- if(te instanceof LightBulbTileEntity && ((LightBulbTileEntity)te).getActive()){
- return 15;
- }
- return 0;
- }
-}
diff --git a/ihl/enviroment/LightBulbModel.java b/ihl/enviroment/LightBulbModel.java
deleted file mode 100644
index bca6305..0000000
--- a/ihl/enviroment/LightBulbModel.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package ihl.enviroment;
-
-import ihl.model.IHLModelRenderer;
-import net.minecraft.client.model.ModelBase;
-import net.minecraftforge.common.util.ForgeDirection;
-
-public class LightBulbModel extends ModelBase
-{
- //fields
- IHLModelRenderer Base;
- IHLModelRenderer BaseON;
-
- public LightBulbModel()
- {
- textureWidth = 32;
- textureHeight = 32;
- setTextureOffset("Base.Shape1", 0, 19);
- setTextureOffset("Base.TubeNorth", 20, 0);
- setTextureOffset("Base.CylinderNorth", 0, 0);
- setTextureOffset("Base.CylinderNorth2", 0, 0);
- setTextureOffset("Base.SpyralNorth", 16, 24);
-
- setTextureOffset("BaseON.Shape1", 0, 19);
- setTextureOffset("BaseON.TubeNorth", 20, 0);
- setTextureOffset("BaseON.CylinderNorth", 0, 9);
- setTextureOffset("BaseON.CylinderNorth2", 10, 10);
- setTextureOffset("BaseON.SpyralNorth", 0, 24);
-
- Base = new IHLModelRenderer(this, "Base");
- Base.setRotationPoint(0F, 16F, 0F);
- Base.mirror = true;
- Base.addBox("Shape1", -2F, -2F, 7F, 4, 4, 1);
- Base.addTube("TubeNorth", -2F, -2F, 5F, 4, 4, 2, 0.8f, 1f, ForgeDirection.NORTH);
- Base.drawFromInside = true;
- Base.addTube("CylinderNorth", -1.5F, -1.5F, 0F, 3, 3, 7, 0f, 1f, ForgeDirection.NORTH);
- Base.addTube("CylinderNorth2", -1F, -1F, 0.5F, 2, 2, 5, 0f, 1f, ForgeDirection.NORTH);
- Base.drawFromInside = false;
- Base.addTube("SpyralNorth", -0.5F, -0.5F, 0.5F, 1, 1, 7, 0f, 1f, ForgeDirection.NORTH);
-
- BaseON = new IHLModelRenderer(this, "BaseON");
- BaseON.setRotationPoint(0F, 16F, 0F);
- BaseON.mirror = true;
- BaseON.addBox("Shape1", -2F, -2F, 7F, 4, 4, 1);
- BaseON.addTube("TubeNorth", -2F, -2F, 5F, 4, 4, 2, 0.8f, 1f, ForgeDirection.NORTH);
- BaseON.drawFromInside = true;
- BaseON.addTube("CylinderNorth", -1.5F, -1.5F, 0F, 3, 3, 7, 0f, 1f, ForgeDirection.NORTH);
- BaseON.addTube("CylinderNorth2", -1F, -1F, 0.5F, 2, 2, 5, 0f, 1f, ForgeDirection.NORTH);
- BaseON.drawFromInside = false;
- BaseON.addTube("SpyralNorth", -0.5F, -0.5F, 0.5F, 1, 1, 7, 0f, 1f, ForgeDirection.NORTH);
- }
-}
diff --git a/ihl/enviroment/LightBulbRender.java b/ihl/enviroment/LightBulbRender.java
deleted file mode 100644
index caa5f65..0000000
--- a/ihl/enviroment/LightBulbRender.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package ihl.enviroment;
-import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.opengl.GL11;
-
-import ihl.IHLModInfo;
-
-public class LightBulbRender extends TileEntitySpecialRenderer{
-private LightBulbModel model = new LightBulbModel();
-private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/lightBulb.png");
-private final float scale=1F/16F;
-
- public LightBulbRender() {}
-
-
- @Override
- public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8)
- {
- LightBulbTileEntity cte = (LightBulbTileEntity)tile;
- int rotation = 0;
- int rotationz = 0;
- if(tile.getWorldObj() != null)
- {
- switch (cte.getFacing())
- {
- case 0:
- rotationz = 1;
- break;
- case 1:
- rotationz = 3;
- break;
- case 2:
- rotation = 2;
- break;
- case 5:
- rotation = 3;
- break;
- case 3:
- rotation = 0;
- break;
- case 4:
- rotation = 1;
- break;
- default:
- rotation = 0;
- }
- }
- else
- {
- return;
- }
- model.BaseON.rotateAngleY=(float) (rotation*Math.PI/2);
- model.BaseON.rotateAngleX=(float) (rotationz*Math.PI/2);
- model.Base.rotateAngleY=(float) (rotation*Math.PI/2);
- model.Base.rotateAngleX=(float) (rotationz*Math.PI/2);
- GL11.glPushMatrix();
- GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
- GL11.glScalef(1.0F, -1F, -1F);
- bindTexture(tex);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL11.glColor4f((cte.colour>>>16)/255f,((cte.colour>>>8)&255)/255f, (cte.colour&255)/255f,1f);
- if(cte.getActive())
- {
- GL11.glDisable(GL11.GL_LIGHTING);
- model.BaseON.render(scale);
- }
- else
- {
- model.Base.render(scale);
- }
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glPopMatrix(); //end
-
- }
-} \ No newline at end of file
diff --git a/ihl/enviroment/LightBulbTileEntity.java b/ihl/enviroment/LightBulbTileEntity.java
deleted file mode 100644
index 8695bd7..0000000
--- a/ihl/enviroment/LightBulbTileEntity.java
+++ /dev/null
@@ -1,273 +0,0 @@
-package ihl.enviroment;
-
-import java.util.List;
-import java.util.Vector;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.World;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.common.util.ForgeDirection;
-import ic2.api.energy.event.EnergyTileLoadEvent;
-import ic2.api.energy.event.EnergyTileUnloadEvent;
-import ic2.api.energy.tile.IEnergySink;
-import ic2.api.network.INetworkDataProvider;
-import ic2.api.network.INetworkTileEntityEventListener;
-import ic2.api.tile.IWrenchable;
-import ic2.core.IC2;
-import ic2.core.ITickCallback;
-import ihl.ClientProxy;
-import ihl.IHLMod;
-import ihl.IHLModInfo;
-import ihl.model.RenderBlocksExt;
-import ihl.utils.IHLUtils;
-
-public class LightBulbTileEntity extends TileEntity
- implements IEnergySink, IWrenchable, INetworkDataProvider {
- private boolean active = false;
- private short facing = 0;
- public boolean prevActive = false;
- public short prevFacing = 0;
- private double energy;
- public boolean addedToEnergyNet = false;
- private boolean loaded = false;
- private int ticker;
- public int colour = 0xffffff;
-
- @SideOnly(value = Side.CLIENT)
- LightSource lightSource;
-
- @Override
- public void readFromNBT(NBTTagCompound nbttagcompound) {
- super.readFromNBT(nbttagcompound);
- this.energy = nbttagcompound.getDouble("energy");
- this.facing = nbttagcompound.getShort("facing");
- this.colour = nbttagcompound.getInteger("colour");
- }
-
- @Override
- public void writeToNBT(NBTTagCompound nbttagcompound) {
- super.writeToNBT(nbttagcompound);
- nbttagcompound.setDouble("energy", this.energy);
- nbttagcompound.setShort("facing", this.facing);
- nbttagcompound.setInteger("colour", this.colour);
- }
-
- /**
- * invalidates a tile entity
- */
- @Override
- public void invalidate() {
- super.invalidate();
- if (this.loaded) {
- this.onUnloaded();
- }
- }
-
- @Override
- public void onChunkUnload() {
- super.onChunkUnload();
- if (this.loaded) {
- this.onUnloaded();
- }
- }
-
- public void onLoaded() {
- if (!this.worldObj.isRemote) {
- IC2.network.get().updateTileEntityField(this, "colour");
- }
- if (IC2.platform.isSimulating() && !this.addedToEnergyNet) {
- MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
- this.addedToEnergyNet = true;
- }
- this.loaded = true;
- }
-
- public void onUnloaded() {
- if (IC2.platform.isSimulating()) {
- if (this.addedToEnergyNet) {
- MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
- this.addedToEnergyNet = false;
- }
- }
- this.active = false;
- this.updateLightState();
- }
-
- @Override
- public final boolean canUpdate() {
- return true;
- }
-
- @Override
- public void updateEntity() {
- if (this.worldObj.isRemote) {
- if(this.prevActive != active){
- updateLightState();
- this.prevActive = active;
- }
- }
- if(!this.loaded){
- this.onLoaded();
- }
- if (!this.worldObj.isRemote && ++this.ticker % 4 == 0) {
- if (this.prevFacing != facing) {
- this.setFacing(facing);
- }
- if (this.energy > 0) {
- this.energy--;
- this.setActive(true);
- } else {
- this.setActive(false);
- }
- }
- }
-
- protected void updateLightState() {
- if (IC2.platform.isSimulating()) {
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- } else if (IC2.platform.isRendering()) {
- if (this.getActive()) {
- if(lightSource != null)
- ((ClientProxy) IHLMod.proxy).getLightHandler().removeLightSource(lightSource);
- int red = colour >>> 16;
- int green = (colour >>> 8) & 255;
- int blue = colour & 255;
- int max = red;
- if (max < green)
- max = green;
- if (max < blue)
- max = blue;
- max -= 255;
- red -= max;// Normalize colours
- blue -= max;
- green -= max;
- lightSource = this.createLightSource(red, green, blue);
- ((ClientProxy) IHLMod.proxy).getLightHandler().addLightSource(lightSource);
- } else if (lightSource != null) {
- ((ClientProxy) IHLMod.proxy).getLightHandler().removeLightSource(lightSource);
- lightSource = null;
- }
- }
- }
-
- @SideOnly(value = Side.CLIENT)
- protected LightSource createLightSource(int red, int green, int blue) {
- return ((ClientProxy) IHLMod.proxy).getLightHandler().calculateLightSource(worldObj, xCoord, yCoord, zCoord,
- 64, red, green, blue, null);
- }
-
- @Override
- public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
- switch (direction) {
- case UP:
- return this.getFacing() == 0;
- case DOWN:
- return this.getFacing() == 1;
- case SOUTH:
- return this.getFacing() == 2;
- case NORTH:
- return this.getFacing() == 3;
- case EAST:
- return this.getFacing() == 4;
- case WEST:
- return this.getFacing() == 5;
- default:
- return false;
- }
- }
-
- @Override
- public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
- return false;
- }
-
- @Override
- public short getFacing() {
- return this.facing;
- }
-
- @Override
- public void setFacing(short facing1) {
- if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
- MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
- this.addedToEnergyNet = false;
- }
- this.facing = facing1;
- if (IC2.platform.isSimulating()) {
- if (this.prevFacing != facing) {
- IC2.network.get().updateTileEntityField(this, "facing");
- }
- }
- this.prevFacing = facing;
- if (IC2.platform.isSimulating() && !this.addedToEnergyNet) {
- MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
- this.addedToEnergyNet = true;
- }
- }
-
- @Override
- public List<String> getNetworkedFields() {
- Vector<String> ret = new Vector<String>(2);
- ret.add("active");
- ret.add("facing");
- ret.add("colour");
- return ret;
- }
-
- @Override
- public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
- return true;
- }
-
- @Override
- public float getWrenchDropRate() {
- return 1;
- }
-
- @Override
- public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
- return IHLUtils.getThisModItemStack("lightBulb");
- }
-
- @Override
- public double getDemandedEnergy() {
- if (energy > 10d) {
- return 0d;
- }
- return Integer.MAX_VALUE;
- }
-
- @Override
- public int getSinkTier() {
- return 1;
- }
-
- @Override
- public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
- this.energy += amount;
- return 0.0D;
- }
-
- public boolean getActive() {
- return this.active;
- }
-
- public void setActive(boolean active1) {
- this.active = active1;
- if (this.prevActive != active1) {
- IC2.network.get().updateTileEntityField(this, "active");
- updateLightState();
- }
- this.prevActive = active1;
- }
-
- public void setActiveWithoutNotify(boolean active1) {
- this.active = active1;
- this.prevActive = active1;
- }
-}
diff --git a/ihl/enviroment/LightHandler.java b/ihl/enviroment/LightHandler.java
deleted file mode 100644
index 31a921e..0000000
--- a/ihl/enviroment/LightHandler.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package ihl.enviroment;
-
-import java.util.BitSet;
-import java.util.HashSet;
-import java.util.Set;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ihl.IHLMod;
-import ihl.utils.IHLMathUtils;
-import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
-import net.minecraft.init.Blocks;
-import net.minecraft.world.World;
-
-@SideOnly(value = Side.CLIENT)
-public class LightHandler {
-
- private int[][] directionMasks;
- private int[][] vectors;
- private int bits;
- private int halfValue;
-
- private int lightBitsPerDimension = 10;
- private int maxLightRadius = (1 << lightBitsPerDimension - 1) - 1;
- private int bitmask = (1 << lightBitsPerDimension) - 1;
- public final Set<LightSource> lightSources = new HashSet<LightSource>();
-
- public LightHandler() {
- this.directionMasks = IHLMod.explosionHandler.directionMasks;
- this.vectors = IHLMod.explosionHandler.vectors;
- this.bits = IHLMod.explosionHandler.bits;
- this.halfValue = IHLMod.explosionHandler.halfValue;
- }
-
- public int encodeXYZ(int x, int y, int z) {
- return x + maxLightRadius << lightBitsPerDimension * 2 | y + maxLightRadius << lightBitsPerDimension
- | z + maxLightRadius;
- }
-
- public int[] decodeXYZ(int l) {
- return new int[] { (l >>> lightBitsPerDimension * 2) - maxLightRadius,
- ((l >>> lightBitsPerDimension) & bitmask) - maxLightRadius, (l & bitmask) - maxLightRadius };
- }
-
- public LightSource calculateLightSource(World world, int sourceX, int sourceY, int sourceZ, int power, int red,
- int green, int blue, double[] ds) {
- LightSource lightSource = new LightSource(sourceX, sourceY, sourceZ, red, green, blue, power);
- int[] borders = { sourceX, sourceY, sourceZ, sourceX, sourceY, sourceZ };
- int[] evSource = { sourceX, sourceY, sourceZ };
- int[] lightSourceXYZ = { sourceX, sourceY, sourceZ };
- for (int i = 0; i < directionMasks.length; i++) {
- int[] directionMask = directionMasks[i];
- this.litBlocksAndGetDescendants(world, evSource, lightSourceXYZ, lightSource.illuminatedBlocks, 0, power>>1,
- directionMask, borders, ds);
- }
- lightSource.setBorders(borders[0], borders[1], borders[2], borders[3], borders[4], borders[5]);
- return lightSource;
- }
-
- private void litBlocksAndGetDescendants(World world, int[] evSource, int[] lightSource, BitSet illuminatedBlocksSet,
- int ev, int power, int[] directionMask, int[] borders, double[] ds) {
- power = this.getNewPower(world, ev, evSource, lightSource, power, directionMask, illuminatedBlocksSet, borders,
- ds);
- power--;
- if (power > 1) {
- if (vectors[ev].length == 0) {
- int[] xyz = IHLMod.explosionHandler.decodeXYZ(ev);
- int xb = xyz[0] >> bits - 1;
- int yb = xyz[1] >> bits - 1;
- int zb = xyz[2] >> bits - 1;
- int hashb = xb << 2 | yb << 1 | zb;
- xyz[0] -= xb * halfValue;
- xyz[1] -= yb * halfValue;
- xyz[2] -= zb * halfValue;
- if (hashb == 0 || xb > 1 || yb > 1 || zb > 1) {
- throw new ArithmeticException("End vectors shall be higher than half value");
- }
- int ev2 = IHLMod.explosionHandler.encodeXYZ(xyz[0], xyz[1], xyz[2]);
- int[] nextEVSource = { evSource[0] + xb * halfValue * directionMask[0],
- evSource[1] + yb * halfValue * directionMask[1],
- evSource[2] + zb * halfValue * directionMask[2] };
- litBlocksAndGetDescendants(world, nextEVSource, lightSource, illuminatedBlocksSet, ev2, power,
- directionMask, borders, ds);
- } else {
- for (int d1 : this.vectors[ev]) {
- litBlocksAndGetDescendants(world, evSource, lightSource, illuminatedBlocksSet, d1, power,
- directionMask, borders, ds);
- }
- }
- }
-
- }
-
- private int getNewPower(World world, int ev, int[] evSource, int[] lightSource, int power, int[] directionMask,
- BitSet illuminatedBlocksSet, int[] borders, double[] ds) {
- int power1 = power;
- int[] xyz = IHLMod.explosionHandler.decodeXYZ(ev);
- int absX = xyz[0] * directionMask[0] + evSource[0];
- int absY = xyz[1] * directionMask[1] + evSource[1];
- int absZ = xyz[2] * directionMask[2] + evSource[2];
- if (absX < borders[0]) {
- borders[0] = absX;
- } else if (absY < borders[1]) {
- borders[1] = absY;
- } else if (absZ < borders[2]) {
- borders[2] = absZ;
- } else if (absX > borders[3]) {
- borders[3] = absX;
- } else if (absY > borders[4]) {
- borders[4] = absY;
- } else if (absZ > borders[5]) {
- borders[5] = absZ;
- }
- power1 = power1 * (255 - world.getBlockLightOpacity(absX, absY, absZ)) / 255;
- int lightBitAddress = this.encodeXYZ(absX - lightSource[0], absY - lightSource[1], absZ - lightSource[2]);
- illuminatedBlocksSet.set(lightBitAddress);
- if (ds != null) {
- float dx = (float) (absX - ds[0]);
- float dy = (float) (absY - ds[1]);
- float dz = (float) (absZ - ds[2]);
- float sqd = dx * dx + dy * dy + dz * dz;
- float d = IHLMathUtils.sqrt(sqd);
- float dx1 = (float) (ds[3] * d);
- float dy1 = (float) (ds[4] * d);
- float dz1 = (float) (ds[5] * d);
- float ddx = dx - dx1;
- float ddy = dy - dy1;
- float ddz = dz - dz1;
- float sqr = ddx * ddx + ddy * ddy + ddz * ddz;
- float sqrmax = (float) ds[6] * sqd + 4f;
- if (sqr > sqrmax) {
- return 0;
- }
- }
- return power1;
- }
-
- public void addLightSource(LightSource lightSource) {
-/* IHLMod.log.info("Added light source at area from "+lightSource.fromX+";"+lightSource.fromY+";"+lightSource.fromZ+
- " to "+lightSource.toX+";"+lightSource.toY+";"+lightSource.toZ);*/
- this.lightSources.add(lightSource);
- Minecraft.getMinecraft().theWorld.markBlockRangeForRenderUpdate(
- lightSource.fromX,
- lightSource.fromY,
- lightSource.fromZ,
- lightSource.toX,
- lightSource.toY,
- lightSource.toZ);
- }
-
- public void removeLightSource(LightSource lightSource) {
- if(!this.lightSources.remove(lightSource)){
- throw new IllegalArgumentException("Requested light source is not presented.");
- }
-/* IHLMod.log.info("Removing light source at area from "+lightSource.fromX+";"+lightSource.fromY+";"+lightSource.fromZ+
- " to "+lightSource.toX+";"+lightSource.toY+";"+lightSource.toZ);*/
- Minecraft.getMinecraft().theWorld.markBlockRangeForRenderUpdate(
- lightSource.fromX,
- lightSource.fromY,
- lightSource.fromZ,
- lightSource.toX,
- lightSource.toY,
- lightSource.toZ);
- }
-}
diff --git a/ihl/enviroment/LightSource.java b/ihl/enviroment/LightSource.java
deleted file mode 100644
index 55f7c6c..0000000
--- a/ihl/enviroment/LightSource.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package ihl.enviroment;
-
-import java.util.BitSet;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ihl.ClientProxy;
-import ihl.IHLMod;
-import ihl.utils.IHLMathUtils;
-import net.minecraft.world.World;
-
-@SideOnly(value = Side.CLIENT)
-public class LightSource {
- private final int centerX;
- private final int centerY;
- private final int centerZ;
- public int fromX;
- public int fromY;
- public int fromZ;
- public int toX;
- public int toY;
- public int toZ;
- private final int red;
- private final int green;
- private final int blue;
- private final int power;
- public final BitSet illuminatedBlocks = new BitSet();
-
- public LightSource(int centerX1, int centerY1, int centerZ1, int red1, int green1, int blue1, int power1) {
- centerX = centerX1;
- centerY = centerY1;
- centerZ = centerZ1;
- red = red1;
- green = green1;
- blue = blue1;
- power = power1;
- }
-
- public void setBorders(int fromX1, int fromY1, int fromZ1, int toX1, int toY1, int toZ1) {
- fromX = fromX1;
- fromY = fromY1;
- fromZ = fromZ1;
- toX = toX1;
- toY = toY1;
- toZ = toZ1;
- }
-
- public boolean isBlockIlluminated(int x, int y, int z) {
- if (x < fromX || x > toX || y < fromY || y > toY || z < fromZ || z > toZ) {
- return false;
- } else {
- int rx = x - centerX;
- int ry = y - centerY;
- int rz = z - centerZ;
- int l = ((ClientProxy) IHLMod.proxy).getLightHandler().encodeXYZ(rx, ry, rz);
- return illuminatedBlocks.get(l);
- }
- }
-
- public int[] getLightValue(int x, int y, int z, int[] normal) {
- int dx = centerX - x;
- int dy = centerY - y;
- int dz = centerZ - z;
- int d = dx * dx + dy * dy + dz * dz;
- if (d == 0) {
- return new int[] { 0xf0, this.red, this.blue, this.green };
- }
- if (normal[0] + normal[1] + normal[2] == 0) {
- dx = dx < 0 ? -dx : dx;
- dy = dy < 0 ? -dy : dy;
- dz = dz < 0 ? -dz : dz;
- } else {
- dx = normal[0] * dx;
- dy = normal[1] * dy;
- dz = normal[2] * dz;
- dx = dx > 0 ? dx : 0;
- dy = dy > 0 ? dy : 0;
- dz = dz > 0 ? dz : 0;
- }
- int r = power * (dx + dy + dz) / d;
- r = r<0?0:r;
- int brightness = r > 15 ? 15 : r;
- return new int[] { brightness << 4, this.red*r, this.green*r, this.blue*r};
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof LightSource) {
- LightSource otherLS = (LightSource) o;
- return this.centerX == otherLS.centerX && this.centerY == otherLS.centerY && this.centerZ == otherLS.centerZ
- && this.fromX == otherLS.fromX && this.fromY == otherLS.fromY && this.fromZ == otherLS.fromZ
- && this.toX == otherLS.toX && this.toY == otherLS.toY && this.toZ == otherLS.toZ;
- }
- return false;
- }
-
- public void provideLight(World world, int x, int y, int z) {
- int dx = x-centerX;//100 10 20
- int dy = y-centerY;
- int dz = z-centerZ;
- int sqd = dx*dx+dy*dy+dz*dz;
- float d = IHLMathUtils.sqrt(sqd);
- float dx1 = dx/d;
- float dy1 = dy/d;
- float dz1 = dz/d;
- float x1 = x+0.5f;
- float y1 = y+0.5f;
- float z1 = z+0.5f;
- for(int i=0;i<64;i++){
- x1+=dx1;
- y1+=dy1;
- z1+=dz1;
- int absX = (int)x1;
- int absY = (int)y1;
- int absZ = (int)z1;
- int ddx = absX-centerX;
- int ddy = absY-centerY;
- int ddz = absZ-centerZ;
- this.illuminatedBlocks.set(((ClientProxy) IHLMod.proxy).getLightHandler().encodeXYZ(ddx, ddy, ddz));
- if (absX < fromX) {
- fromX = absX;
- } else if (absY < fromY) {
- fromY = absY;
- } else if (absZ < fromZ) {
- fromZ = absZ;
- } else if (absX > toX) {
- toX = absX;
- } else if (absY > toY) {
- toY = absY;
- } else if (absZ > toZ) {
- toZ = absZ;
- }
- if(world.getBlockLightOpacity(absX, absY, absZ)>192) {
- break;
- }
- }
- }
-
- public void castShadow(World world, int x, int y, int z) {
- int dx = x-centerX;
- int dy = y-centerY;
- int dz = z-centerZ;
- int sqd = dx*dx+dy*dy+dz*dz;
- float d = IHLMathUtils.sqrt(sqd);
- float dx1 = dx/d;
- float dy1 = dy/d;
- float dz1 = dz/d;
- float x1 = x+0.5f;
- float y1 = y+0.5f;
- float z1 = z+0.5f;
- x1+=dx1;
- y1+=dy1;
- z1+=dz1;
- for(int i=0;i<64;i++){
- x1+=dx1;
- y1+=dy1;
- z1+=dz1;
- int absX = (int)x1;
- int absY = (int)y1;
- int absZ = (int)z1;
- int ddx = absX-centerX;
- int ddy = absY-centerY;
- int ddz = absZ-centerZ;
- this.illuminatedBlocks.clear(((ClientProxy) IHLMod.proxy).getLightHandler().encodeXYZ(ddx, ddy, ddz));
- if (absX < fromX) {
- fromX = absX;
- } else if (absY < fromY) {
- fromY = absY;
- } else if (absZ < fromZ) {
- fromZ = absZ;
- } else if (absX > toX) {
- toX = absX;
- } else if (absY > toY) {
- toY = absY;
- } else if (absZ > toZ) {
- toZ = absZ;
- }
- if(world.getBlockLightOpacity(absX, absY, absZ)>192) {
- break;
- }
- }
- }
-}
diff --git a/ihl/enviroment/SpotlightBlock.java b/ihl/enviroment/SpotlightBlock.java
deleted file mode 100644
index 02cafd1..0000000
--- a/ihl/enviroment/SpotlightBlock.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package ihl.enviroment;
-
-import ic2.core.IC2;
-import ihl.IHLCreativeTab;
-import ihl.items_blocks.IHLItemBlock;
-
-import java.util.List;
-import java.util.Random;
-
-import net.minecraft.block.Block;
-import net.minecraft.block.ITileEntityProvider;
-import net.minecraft.block.material.Material;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemDye;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.IBlockAccess;
-import net.minecraft.world.World;
-import cpw.mods.fml.common.registry.GameRegistry;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-
-public class SpotlightBlock extends Block implements ITileEntityProvider
-{
-
- public SpotlightBlock(String unlocalizedName1)
- {
- super(Material.glass);
- this.setStepSound(soundTypeGlass);
- this.setBlockName(unlocalizedName1);
- GameRegistry.registerBlock(this,IHLItemBlock.class, unlocalizedName1);
- this.setHardness(0.3F);
- this.setResistance(0.5F);
- this.setCreativeTab(IHLCreativeTab.tab);
- this.setBlockTextureName("glass");
- }
-
- @Override
- public boolean hasTileEntity(int metadata)
- {
- return true;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @SideOnly(Side.CLIENT)
- public void getSubBlocks(Item item, CreativeTabs tab, List itemlist) {
- for (int colour : ItemDye.field_150922_c) {
- ItemStack stack = new ItemStack(item);
- stack.stackTagCompound = new NBTTagCompound();
- stack.stackTagCompound.setInteger("colour", colour);
- itemlist.add(stack);
- }
- }
-
-
-
- /**
- * Returns the quantity of items to drop on block destruction.
- */
- @Override
- public int quantityDropped(Random random)
- {
- return 0;
- }
-
- @Override
- public boolean renderAsNormalBlock()
- {
- return false;
- }
-
- /**
- * The type of render function that is called for this block
- */
- @Override
- public int getRenderType()
- {
- return -2;
- }
-
- @Override
- public boolean isOpaqueCube()
- {
- return false;
- }
-
- @Override
- public boolean isNormalCube()
- {
- return false;
- }
-
- @Override
- public TileEntity createNewTileEntity(World arg0, int arg1)
- {
- return new SpotlightTileEntity();
- }
-
- @Override
- public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack)
- {
- TileEntity t = world.getTileEntity(x, y, z);
- if(IC2.platform.isSimulating() && t instanceof SpotlightTileEntity)
- {
- SpotlightTileEntity te = (SpotlightTileEntity)t;
- te.setDirectionVector(player);
- if(stack.stackTagCompound!=null)
- te.colour=stack.stackTagCompound.getInteger("colour");
- }
- }
-
- @Override
- public void onBlockPreDestroy(World world, int x, int y, int z, int meta) {
- if (world.isRemote) {
- TileEntity te = world.getTileEntity(x, y, z);
- if (te != null && te instanceof LightBulbTileEntity) {
- LightBulbTileEntity ate = (LightBulbTileEntity) te;
- ate.invalidate();
- }
- }
- super.onBlockPreDestroy(world, x, y, z, meta);
- }
-
- @Override
- public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z)
- {
- TileEntity te = world.getTileEntity(x,y,z);
- if(IC2.platform.isSimulating() && te instanceof SpotlightTileEntity)
- {
- ((SpotlightTileEntity)te).setDirectionVector(player);
- return true;
- }
- return false;
- }
-
- public int getLightValue(IBlockAccess world, int x, int y, int z) {
- TileEntity te = world.getTileEntity(x, y, z);
- if(te instanceof LightBulbTileEntity && ((LightBulbTileEntity)te).getActive()){
- return 15;
- }
- return 0;
- }
-} \ No newline at end of file
diff --git a/ihl/enviroment/SpotlightModel.java b/ihl/enviroment/SpotlightModel.java
deleted file mode 100644
index 057bf94..0000000
--- a/ihl/enviroment/SpotlightModel.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package ihl.enviroment;
-
-import ihl.model.IHLModelRenderer;
-import net.minecraft.client.model.ModelBase;
-
-
-public class SpotlightModel extends ModelBase
-{
- //fields
- IHLModelRenderer Base;
- IHLModelRenderer RotatingPart1;
- IHLModelRenderer RotatingPart2;
- IHLModelRenderer RotatingPart3Halo;
-
- public SpotlightModel()
- {
- textureWidth = 64;
- textureHeight = 32;
- setTextureOffset("Base.Shape1", 0, 0);
- setTextureOffset("RotatingPart1.Shape3", 0, 0);
- setTextureOffset("RotatingPart1.Shape2", 0, 0);
- setTextureOffset("RotatingPart1.Shape4", 0, 0);
- setTextureOffset("RotatingPart2.Shape5", 0, 15);
- setTextureOffset("RotatingPart2.Shape6", 13, 14);
- setTextureOffset("RotatingPart2.Shape7", 7, 15);
- setTextureOffset("RotatingPart2.Shape8", 14, 8);
- setTextureOffset("RotatingPart2.Shape9", 6, 8);
- setTextureOffset("RotatingPart2.Shape10", 0, 23);
- setTextureOffset("RotatingPart2.Shape11", 0, 0);
- setTextureOffset("RotatingPart2.Shape12", 0, 0);
- setTextureOffset("RotatingPart3Halo.Shape13", 32, 0);
-
- Base = new IHLModelRenderer(this, "Base");
- Base.setRotationPoint(0F, 16F, 0F);
- setRotation(Base, 0F, 0F, 0F);
- Base.mirror = false;
- Base.addBox("Shape1", -7F, -7F, 7F, 14, 14, 1);
- RotatingPart1 = new IHLModelRenderer(this, "RotatingPart1");
- RotatingPart1.setRotationPoint(0F, 16F, 0F);
- setRotation(RotatingPart1, 0F, 0F, 0F);
- RotatingPart1.mirror = false;
- RotatingPart1.addBox("Shape3", 5F, -1F, -1F, 1, 2, 8);
- RotatingPart1.addBox("Shape2", -6F, -1F, -1F, 1, 2, 8);
- RotatingPart1.addBox("Shape4", -5F, -1F, 6F, 10, 2, 1);
- RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2");
- RotatingPart2.setRotationPoint(0F, 16F, 0F);
- setRotation(RotatingPart2, 0F, 0F, 0F);
- RotatingPart2.mirror = false;
- RotatingPart2.addBox("Shape5", -4F, -4F, -6F, 7, 1, 7);
- RotatingPart2.addBox("Shape6", -4F, -4F, 1F, 8, 8, 1);
- RotatingPart2.addBox("Shape7", -3F, 3F, -6F, 7, 1, 7);
- RotatingPart2.addBox("Shape8", 3F, -4F, -6F, 1, 7, 7);
- RotatingPart2.addBox("Shape9", -4F, -3F, -6F, 1, 7, 7);
- RotatingPart2.addBox("Shape10", -3F, -3F, -5F, 6, 6, 1);
- RotatingPart2.addBox("Shape11", 4F, -1F, -1F, 1, 2, 2);
- RotatingPart2.addBox("Shape12", -5F, -1F, -1F, 1, 2, 2);
- RotatingPart3Halo = new IHLModelRenderer(this, "RotatingPart3Halo");
- RotatingPart3Halo.setRotationPoint(0F, 16F, 0F);
- setRotation(RotatingPart3Halo, 0F, 0F, 0F);
- RotatingPart3Halo.mirror = false;
- RotatingPart3Halo.addBox("Shape13", -8F, -8F, -6.1F, 16, 16, 0);
- }
-
- private void setRotation(IHLModelRenderer model, float x, float y, float z)
- {
- model.rotateAngleX = x;
- model.rotateAngleY = y;
- model.rotateAngleZ = z;
- }
-
-}
diff --git a/ihl/enviroment/SpotlightRender.java b/ihl/enviroment/SpotlightRender.java
deleted file mode 100644
index 8f48e1a..0000000
--- a/ihl/enviroment/SpotlightRender.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package ihl.enviroment;
-import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ResourceLocation;
-import org.lwjgl.opengl.GL11;
-
-import ihl.IHLModInfo;
-import ihl.utils.IHLRenderUtils;
-
-public class SpotlightRender extends TileEntitySpecialRenderer{
-private SpotlightModel model = new SpotlightModel();
-private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/spotlight.png");
-private final float scale=1F/16F;
-
- public SpotlightRender() {}
-
-
- @Override
- public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8)
- {
- SpotlightTileEntity cte = (SpotlightTileEntity)tile;
- int rotation = 0;
- int rotationz = 0;
- if(tile.getWorldObj() != null)
- {
- switch (cte.getFacing())
- {
- case 0:
- rotationz = 1;
- break;
- case 1:
- rotationz = 3;
- break;
- case 2:
- rotation = 2;
- break;
- case 5:
- rotation = 3;
- break;
- case 3:
- rotation = 0;
- break;
- case 4:
- rotation = 1;
- break;
- default:
- rotation = 0;
- }
- }
- else
- {
- return;
- }
- model.Base.rotateAngleY=(float) (rotation*Math.PI/2);
- model.Base.rotateAngleX=(float) (rotationz*Math.PI/2);
- model.RotatingPart1.rotateAngleY=(float) (rotation*Math.PI/2);
- model.RotatingPart1.rotateAngleX=(float) (rotationz*Math.PI/2);
- model.RotatingPart2.rotateAngleY=(float) (rotation*Math.PI/2);
- model.RotatingPart2.rotateAngleX=(float) (rotationz*Math.PI/2);
- model.RotatingPart3Halo.rotateAngleY=(float) (rotation*Math.PI/2);
- model.RotatingPart3Halo.rotateAngleX=(float) (rotationz*Math.PI/2);
- model.RotatingPart2.rotateAngleX+=cte.rotationPitch;
- model.RotatingPart3Halo.rotateAngleX+=cte.rotationPitch;
- GL11.glPushMatrix();
- GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
- GL11.glScalef(1.0F, -1F, -1F);
- bindTexture(tex);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL11.glColor4f(1f, 1f, 1f, 1f);
- model.Base.render(scale);
- GL11.glTranslatef(model.RotatingPart1.rotationPointX*scale, model.RotatingPart1.rotationPointY*scale, model.RotatingPart1.rotationPointZ*scale);
- GL11.glColor4f((cte.colour>>>16)/255f,((cte.colour>>>8)&255)/255f, (cte.colour&255)/255f,1f);
- switch(cte.getFacing())
- {
- case 0:
- GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
- break;
- case 1:
- GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
- break;
- case 2:
- GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
- break;
- case 3:
- GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
- break;
- case 4:
- GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
- break;
- case 5:
- GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
- break;
- }
- GL11.glTranslatef(-model.RotatingPart1.rotationPointX*scale, -model.RotatingPart1.rotationPointY*scale, -model.RotatingPart1.rotationPointZ*scale);
- model.RotatingPart1.render(scale);
- model.RotatingPart2.render(scale);
- if(cte.getActive())
- {
- IHLRenderUtils.instance.enableAmbientLighting();
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
- model.RotatingPart3Halo.render(scale);
- IHLRenderUtils.instance.disableAmbientLighting();
- }
-
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glPopMatrix(); //end
-
- }
-} \ No newline at end of file
diff --git a/ihl/enviroment/SpotlightTileEntity.java b/ihl/enviroment/SpotlightTileEntity.java
deleted file mode 100644
index d8e55df..0000000
--- a/ihl/enviroment/SpotlightTileEntity.java
+++ /dev/null
@@ -1,212 +0,0 @@
-package ihl.enviroment;
-
-import ic2.api.network.INetworkTileEntityEventListener;
-import ic2.core.IC2;
-import ihl.ClientProxy;
-import ihl.IHLMod;
-import ihl.IHLModInfo;
-import ihl.handpump.XYZ;
-import ihl.utils.IHLUtils;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import net.minecraft.block.Block;
-import net.minecraft.block.material.Material;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.Vec3;
-import net.minecraftforge.common.util.ForgeDirection;
-
-public class SpotlightTileEntity extends LightBulbTileEntity implements INetworkTileEntityEventListener {
- public float directionX = 0f;
- public float directionY = -1f;
- public float directionZ = 0f;
- public float prevDirectionX = 0f;
- public float prevDirectionY = -1f;
- public float prevDirectionZ = 0f;
- public float rotationPitch = 0f;
- public float rotationYaw = 0f;
- public float prevRotationPitch = 0f;
- public float prevRotationYaw = 0f;
- boolean needLightTargetUpdate = false;
-
- @Override
- public void readFromNBT(NBTTagCompound nbttagcompound) {
- super.readFromNBT(nbttagcompound);
- directionX = nbttagcompound.getFloat("directionX");
- directionY = nbttagcompound.getFloat("directionY");
- directionZ = nbttagcompound.getFloat("directionZ");
- this.rotationPitch = this.getVectorPitchAngle(directionX,directionY,directionZ);
- this.rotationYaw = this.getVectorYawAngle(directionX,directionY,directionZ);
- needLightTargetUpdate = true;
- }
-
- @Override
- public void writeToNBT(NBTTagCompound nbttagcompound) {
- super.writeToNBT(nbttagcompound);
- nbttagcompound.setDouble("directionX", directionX);
- nbttagcompound.setDouble("directionY", directionY);
- nbttagcompound.setDouble("directionZ", directionZ);
- }
-
- @Override
- public List<String> getNetworkedFields() {
- List<String> list = super.getNetworkedFields();
- list.add("needLightTargetUpdate");
- list.add("rotationPitch");
- list.add("rotationYaw");
- list.add("directionX");
- list.add("directionY");
- list.add("directionZ");
- return list;
- }
-
- @Override
- public void updateEntity() {
- super.updateEntity();
- if (this.worldObj.isRemote) {
- if(this.directionX!=this.prevDirectionX ||
- this.directionY!=this.prevDirectionY ||
- this.directionZ!=this.prevDirectionZ){
- updateLightState();
- this.prevDirectionX=this.directionX;
- this.prevDirectionY=this.directionY;
- this.prevDirectionZ=this.directionZ;
- }
- } else if (needLightTargetUpdate) {
- this.updateLightState();
- needLightTargetUpdate = false;
- }
- if (!this.worldObj.isRemote) {
- if (this.prevRotationPitch != this.rotationPitch) {
- IC2.network.get().updateTileEntityField(this, "rotationPitch");
- this.prevRotationPitch = this.rotationPitch;
- }
- if (this.prevRotationYaw != this.rotationYaw) {
- IC2.network.get().updateTileEntityField(this, "rotationYaw");
- this.prevRotationYaw = this.rotationYaw;
- }
- }
- }
-
- @Override
- public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
- return IHLUtils.getThisModItemStack("spotlight");
- }
-
- public void setDirectionVector(EntityLivingBase player) {
- ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing());
- Vec3 lookVec = player.getLookVec();
- if (lookVec.xCoord * dir.offsetX + lookVec.yCoord * dir.offsetY + lookVec.zCoord * dir.offsetZ < 0) {
- double x = player.posX - this.xCoord - 0.5D;
- double y = player.posY + player.getEyeHeight() - this.yCoord - 0.5D;
- double z = player.posZ - this.zCoord - 0.5D;
- double d = Math.sqrt(x * x + y * y + z * z);
- directionX = (float) (x / d);
- directionY = (float) (y / d);
- directionZ = (float) (z / d);
- } else {
- Vec3 plook = player.getLookVec();
- directionX = (float) (plook.xCoord);
- directionY = (float) (plook.yCoord);
- directionZ = (float) (plook.zCoord);
- }
- IC2.network.get().updateTileEntityField(this, "directionX");
- IC2.network.get().updateTileEntityField(this, "directionY");
- IC2.network.get().updateTileEntityField(this, "directionZ");
- this.rotationPitch = this.getVectorPitchAngle(directionX,directionY,directionZ);
- this.rotationYaw = this.getVectorYawAngle(directionX,directionY,directionZ);
- this.needLightTargetUpdate = true;
- IC2.network.get().initiateTileEntityEvent(this, 0, true);
- }
-
- private float getVectorPitchAngle(float x, float y, float z) {
- switch (this.getFacing()) {
- case 0:
- return (float) -(Math.abs(Math.asin(z)) + Math.abs(Math.asin(x)));
- case 1:
- return (float) (Math.abs(Math.asin(z)) + Math.abs(Math.asin(x)));
- case 2:
- return (float) (Math.abs(Math.asin(y)) + Math.abs(Math.asin(x)));
- case 3:
- return (float) (Math.abs(Math.asin(y)) + Math.abs(Math.asin(x)));
- case 4:
- return (float) (Math.abs(Math.asin(y)) + Math.abs(Math.asin(z)));
- case 5:
- return (float) (Math.abs(Math.asin(y)) + Math.abs(Math.asin(z)));
- default:
- return (float) (-Math.asin(y));
- }
- }
-
- @SideOnly(value = Side.CLIENT)
- @Override
- protected LightSource createLightSource(int red, int green, int blue) {
- return ((ClientProxy) IHLMod.proxy).getLightHandler().calculateLightSource(worldObj, xCoord, yCoord, zCoord,
- 256, red, green, blue, new double[] { this.xCoord + 0.5f, this.yCoord + 0.5f, this.zCoord + 0.5f,
- this.directionX, this.directionY, this.directionZ, 0.8d });
- }
-
- private float getVectorYawAngle(float x, float y, float z) {
- switch (this.getFacing()) {
- case 0:
- if (z >= 0) {
- return (float) (Math.acos(x / Math.sqrt(x * x + z * z)) - Math.PI / 2);
- } else {
- return (float) (-Math.acos(x / Math.sqrt(x * x + z * z)) - Math.PI / 2);
- }
- case 1:
- if (z >= 0) {
- return (float) (Math.acos(x / Math.sqrt(x * x + z * z)) - Math.PI / 2);
- } else {
- return (float) (-Math.acos(x / Math.sqrt(x * x + z * z)) - Math.PI / 2);
- }
- case 2:
- if (y >= 0) {
- return (float) (-Math.acos(x / Math.sqrt(x * x + y * y)) - Math.PI / 2);
- } else {
- return (float) (Math.acos(x / Math.sqrt(x * x + y * y)) - Math.PI / 2);
- }
- case 3:
- if (y >= 0) {
- return (float) (-Math.acos(x / Math.sqrt(x * x + y * y)) - Math.PI / 2);
- } else {
- return (float) (Math.acos(x / Math.sqrt(x * x + y * y)) - Math.PI / 2);
- }
- case 4:
- if (y >= 0) {
- return (float) (-Math.acos(z / Math.sqrt(z * z + y * y)) - Math.PI / 2);
- } else {
- return (float) (Math.acos(z / Math.sqrt(z * z + y * y)) - Math.PI / 2);
- }
- case 5:
- if (y >= 0) {
- return (float) (-Math.acos(z / Math.sqrt(z * z + y * y)) - Math.PI / 2);
- } else {
- return (float) (Math.acos(z / Math.sqrt(z * z + y * y)) - Math.PI / 2);
- }
- default:
- return 0f;
- }
- }
-
- @Override
- public void onNetworkEvent(int event) {
- this.worldObj.playSound(xCoord + 0.5d, yCoord + 0.5d, zCoord + 0.5d, IHLModInfo.MODID + ":spotlightRotating",
- 10F, 1f, true);
- }
-}
-
-/*
- * -Y DOWN(0, -1, 0) 0 /* +Y UP(0, 1, 0) 1 /* -Z NORTH(0, 0, -1) 2 /* +Z
- * SOUTH(0, 0, 1) 3 /* -X WEST(-1, 0, 0), 4 /* +X EAST(1, 0, 0), 5
- * //VALID_DIRECTIONS = {DOWN, UP, NORTH, SOUTH, WEST, EAST};
- */