Kill induction module and start on balloons :)
This commit is contained in:
parent
6b5f8833f0
commit
510debc0fb
45 changed files with 275 additions and 5684 deletions
|
@ -39,6 +39,7 @@ import mekanism.client.render.RenderTickHandler;
|
|||
import mekanism.client.render.block.BasicRenderingHandler;
|
||||
import mekanism.client.render.block.MachineRenderingHandler;
|
||||
import mekanism.client.render.block.TransmitterRenderingHandler;
|
||||
import mekanism.client.render.entity.RenderBalloon;
|
||||
import mekanism.client.render.entity.RenderObsidianTNTPrimed;
|
||||
import mekanism.client.render.entity.RenderRobit;
|
||||
import mekanism.client.render.item.ItemRenderingHandler;
|
||||
|
@ -63,6 +64,7 @@ import mekanism.client.render.tileentity.RenderUniversalCable;
|
|||
import mekanism.client.sound.Sound;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.CommonProxy;
|
||||
import mekanism.common.EntityBalloon;
|
||||
import mekanism.common.EntityObsidianTNT;
|
||||
import mekanism.common.EntityRobit;
|
||||
import mekanism.common.IElectricChest;
|
||||
|
@ -275,6 +277,7 @@ public class ClientProxy extends CommonProxy
|
|||
//Register entity rendering handlers
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNTPrimed());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityRobit.class, new RenderRobit());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityBalloon.class, new RenderBalloon());
|
||||
|
||||
//Register item handler
|
||||
ItemRenderingHandler handler = new ItemRenderingHandler();
|
||||
|
|
84
common/mekanism/client/model/ModelBalloon.java
Normal file
84
common/mekanism/client/model/ModelBalloon.java
Normal file
|
@ -0,0 +1,84 @@
|
|||
package mekanism.client.model;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelBalloon extends ModelBase
|
||||
{
|
||||
ModelRenderer Balloon2;
|
||||
ModelRenderer Balloon1;
|
||||
ModelRenderer Balloon3;
|
||||
ModelRenderer Balloonnub;
|
||||
ModelRenderer String;
|
||||
|
||||
public ModelBalloon()
|
||||
{
|
||||
textureWidth = 64;
|
||||
textureHeight = 32;
|
||||
|
||||
Balloon2 = new ModelRenderer(this, 0, 0);
|
||||
Balloon2.addBox(-2.5F, -2F, -2F, 5, 4, 4);
|
||||
Balloon2.setRotationPoint(0F, 0F, 0F);
|
||||
Balloon2.setTextureSize(64, 32);
|
||||
Balloon2.mirror = true;
|
||||
setRotation(Balloon2, 0F, 0F, 0F);
|
||||
Balloon1 = new ModelRenderer(this, 0, 8);
|
||||
Balloon1.addBox(-2F, -2F, -2.5F, 4, 4, 5);
|
||||
Balloon1.setRotationPoint(0F, 0F, 0F);
|
||||
Balloon1.setTextureSize(64, 32);
|
||||
Balloon1.mirror = true;
|
||||
setRotation(Balloon1, 0F, 0F, 0F);
|
||||
Balloon3 = new ModelRenderer(this, 18, 0);
|
||||
Balloon3.addBox(-2F, -2.5F, -2F, 4, 5, 4);
|
||||
Balloon3.setRotationPoint(0F, 0F, 0F);
|
||||
Balloon3.setTextureSize(64, 32);
|
||||
Balloon3.mirror = true;
|
||||
setRotation(Balloon3, 0F, 0F, 0F);
|
||||
Balloonnub = new ModelRenderer(this, 18, 9);
|
||||
Balloonnub.addBox(-0.5F, 2.5F, -0.5F, 1, 1, 1);
|
||||
Balloonnub.setRotationPoint(0F, 0F, 0F);
|
||||
Balloonnub.setTextureSize(64, 32);
|
||||
Balloonnub.mirror = true;
|
||||
setRotation(Balloonnub, 0F, 0F, 0F);
|
||||
String = new ModelRenderer(this, 34, 0);
|
||||
String.addBox(-0.5F, 3.5F, -0.5F, 1, 11, 1);
|
||||
String.setRotationPoint(0F, 0F, 0F);
|
||||
String.setTextureSize(64, 32);
|
||||
String.mirror = true;
|
||||
setRotation(String, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float size, EnumColor color)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor3f(color.getColor(0), color.getColor(1), color.getColor(2));
|
||||
GL11.glScalef(1.5F, 1.5F, 1.5F);
|
||||
GL11.glTranslatef(0, -0.07F, 0);
|
||||
|
||||
Balloon2.render(size);
|
||||
Balloon1.render(size);
|
||||
Balloon3.render(size);
|
||||
Balloonnub.render(size);
|
||||
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.2F, 1, 0.2F);
|
||||
String.render(size);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
}
|
43
common/mekanism/client/render/entity/RenderBalloon.java
Normal file
43
common/mekanism/client/render/entity/RenderBalloon.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package mekanism.client.render.entity;
|
||||
|
||||
import mekanism.client.model.ModelBalloon;
|
||||
import mekanism.common.EntityBalloon;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderBalloon extends Render
|
||||
{
|
||||
public ModelBalloon model = new ModelBalloon();
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity entity)
|
||||
{
|
||||
return MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float f, float f1)
|
||||
{
|
||||
EntityBalloon balloon = (EntityBalloon)entity;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
GL11.glRotatef(180, 1, 0, 0);
|
||||
GL11.glTranslatef(0, 0.9F, 0);
|
||||
|
||||
bindTexture(getEntityTexture(entity));
|
||||
|
||||
model.render(0.0625F, balloon.color);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -502,7 +502,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
@Override
|
||||
public String getFlow()
|
||||
{
|
||||
return "" + electricityStored;
|
||||
//TODO return MekanismUtils.getPowerDisplay(20*electricityStored);
|
||||
return MekanismUtils.getPowerDisplay(20*electricityStored);
|
||||
}
|
||||
}
|
||||
|
|
139
common/mekanism/common/EntityBalloon.java
Normal file
139
common/mekanism/common/EntityBalloon.java
Normal file
|
@ -0,0 +1,139 @@
|
|||
package mekanism.common;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
|
||||
{
|
||||
public EnumColor color = EnumColor.DARK_RED;
|
||||
|
||||
public EntityBalloon(World world)
|
||||
{
|
||||
super(world);
|
||||
|
||||
ignoreFrustumCheck = true;
|
||||
preventEntitySpawning = true;
|
||||
setPosition(posX + 0.5F, posY + 3F, posZ + 0.5F);
|
||||
yOffset = height / 2.0F;
|
||||
setSize(0.25F, 0.25F);
|
||||
motionY = 0.04;
|
||||
}
|
||||
|
||||
public EntityBalloon(World world, double x, double y, double z)
|
||||
{
|
||||
this(world);
|
||||
|
||||
setPosition(x + 0.5F, y + 3F, z + 0.5F);
|
||||
|
||||
prevPosX = x;
|
||||
prevPosY = y;
|
||||
prevPosZ = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
motionY = Math.min(motionY*1.02F, 0.2F);
|
||||
|
||||
moveEntity(motionX, motionY, motionZ);
|
||||
|
||||
motionX *= 0.98;
|
||||
motionZ *= 0.98;
|
||||
|
||||
if(onGround)
|
||||
{
|
||||
motionX *= 0.7;
|
||||
motionZ *= 0.7;
|
||||
}
|
||||
|
||||
if(motionY == 0)
|
||||
{
|
||||
motionY = 0.04;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePushed()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith()
|
||||
{
|
||||
return !isDead;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTriggerWalking()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
color = EnumColor.values()[nbtTags.getInteger("color")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitByEntity(Entity entity)
|
||||
{
|
||||
worldObj.playSoundAtEntity(this, "mekanism:etc.Pop", 1, 1);
|
||||
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
worldObj.spawnParticle("reddust", posX + (rand.nextFloat()*.6 - 0.3), posY - 0.8 + (rand.nextFloat()*.6 - 0.3), posZ + (rand.nextFloat()*.6 - 0.3), 0, 0, 0);
|
||||
}
|
||||
|
||||
setDead();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
nbtTags.setInteger("color", color.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(ByteArrayDataOutput data)
|
||||
{
|
||||
data.writeDouble(posX);
|
||||
data.writeDouble(posY);
|
||||
data.writeDouble(posZ);
|
||||
|
||||
data.writeInt(color.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData(ByteArrayDataInput data)
|
||||
{
|
||||
setPosition(data.readDouble(), data.readDouble(), data.readDouble());
|
||||
|
||||
color = EnumColor.values()[data.readInt()];
|
||||
}
|
||||
|
||||
public boolean isInRangeToRenderDist(double par1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldRenderInPass(int pass)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1132,10 +1132,12 @@ public class Mekanism
|
|||
//Entity IDs
|
||||
EntityRegistry.registerGlobalEntityID(EntityObsidianTNT.class, "ObsidianTNT", EntityRegistry.findGlobalUniqueEntityId());
|
||||
EntityRegistry.registerGlobalEntityID(EntityRobit.class, "Robit", EntityRegistry.findGlobalUniqueEntityId());
|
||||
EntityRegistry.registerGlobalEntityID(EntityBalloon.class, "Balloon", EntityRegistry.findGlobalUniqueEntityId());
|
||||
|
||||
//Registrations
|
||||
EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 0, this, 40, 5, true);
|
||||
EntityRegistry.registerModEntity(EntityRobit.class, "Robit", 1, this, 40, 2, true);
|
||||
EntityRegistry.registerModEntity(EntityBalloon.class, "Balloon", 2, this, 40, 1, true);
|
||||
|
||||
//Tile entities
|
||||
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Random;
|
|||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.EntityBalloon;
|
||||
import mekanism.common.IConfigurable;
|
||||
import mekanism.common.IInvConfiguration;
|
||||
import mekanism.common.PacketHandler;
|
||||
|
@ -62,6 +63,8 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
|
|||
{
|
||||
if(!world.isRemote)
|
||||
{
|
||||
world.spawnEntityInWorld(new EntityBalloon(world, x, y, z));
|
||||
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof IConfigurable)
|
||||
|
|
|
@ -1,470 +0,0 @@
|
|||
package mekanism.induction.client;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.GL_SMOOTH;
|
||||
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.glBlendFunc;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
import static org.lwjgl.opengl.GL11.glShadeModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Electric shock Fxs.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class FXElectricBolt extends EntityFX
|
||||
{
|
||||
public static final ResourceLocation PARTICLE_RESOURCE = new ResourceLocation("textures/particle/particles.png");
|
||||
|
||||
/** The width of the electrical bolt. */
|
||||
private float boltWidth;
|
||||
/** The maximum length of the bolt */
|
||||
public double boltLength;
|
||||
/** Electric Bolt's start and end positions; */
|
||||
private BoltPoint start;
|
||||
private BoltPoint end;
|
||||
/** An array of the segments of the bolt. */
|
||||
private List<BoltSegment> segments = new ArrayList<BoltSegment>();
|
||||
private final Map<Integer, Integer> parentIDMap = new HashMap<Integer, Integer>();
|
||||
/** Determines how complex the bolt is. */
|
||||
public float complexity;
|
||||
public int segmentCount;
|
||||
private int maxSplitID;
|
||||
private Random rand;
|
||||
|
||||
public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec, boolean doSplits)
|
||||
{
|
||||
super(world, startVec.x, startVec.y, startVec.z);
|
||||
|
||||
rand = new Random();
|
||||
start = new BoltPoint(startVec);
|
||||
end = new BoltPoint(targetVec);
|
||||
|
||||
if (end.y == Double.POSITIVE_INFINITY)
|
||||
{
|
||||
end.y = Minecraft.getMinecraft().thePlayer.posY + 30;
|
||||
}
|
||||
|
||||
/** By default, we do an electrical color */
|
||||
segmentCount = 1;
|
||||
particleMaxAge = (3 + rand.nextInt(3) - 1);
|
||||
complexity = 2f;
|
||||
boltWidth = 0.05f;
|
||||
boltLength = start.distance(end);
|
||||
setUp(doSplits);
|
||||
}
|
||||
|
||||
public FXElectricBolt(World world, Vector3 startVec, Vector3 targetVec)
|
||||
{
|
||||
this(world, startVec, targetVec, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate all required segments of the entire bolt.
|
||||
*/
|
||||
private void setUp(boolean doSplits)
|
||||
{
|
||||
segments.add(new BoltSegment(start, end));
|
||||
recalculate();
|
||||
|
||||
if (doSplits)
|
||||
{
|
||||
double offsetRatio = boltLength * complexity;
|
||||
split(2, offsetRatio / 10, 0.7f, 0.1f, 20 / 2);
|
||||
split(2, offsetRatio / 15, 0.5f, 0.1f, 25 / 2);
|
||||
split(2, offsetRatio / 25, 0.5f, 0.1f, 28 / 2);
|
||||
split(2, offsetRatio / 38, 0.5f, 0.1f, 30 / 2);
|
||||
split(2, offsetRatio / 55, 0, 0, 0);
|
||||
split(2, offsetRatio / 70, 0, 0, 0);
|
||||
recalculate();
|
||||
|
||||
Collections.sort(segments, new Comparator()
|
||||
{
|
||||
public int compare(BoltSegment bolt1, BoltSegment bolt2)
|
||||
{
|
||||
return Float.compare(bolt2.alpha, bolt1.alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Object obj1, Object obj2)
|
||||
{
|
||||
return compare((BoltSegment) obj1, (BoltSegment) obj2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public FXElectricBolt setColor(float r, float g, float b)
|
||||
{
|
||||
particleRed = r + (rand.nextFloat() * 0.1f) - 0.1f;
|
||||
particleGreen = g + (rand.nextFloat() * 0.1f) - 0.1f;
|
||||
particleBlue = b + (rand.nextFloat() * 0.1f) - 0.1f;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Slits a large segment into multiple smaller ones.
|
||||
*
|
||||
* @param splitAmount - The amount of splits
|
||||
* @param offset - The multiplier scale for the offset.
|
||||
* @param splitChance - The chance of creating a split.
|
||||
* @param splitLength - The length of each split.
|
||||
* @param splitAngle - The angle of the split.
|
||||
*/
|
||||
public void split(int splitAmount, double offset, float splitChance, float splitLength, float splitAngle)
|
||||
{
|
||||
/** Temporarily store old segments in a new array */
|
||||
List<BoltSegment> oldSegments = segments;
|
||||
segments = new ArrayList();
|
||||
/** Previous segment */
|
||||
BoltSegment prev = null;
|
||||
|
||||
for (BoltSegment segment : oldSegments)
|
||||
{
|
||||
prev = segment.prev;
|
||||
/** Length of each subsegment */
|
||||
Vector3 subSegment = segment.difference.clone().scale(1.0F / splitAmount);
|
||||
|
||||
/**
|
||||
* Creates an array of new bolt points. The first and last points of the bolts are the
|
||||
* respected start and end points of the current segment.
|
||||
*/
|
||||
BoltPoint[] newPoints = new BoltPoint[splitAmount + 1];
|
||||
Vector3 startPoint = segment.start;
|
||||
newPoints[0] = segment.start;
|
||||
newPoints[splitAmount] = segment.end;
|
||||
|
||||
/**
|
||||
* Create bolt points.
|
||||
*/
|
||||
for (int i = 1; i < splitAmount; i++)
|
||||
{
|
||||
Vector3 newOffset = segment.difference.getPerpendicular().rotate(rand.nextFloat() * 360, segment.difference).scale((rand.nextFloat() - 0.5F) * offset);
|
||||
Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i));
|
||||
|
||||
newPoints[i] = new BoltPoint(basePoint, newOffset);
|
||||
}
|
||||
|
||||
for (int i = 0; i < splitAmount; i++)
|
||||
{
|
||||
BoltSegment next = new BoltSegment(newPoints[i], newPoints[(i + 1)], segment.alpha, segment.id * splitAmount + i, segment.splitID);
|
||||
next.prev = prev;
|
||||
|
||||
if (prev != null)
|
||||
{
|
||||
prev.next = next;
|
||||
}
|
||||
|
||||
if ((i != 0) && (rand.nextFloat() < splitChance))
|
||||
{
|
||||
Vector3 splitrot = next.difference.xCrossProduct().rotate(rand.nextFloat() * 360, next.difference);
|
||||
Vector3 diff = next.difference.clone().rotate((rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitrot).scale(splitLength);
|
||||
maxSplitID += 1;
|
||||
parentIDMap.put(maxSplitID, next.splitID);
|
||||
BoltSegment split = new BoltSegment(newPoints[i], new BoltPoint(newPoints[(i + 1)].base, newPoints[(i + 1)].offset.clone().translate(diff)), segment.alpha / 2f, next.id, maxSplitID);
|
||||
split.prev = prev;
|
||||
segments.add(split);
|
||||
}
|
||||
|
||||
prev = next;
|
||||
segments.add(next);
|
||||
}
|
||||
|
||||
if (segment.next != null)
|
||||
{
|
||||
segment.next.prev = prev;
|
||||
}
|
||||
}
|
||||
|
||||
segmentCount *= splitAmount;
|
||||
|
||||
}
|
||||
|
||||
private void recalculate()
|
||||
{
|
||||
HashMap<Integer, Integer> lastActiveSegment = new HashMap<Integer, Integer>();
|
||||
|
||||
Collections.sort(segments, new Comparator()
|
||||
{
|
||||
public int compare(BoltSegment o1, BoltSegment o2)
|
||||
{
|
||||
int comp = Integer.valueOf(o1.splitID).compareTo(Integer.valueOf(o2.splitID));
|
||||
|
||||
if (comp == 0)
|
||||
{
|
||||
return Integer.valueOf(o1.id).compareTo(Integer.valueOf(o2.id));
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Object obj, Object obj1)
|
||||
{
|
||||
return compare((BoltSegment) obj, (BoltSegment) obj1);
|
||||
}
|
||||
});
|
||||
|
||||
int lastSplitCalc = 0;
|
||||
int lastActiveSeg = 0;
|
||||
|
||||
for (BoltSegment segment : segments)
|
||||
{
|
||||
if (segment != null)
|
||||
{
|
||||
if (segment.splitID > lastSplitCalc)
|
||||
{
|
||||
lastActiveSegment.put(lastSplitCalc, lastActiveSeg);
|
||||
lastSplitCalc = segment.splitID;
|
||||
|
||||
if(lastActiveSegment.get(parentIDMap.get(segment.splitID)) != null)
|
||||
{
|
||||
lastActiveSeg = lastActiveSegment.get(parentIDMap.get(segment.splitID)).intValue();
|
||||
}
|
||||
else {
|
||||
lastActiveSeg = 0;
|
||||
}
|
||||
}
|
||||
|
||||
lastActiveSeg = segment.id;
|
||||
}
|
||||
}
|
||||
|
||||
lastActiveSegment.put(lastSplitCalc, lastActiveSeg);
|
||||
lastSplitCalc = 0;
|
||||
lastActiveSeg = lastActiveSegment.get(0).intValue();
|
||||
BoltSegment segment;
|
||||
|
||||
for (Iterator<BoltSegment> iterator = segments.iterator(); iterator.hasNext(); segment.recalculate())
|
||||
{
|
||||
segment = iterator.next();
|
||||
|
||||
if (lastSplitCalc != segment.splitID)
|
||||
{
|
||||
lastSplitCalc = segment.splitID;
|
||||
lastActiveSeg = lastActiveSegment.get(segment.splitID);
|
||||
}
|
||||
|
||||
if (segment.id > lastActiveSeg)
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
if (particleAge++ >= particleMaxAge)
|
||||
{
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialframe, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch)
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
tessellator.draw();
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(3042);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "FadedSphere.png"));
|
||||
/**
|
||||
* Render the actual bolts.
|
||||
*/
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setBrightness(15728880);
|
||||
Vector3 playerVector = new Vector3(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch);
|
||||
|
||||
int renderlength = (int) ((particleAge + partialframe + (int) (boltLength * 3.0F)) / (int) (boltLength * 3.0F) * segmentCount);
|
||||
|
||||
for (BoltSegment segment : segments)
|
||||
{
|
||||
if (segment != null && segment.id <= renderlength)
|
||||
{
|
||||
double renderWidth = boltWidth * ((new Vector3(player).distance(segment.start) / 5f + 1f) * (1 + segment.alpha) * 0.5f);
|
||||
renderWidth = Math.min(boltWidth, Math.max(renderWidth, 0));
|
||||
|
||||
if (segment.difference.getMagnitude() > 0 && segment.difference.getMagnitude() != Double.NaN && segment.difference.getMagnitude() != Double.POSITIVE_INFINITY && renderWidth > 0 && renderWidth != Double.NaN && renderWidth != Double.POSITIVE_INFINITY)
|
||||
{
|
||||
Vector3 diffPrev = playerVector.crossProduct(segment.prevDiff).scale(renderWidth / segment.sinPrev);
|
||||
Vector3 diffNext = playerVector.crossProduct(segment.nextDiff).scale(renderWidth / segment.sinNext);
|
||||
Vector3 startVec = segment.start;
|
||||
Vector3 endVec = segment.end;
|
||||
float rx1 = (float) (startVec.x - interpPosX);
|
||||
float ry1 = (float) (startVec.y - interpPosY);
|
||||
float rz1 = (float) (startVec.z - interpPosZ);
|
||||
float rx2 = (float) (endVec.x - interpPosX);
|
||||
float ry2 = (float) (endVec.y - interpPosY);
|
||||
float rz2 = (float) (endVec.z - interpPosZ);
|
||||
|
||||
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, (1.0F - (particleAge >= 0 ? ((float) particleAge / (float) particleMaxAge) : 0.0F) * 0.6f) * segment.alpha);
|
||||
tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D);
|
||||
tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D);
|
||||
tessellator.addVertexWithUV(rx1 + diffPrev.x, ry1 + diffPrev.y, rz1 + diffPrev.z, 0.5D, 1.0D);
|
||||
tessellator.addVertexWithUV(rx2 + diffNext.x, ry2 + diffNext.y, rz2 + diffNext.z, 0.5D, 1.0D);
|
||||
|
||||
/**
|
||||
* Render the bolts balls.
|
||||
*/
|
||||
|
||||
if (segment.next == null)
|
||||
{
|
||||
Vector3 roundEnd = segment.end.clone().translate(segment.difference.clone().normalize().scale(renderWidth));
|
||||
float rx3 = (float) (roundEnd.x - interpPosX);
|
||||
float ry3 = (float) (roundEnd.y - interpPosY);
|
||||
float rz3 = (float) (roundEnd.z - interpPosZ);
|
||||
tessellator.addVertexWithUV(rx3 - diffNext.x, ry3 - diffNext.y, rz3 - diffNext.z, 0.0D, 0.0D);
|
||||
tessellator.addVertexWithUV(rx2 - diffNext.x, ry2 - diffNext.y, rz2 - diffNext.z, 0.5D, 0.0D);
|
||||
tessellator.addVertexWithUV(rx2 + diffNext.x, ry2 + diffNext.y, rz2 + diffNext.z, 0.5D, 1.0D);
|
||||
tessellator.addVertexWithUV(rx3 + diffNext.x, ry3 + diffNext.y, rz3 + diffNext.z, 0.0D, 1.0D);
|
||||
}
|
||||
|
||||
if (segment.prev == null)
|
||||
{
|
||||
Vector3 roundEnd = segment.start.clone().difference(segment.difference.clone().normalize().scale(renderWidth));
|
||||
float rx3 = (float) (roundEnd.x - interpPosX);
|
||||
float ry3 = (float) (roundEnd.y - interpPosY);
|
||||
float rz3 = (float) (roundEnd.z - interpPosZ);
|
||||
tessellator.addVertexWithUV(rx1 - diffPrev.x, ry1 - diffPrev.y, rz1 - diffPrev.z, 0.5D, 0.0D);
|
||||
tessellator.addVertexWithUV(rx3 - diffPrev.x, ry3 - diffPrev.y, rz3 - diffPrev.z, 0.0D, 0.0D);
|
||||
tessellator.addVertexWithUV(rx3 + diffPrev.x, ry3 + diffPrev.y, rz3 + diffPrev.z, 0.0D, 1.0D);
|
||||
tessellator.addVertexWithUV(rx1 + diffPrev.x, ry1 + diffPrev.y, rz1 + diffPrev.z, 0.5D, 1.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glDisable(3042);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(PARTICLE_RESOURCE);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
|
||||
private class BoltPoint extends Vector3
|
||||
{
|
||||
public Vector3 base;
|
||||
public Vector3 offset;
|
||||
|
||||
public BoltPoint(Vector3 b, Vector3 o)
|
||||
{
|
||||
super(b.clone().translate(o));
|
||||
base = b;
|
||||
offset = o;
|
||||
}
|
||||
|
||||
public BoltPoint(Vector3 base)
|
||||
{
|
||||
this(base, new Vector3());
|
||||
}
|
||||
}
|
||||
|
||||
private class BoltSegment
|
||||
{
|
||||
public BoltPoint start;
|
||||
public BoltPoint end;
|
||||
public BoltSegment prev;
|
||||
public BoltSegment next;
|
||||
public float alpha;
|
||||
public int id;
|
||||
public int splitID;
|
||||
|
||||
/**
|
||||
* All differences are cached.
|
||||
*/
|
||||
public Vector3 difference;
|
||||
public Vector3 prevDiff;
|
||||
public Vector3 nextDiff;
|
||||
public double sinPrev;
|
||||
public double sinNext;
|
||||
|
||||
public BoltSegment(BoltPoint start, BoltPoint end)
|
||||
{
|
||||
this(start, end, 1, 0, 0);
|
||||
}
|
||||
|
||||
public BoltSegment(BoltPoint s, BoltPoint e, float a, int i, int id)
|
||||
{
|
||||
start = s;
|
||||
end = e;
|
||||
alpha = a;
|
||||
id = i;
|
||||
splitID = id;
|
||||
difference = end.clone().difference(start);
|
||||
}
|
||||
|
||||
public void recalculate()
|
||||
{
|
||||
if (prev != null)
|
||||
{
|
||||
Vector3 prevDiffNorm = prev.difference.clone().normalize();
|
||||
Vector3 diffNorm = difference.clone().normalize();
|
||||
prevDiff = diffNorm.clone().translate(prevDiffNorm).normalize();
|
||||
sinPrev = Math.sin(diffNorm.anglePreNorm(prevDiffNorm.clone().scale(-1)) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
prevDiff = difference.clone().normalize();
|
||||
sinPrev = 1;
|
||||
}
|
||||
|
||||
if (next != null)
|
||||
{
|
||||
Vector3 nextDiffNorm = next.difference.clone().normalize();
|
||||
Vector3 diffNorm = difference.clone().normalize();
|
||||
nextDiff = diffNorm.clone().translate(nextDiffNorm).normalize();
|
||||
sinNext = Math.sin(diffNorm.anglePreNorm(nextDiffNorm.clone().scale(-1)) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextDiff = difference.clone().normalize();
|
||||
sinNext = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package mekanism.induction.client;
|
||||
|
||||
import mekanism.induction.client.gui.GuiBattery;
|
||||
import mekanism.induction.client.render.BlockRenderingHandler;
|
||||
import mekanism.induction.client.render.RenderBattery;
|
||||
import mekanism.induction.client.render.RenderEMContractor;
|
||||
import mekanism.induction.client.render.RenderTesla;
|
||||
import mekanism.induction.common.InductionCommonProxy;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import mekanism.induction.common.tileentity.TileEntityTesla;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class InductionClientProxy extends InductionCommonProxy
|
||||
{
|
||||
public static int INDUCTION_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void registerRenderers()
|
||||
{
|
||||
RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE);
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBattery.class, new RenderBattery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(tileEntity instanceof TileEntityBattery)
|
||||
{
|
||||
return new GuiBattery(player.inventory, ((TileEntityBattery) tileEntity));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFancy()
|
||||
{
|
||||
return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b, boolean split)
|
||||
{
|
||||
if(world.isRemote)
|
||||
{
|
||||
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXElectricBolt(world, start, target, split).setColor(r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package mekanism.induction.client.gui;
|
||||
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.induction.common.BatteryManager;
|
||||
import mekanism.induction.common.inventory.container.ContainerBattery;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
|
||||
public class GuiBattery extends GuiContainer
|
||||
{
|
||||
public TileEntityBattery tileEntity;
|
||||
|
||||
public GuiBattery(InventoryPlayer inventory, TileEntityBattery tentity)
|
||||
{
|
||||
super(new ContainerBattery(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
ySize += 41;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString("Battery", 43, 6, 0x404040);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
fontRenderer.drawString("Cells: " + tileEntity.clientCells + " / " + (tileEntity.clientVolume*BatteryManager.CELLS_PER_BATTERY), 62, 23, 0x404040);
|
||||
fontRenderer.drawString("Energy: ", 62, 33, 0x404040);
|
||||
fontRenderer.drawString(ElectricityDisplay.getDisplay(this.tileEntity.getEnergyStored(), ElectricUnit.JOULES, 4, true), 62, 43, 0x404040);
|
||||
fontRenderer.drawString("Max: " + ElectricityDisplay.getDisplayShort(this.tileEntity.getMaxEnergyStored(), ElectricUnit.JOULES), 62, 53, 0x404040);
|
||||
fontRenderer.drawString("Percentage: " + (int) (this.tileEntity.getEnergyStored() / this.tileEntity.getMaxEnergyStored() * 100) + "%", 62, 63, 0x404040);
|
||||
fontRenderer.drawString("Volume: " + tileEntity.structure.getVolume(), 62, 73, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBattery.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
int scale = (int) ((tileEntity.getEnergyStored() / tileEntity.getMaxEnergyStored()) * 105);
|
||||
drawTexturedModalRect(guiWidth + 61, guiHeight + 102, 0, 207, scale, 12);
|
||||
}
|
||||
}
|
|
@ -1,348 +0,0 @@
|
|||
package mekanism.induction.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelBattery extends ModelBase
|
||||
{
|
||||
// fields
|
||||
ModelRenderer BackInnerPanel;
|
||||
ModelRenderer Slide1;
|
||||
ModelRenderer Slide2;
|
||||
ModelRenderer Slide3;
|
||||
ModelRenderer Slide4;
|
||||
ModelRenderer Slide5;
|
||||
ModelRenderer Slide6;
|
||||
ModelRenderer Slide7;
|
||||
ModelRenderer Slide8;
|
||||
ModelRenderer Slide9;
|
||||
ModelRenderer Slide10;
|
||||
ModelRenderer Slide11;
|
||||
ModelRenderer Slide12;
|
||||
ModelRenderer Slide13;
|
||||
ModelRenderer Slide14;
|
||||
ModelRenderer Slide15;
|
||||
ModelRenderer Slide16;
|
||||
ModelRenderer Slide17;
|
||||
ModelRenderer Slide18;
|
||||
ModelRenderer Slide19;
|
||||
ModelRenderer Slide20;
|
||||
ModelRenderer Slide21;
|
||||
ModelRenderer Slide22;
|
||||
ModelRenderer Slide23;
|
||||
ModelRenderer Slide24;
|
||||
ModelRenderer Slide25;
|
||||
ModelRenderer Slide26;
|
||||
ModelRenderer Slide27;
|
||||
ModelRenderer Slide28;
|
||||
ModelRenderer FrontInnerPanel;
|
||||
ModelRenderer RightInnerPanel;
|
||||
ModelRenderer LeftInnerPanel;
|
||||
ModelRenderer Podium;
|
||||
ModelRenderer BottomBase;
|
||||
ModelRenderer PodiumBase;
|
||||
ModelRenderer TapNode1;
|
||||
ModelRenderer TapNode2;
|
||||
ModelRenderer TapNode3;
|
||||
ModelRenderer TapNode4;
|
||||
ModelRenderer ElectricalConduit;
|
||||
|
||||
public ModelBattery()
|
||||
{
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
BackInnerPanel = new ModelRenderer(this, 0, 46);
|
||||
BackInnerPanel.addBox(0F, 0F, 0F, 14, 15, 3);
|
||||
BackInnerPanel.setRotationPoint(-7F, 9F, 4F);
|
||||
BackInnerPanel.setTextureSize(64, 32);
|
||||
BackInnerPanel.mirror = true;
|
||||
setRotation(BackInnerPanel, 0F, 0F, 0F);
|
||||
Slide1 = new ModelRenderer(this, 39, 0);
|
||||
Slide1.addBox(0F, 0F, 0F, 14, 1, 1);
|
||||
Slide1.setRotationPoint(-7F, 15F, 7F);
|
||||
Slide1.setTextureSize(64, 32);
|
||||
Slide1.mirror = true;
|
||||
setRotation(Slide1, 0F, 0F, 0F);
|
||||
Slide2 = new ModelRenderer(this, 39, 0);
|
||||
Slide2.addBox(0F, 0F, 0F, 14, 1, 1);
|
||||
Slide2.setRotationPoint(-7F, 15F, -8F);
|
||||
Slide2.setTextureSize(64, 32);
|
||||
Slide2.mirror = true;
|
||||
setRotation(Slide2, 0F, 0F, 0F);
|
||||
Slide3 = new ModelRenderer(this, 35, 0);
|
||||
Slide3.addBox(0F, 0F, 0F, 16, 1, 1);
|
||||
Slide3.setRotationPoint(-8F, 23F, -8F);
|
||||
Slide3.setTextureSize(64, 32);
|
||||
Slide3.mirror = true;
|
||||
setRotation(Slide3, 0F, 0F, 0F);
|
||||
Slide4 = new ModelRenderer(this, 35, 0);
|
||||
Slide4.addBox(0F, 0F, 0F, 16, 1, 1);
|
||||
Slide4.setRotationPoint(-8F, 23F, 7F);
|
||||
Slide4.setTextureSize(64, 32);
|
||||
Slide4.mirror = true;
|
||||
setRotation(Slide4, 0F, 0F, 0F);
|
||||
Slide5 = new ModelRenderer(this, 0, 19);
|
||||
Slide5.addBox(0F, 0F, 0F, 1, 1, 14);
|
||||
Slide5.setRotationPoint(-8F, 16F, -7F);
|
||||
Slide5.setTextureSize(64, 32);
|
||||
Slide5.mirror = true;
|
||||
setRotation(Slide5, 0F, 0F, 0F);
|
||||
Slide6 = new ModelRenderer(this, 0, 19);
|
||||
Slide6.addBox(0F, 0F, 0F, 1, 1, 14);
|
||||
Slide6.setRotationPoint(7F, 16F, -7F);
|
||||
Slide6.setTextureSize(64, 32);
|
||||
Slide6.mirror = true;
|
||||
setRotation(Slide6, 0F, 0F, 0F);
|
||||
Slide7 = new ModelRenderer(this, 0, 19);
|
||||
Slide7.addBox(0F, 0F, 0F, 1, 1, 14);
|
||||
Slide7.setRotationPoint(7F, 23F, -7F);
|
||||
Slide7.setTextureSize(64, 32);
|
||||
Slide7.mirror = true;
|
||||
setRotation(Slide7, 0F, 0F, 0F);
|
||||
Slide8 = new ModelRenderer(this, 0, 19);
|
||||
Slide8.addBox(0F, 0F, 0F, 1, 1, 14);
|
||||
Slide8.setRotationPoint(-8F, 23F, -7F);
|
||||
Slide8.setTextureSize(64, 32);
|
||||
Slide8.mirror = true;
|
||||
setRotation(Slide8, 0F, 0F, 0F);
|
||||
Slide9 = new ModelRenderer(this, 0, 0);
|
||||
Slide9.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide9.setRotationPoint(7F, 9F, 0F);
|
||||
Slide9.setTextureSize(64, 32);
|
||||
Slide9.mirror = true;
|
||||
setRotation(Slide9, 0F, 0F, 0F);
|
||||
Slide10 = new ModelRenderer(this, 0, 0);
|
||||
Slide10.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide10.setRotationPoint(7F, 9F, -8F);
|
||||
Slide10.setTextureSize(64, 32);
|
||||
Slide10.mirror = true;
|
||||
setRotation(Slide10, 0F, 0F, 0F);
|
||||
Slide11 = new ModelRenderer(this, 0, 0);
|
||||
Slide11.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide11.setRotationPoint(0F, 9F, -8F);
|
||||
Slide11.setTextureSize(64, 32);
|
||||
Slide11.mirror = true;
|
||||
setRotation(Slide11, 0F, 0F, 0F);
|
||||
Slide12 = new ModelRenderer(this, 0, 0);
|
||||
Slide12.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide12.setRotationPoint(0F, 9F, 7F);
|
||||
Slide12.setTextureSize(64, 32);
|
||||
Slide12.mirror = true;
|
||||
setRotation(Slide12, 0F, 0F, 0F);
|
||||
Slide13 = new ModelRenderer(this, 0, 0);
|
||||
Slide13.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide13.setRotationPoint(-8F, 9F, -8F);
|
||||
Slide13.setTextureSize(64, 32);
|
||||
Slide13.mirror = true;
|
||||
setRotation(Slide13, 0F, 0F, 0F);
|
||||
Slide14 = new ModelRenderer(this, 0, 0);
|
||||
Slide14.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide14.setRotationPoint(-8F, 9F, 0F);
|
||||
Slide14.setTextureSize(64, 32);
|
||||
Slide14.mirror = true;
|
||||
setRotation(Slide14, 0F, 0F, 0F);
|
||||
Slide15 = new ModelRenderer(this, 0, 0);
|
||||
Slide15.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide15.setRotationPoint(-1F, 9F, -8F);
|
||||
Slide15.setTextureSize(64, 32);
|
||||
Slide15.mirror = true;
|
||||
setRotation(Slide15, 0F, 0F, 0F);
|
||||
Slide16 = new ModelRenderer(this, 0, 0);
|
||||
Slide16.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide16.setRotationPoint(-1F, 9F, 7F);
|
||||
Slide16.setTextureSize(64, 32);
|
||||
Slide16.mirror = true;
|
||||
setRotation(Slide16, 0F, 0F, 0F);
|
||||
Slide17 = new ModelRenderer(this, 0, 0);
|
||||
Slide17.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide17.setRotationPoint(7F, 9F, 7F);
|
||||
Slide17.setTextureSize(64, 32);
|
||||
Slide17.mirror = true;
|
||||
setRotation(Slide17, 0F, 0F, 0F);
|
||||
Slide18 = new ModelRenderer(this, 0, 0);
|
||||
Slide18.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide18.setRotationPoint(-8F, 9F, 7F);
|
||||
Slide18.setTextureSize(64, 32);
|
||||
Slide18.mirror = true;
|
||||
setRotation(Slide18, 0F, 0F, 0F);
|
||||
Slide19 = new ModelRenderer(this, 0, 0);
|
||||
Slide19.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide19.setRotationPoint(7F, 9F, -1F);
|
||||
Slide19.setTextureSize(64, 32);
|
||||
Slide19.mirror = true;
|
||||
setRotation(Slide19, 0F, 0F, 0F);
|
||||
Slide20 = new ModelRenderer(this, 0, 0);
|
||||
Slide20.addBox(0F, 0F, 0F, 1, 14, 1);
|
||||
Slide20.setRotationPoint(-8F, 9F, -1F);
|
||||
Slide20.setTextureSize(64, 32);
|
||||
Slide20.mirror = true;
|
||||
setRotation(Slide20, 0F, 0F, 0F);
|
||||
Slide21 = new ModelRenderer(this, 0, 19);
|
||||
Slide21.addBox(0F, 0F, 0F, 1, 1, 14);
|
||||
Slide21.setRotationPoint(-8F, 15F, -7F);
|
||||
Slide21.setTextureSize(64, 32);
|
||||
Slide21.mirror = true;
|
||||
setRotation(Slide21, 0F, 0F, 0F);
|
||||
Slide22 = new ModelRenderer(this, 0, 19);
|
||||
Slide22.addBox(0F, 0F, 0F, 1, 1, 14);
|
||||
Slide22.setRotationPoint(7F, 8F, -7F);
|
||||
Slide22.setTextureSize(64, 32);
|
||||
Slide22.mirror = true;
|
||||
setRotation(Slide22, 0F, 0F, 0F);
|
||||
Slide23 = new ModelRenderer(this, 0, 19);
|
||||
Slide23.addBox(0F, 0F, 0F, 1, 1, 14);
|
||||
Slide23.setRotationPoint(-8F, 8F, -7F);
|
||||
Slide23.setTextureSize(64, 32);
|
||||
Slide23.mirror = true;
|
||||
setRotation(Slide23, 0F, 0F, 0F);
|
||||
Slide24 = new ModelRenderer(this, 0, 19);
|
||||
Slide24.addBox(0F, 0F, 0F, 1, 1, 14);
|
||||
Slide24.setRotationPoint(7F, 15F, -7F);
|
||||
Slide24.setTextureSize(64, 32);
|
||||
Slide24.mirror = true;
|
||||
setRotation(Slide24, 0F, 0F, 0F);
|
||||
Slide25 = new ModelRenderer(this, 35, 0);
|
||||
Slide25.addBox(0F, 0F, 0F, 16, 1, 1);
|
||||
Slide25.setRotationPoint(-8F, 8F, 7F);
|
||||
Slide25.setTextureSize(64, 32);
|
||||
Slide25.mirror = true;
|
||||
setRotation(Slide25, 0F, 0F, 0F);
|
||||
Slide26 = new ModelRenderer(this, 35, 0);
|
||||
Slide26.addBox(0F, 0F, 0F, 16, 1, 1);
|
||||
Slide26.setRotationPoint(-8F, 8F, -8F);
|
||||
Slide26.setTextureSize(64, 32);
|
||||
Slide26.mirror = true;
|
||||
setRotation(Slide26, 0F, 0F, 0F);
|
||||
Slide27 = new ModelRenderer(this, 39, 0);
|
||||
Slide27.addBox(0F, 0F, 0F, 14, 1, 1);
|
||||
Slide27.setRotationPoint(-7F, 16F, 7F);
|
||||
Slide27.setTextureSize(64, 32);
|
||||
Slide27.mirror = true;
|
||||
setRotation(Slide27, 0F, 0F, 0F);
|
||||
Slide28 = new ModelRenderer(this, 39, 0);
|
||||
Slide28.addBox(0F, 0F, 0F, 14, 1, 1);
|
||||
Slide28.setRotationPoint(-7F, 16F, -8F);
|
||||
Slide28.setTextureSize(64, 32);
|
||||
Slide28.mirror = true;
|
||||
setRotation(Slide28, 0F, 0F, 0F);
|
||||
FrontInnerPanel = new ModelRenderer(this, 0, 46);
|
||||
FrontInnerPanel.addBox(0F, 0F, 0F, 14, 15, 3);
|
||||
FrontInnerPanel.setRotationPoint(-7F, 9F, -7F);
|
||||
FrontInnerPanel.setTextureSize(64, 32);
|
||||
FrontInnerPanel.mirror = true;
|
||||
setRotation(FrontInnerPanel, 0F, 0F, 0F);
|
||||
RightInnerPanel = new ModelRenderer(this, 0, 65);
|
||||
RightInnerPanel.addBox(0F, 0F, 0F, 3, 15, 8);
|
||||
RightInnerPanel.setRotationPoint(-7F, 9F, -4F);
|
||||
RightInnerPanel.setTextureSize(64, 32);
|
||||
RightInnerPanel.mirror = true;
|
||||
setRotation(RightInnerPanel, 0F, 0F, 0F);
|
||||
LeftInnerPanel = new ModelRenderer(this, 0, 65);
|
||||
LeftInnerPanel.addBox(0F, 0F, 0F, 3, 15, 8);
|
||||
LeftInnerPanel.setRotationPoint(4F, 9F, -4F);
|
||||
LeftInnerPanel.setTextureSize(64, 32);
|
||||
LeftInnerPanel.mirror = true;
|
||||
setRotation(LeftInnerPanel, 0F, 0F, 0F);
|
||||
Podium = new ModelRenderer(this, 23, 65);
|
||||
Podium.addBox(0F, 0F, 0F, 1, 9, 1);
|
||||
Podium.setRotationPoint(-0.5F, 12F, -0.5F);
|
||||
Podium.setTextureSize(64, 32);
|
||||
Podium.mirror = true;
|
||||
setRotation(Podium, 0F, 0F, 0F);
|
||||
BottomBase = new ModelRenderer(this, 0, 36);
|
||||
BottomBase.addBox(0F, 0F, 0F, 8, 1, 8);
|
||||
BottomBase.setRotationPoint(-4F, 23F, -4F);
|
||||
BottomBase.setTextureSize(64, 32);
|
||||
BottomBase.mirror = true;
|
||||
setRotation(BottomBase, 0F, 0F, 0F);
|
||||
PodiumBase = new ModelRenderer(this, 0, 89);
|
||||
PodiumBase.addBox(0F, 0F, 0F, 4, 2, 4);
|
||||
PodiumBase.setRotationPoint(-2F, 21F, -2F);
|
||||
PodiumBase.setTextureSize(64, 32);
|
||||
PodiumBase.mirror = true;
|
||||
setRotation(PodiumBase, 0F, 0F, 0F);
|
||||
TapNode1 = new ModelRenderer(this, 23, 76);
|
||||
TapNode1.addBox(0F, 0F, 0F, 1, 2, 1);
|
||||
TapNode1.setRotationPoint(-0.5F, 15F, 3F);
|
||||
TapNode1.setTextureSize(64, 32);
|
||||
TapNode1.mirror = true;
|
||||
setRotation(TapNode1, 0F, 0F, 0F);
|
||||
TapNode2 = new ModelRenderer(this, 23, 76);
|
||||
TapNode2.addBox(0F, 0F, 0F, 1, 2, 1);
|
||||
TapNode2.setRotationPoint(3F, 15F, -0.5F);
|
||||
TapNode2.setTextureSize(64, 32);
|
||||
TapNode2.mirror = true;
|
||||
setRotation(TapNode2, 0F, 0F, 0F);
|
||||
TapNode3 = new ModelRenderer(this, 23, 76);
|
||||
TapNode3.addBox(0F, 0F, 0F, 1, 2, 1);
|
||||
TapNode3.setRotationPoint(-0.5F, 15F, -4F);
|
||||
TapNode3.setTextureSize(64, 32);
|
||||
TapNode3.mirror = true;
|
||||
setRotation(TapNode3, 0F, 0F, 0F);
|
||||
TapNode4 = new ModelRenderer(this, 23, 76);
|
||||
TapNode4.addBox(0F, 0F, 0F, 1, 2, 1);
|
||||
TapNode4.setRotationPoint(-4F, 15F, -0.5F);
|
||||
TapNode4.setTextureSize(64, 32);
|
||||
TapNode4.mirror = true;
|
||||
setRotation(TapNode4, 0F, 0F, 0F);
|
||||
ElectricalConduit = new ModelRenderer(this, 17, 89);
|
||||
ElectricalConduit.addBox(0F, 0F, 0F, 3, 3, 3);
|
||||
ElectricalConduit.setRotationPoint(-1.5F, 11F, -1.5F);
|
||||
ElectricalConduit.setTextureSize(64, 32);
|
||||
ElectricalConduit.mirror = true;
|
||||
setRotation(ElectricalConduit, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float f5)
|
||||
{
|
||||
BackInnerPanel.render(f5);
|
||||
Slide1.render(f5);
|
||||
Slide2.render(f5);
|
||||
Slide3.render(f5);
|
||||
Slide4.render(f5);
|
||||
Slide5.render(f5);
|
||||
Slide6.render(f5);
|
||||
Slide7.render(f5);
|
||||
Slide8.render(f5);
|
||||
Slide9.render(f5);
|
||||
Slide10.render(f5);
|
||||
Slide11.render(f5);
|
||||
Slide12.render(f5);
|
||||
Slide13.render(f5);
|
||||
Slide14.render(f5);
|
||||
Slide15.render(f5);
|
||||
Slide16.render(f5);
|
||||
Slide17.render(f5);
|
||||
Slide18.render(f5);
|
||||
Slide19.render(f5);
|
||||
Slide20.render(f5);
|
||||
Slide21.render(f5);
|
||||
Slide22.render(f5);
|
||||
Slide23.render(f5);
|
||||
Slide24.render(f5);
|
||||
Slide25.render(f5);
|
||||
Slide26.render(f5);
|
||||
Slide27.render(f5);
|
||||
Slide28.render(f5);
|
||||
FrontInnerPanel.render(f5);
|
||||
RightInnerPanel.render(f5);
|
||||
LeftInnerPanel.render(f5);
|
||||
Podium.render(f5);
|
||||
BottomBase.render(f5);
|
||||
PodiumBase.render(f5);
|
||||
TapNode1.render(f5);
|
||||
TapNode2.render(f5);
|
||||
TapNode3.render(f5);
|
||||
TapNode4.render(f5);
|
||||
ElectricalConduit.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,246 +0,0 @@
|
|||
package mekanism.induction.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelEMContractor extends ModelBase
|
||||
{
|
||||
public boolean doSpin;
|
||||
|
||||
// fields
|
||||
ModelRenderer frame1;
|
||||
ModelRenderer frame2;
|
||||
ModelRenderer frame3;
|
||||
ModelRenderer frame4;
|
||||
ModelRenderer frame5;
|
||||
ModelRenderer frame6;
|
||||
ModelRenderer frame7;
|
||||
ModelRenderer frame8;
|
||||
ModelRenderer left_frame_connector;
|
||||
ModelRenderer right_frame_connector;
|
||||
ModelRenderer teslapole;
|
||||
ModelRenderer Coil1;
|
||||
ModelRenderer coil2;
|
||||
ModelRenderer coil3;
|
||||
ModelRenderer coil4;
|
||||
ModelRenderer pole1;
|
||||
ModelRenderer pole2;
|
||||
ModelRenderer pole3;
|
||||
ModelRenderer pole4;
|
||||
ModelRenderer poletop1;
|
||||
ModelRenderer poletop2;
|
||||
ModelRenderer poletop3;
|
||||
ModelRenderer poletop4;
|
||||
ModelRenderer base1;
|
||||
ModelRenderer base2;
|
||||
ModelRenderer base3;
|
||||
|
||||
public ModelEMContractor(boolean spin)
|
||||
{
|
||||
doSpin = spin;
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
frame1 = new ModelRenderer(this, 0, 24);
|
||||
frame1.addBox(0F, 0F, 0F, 1, 8, 1);
|
||||
frame1.setRotationPoint(-3F, 15F, -2F);
|
||||
frame1.setTextureSize(128, 128);
|
||||
frame1.mirror = true;
|
||||
setRotation(frame1, 0F, 0F, 0F);
|
||||
frame2 = new ModelRenderer(this, 0, 24);
|
||||
frame2.addBox(0F, 0F, 0F, 1, 8, 1);
|
||||
frame2.setRotationPoint(1F, 15F, 2F);
|
||||
frame2.setTextureSize(128, 128);
|
||||
frame2.mirror = true;
|
||||
setRotation(frame2, 0F, 0F, 0F);
|
||||
frame3 = new ModelRenderer(this, 0, 24);
|
||||
frame3.addBox(0F, 0F, 0F, 1, 8, 1);
|
||||
frame3.setRotationPoint(2F, 15F, -2F);
|
||||
frame3.setTextureSize(128, 128);
|
||||
frame3.mirror = true;
|
||||
setRotation(frame3, 0F, 0F, 0F);
|
||||
frame4 = new ModelRenderer(this, 0, 24);
|
||||
frame4.addBox(0F, 0F, 0F, 1, 8, 1);
|
||||
frame4.setRotationPoint(-3F, 15F, 1F);
|
||||
frame4.setTextureSize(128, 128);
|
||||
frame4.mirror = true;
|
||||
setRotation(frame4, 0F, 0F, 0F);
|
||||
frame5 = new ModelRenderer(this, 0, 24);
|
||||
frame5.addBox(0F, 0F, 0F, 1, 8, 1);
|
||||
frame5.setRotationPoint(2F, 15F, 1F);
|
||||
frame5.setTextureSize(128, 128);
|
||||
frame5.mirror = true;
|
||||
setRotation(frame5, 0F, 0F, 0F);
|
||||
frame6 = new ModelRenderer(this, 0, 24);
|
||||
frame6.addBox(0F, 0F, 0F, 1, 8, 1);
|
||||
frame6.setRotationPoint(1F, 15F, -3F);
|
||||
frame6.setTextureSize(128, 128);
|
||||
frame6.mirror = true;
|
||||
setRotation(frame6, 0F, 0F, 0F);
|
||||
frame7 = new ModelRenderer(this, 0, 24);
|
||||
frame7.addBox(0F, 0F, 0F, 1, 8, 1);
|
||||
frame7.setRotationPoint(-2F, 15F, 2F);
|
||||
frame7.setTextureSize(128, 128);
|
||||
frame7.mirror = true;
|
||||
setRotation(frame7, 0F, 0F, 0F);
|
||||
frame8 = new ModelRenderer(this, 0, 24);
|
||||
frame8.addBox(0F, 0F, 0F, 1, 8, 1);
|
||||
frame8.setRotationPoint(-2F, 15F, -3F);
|
||||
frame8.setTextureSize(128, 128);
|
||||
frame8.mirror = true;
|
||||
setRotation(frame8, 0F, 0F, 0F);
|
||||
left_frame_connector = new ModelRenderer(this, 0, 20);
|
||||
left_frame_connector.addBox(0F, 0F, 0F, 1, 1, 2);
|
||||
left_frame_connector.setRotationPoint(-3F, 15F, -1F);
|
||||
left_frame_connector.setTextureSize(128, 128);
|
||||
left_frame_connector.mirror = true;
|
||||
setRotation(left_frame_connector, 0F, 0F, 0F);
|
||||
right_frame_connector = new ModelRenderer(this, 0, 20);
|
||||
right_frame_connector.addBox(0F, 0F, 0F, 1, 1, 2);
|
||||
right_frame_connector.setRotationPoint(2F, 15F, -1F);
|
||||
right_frame_connector.setTextureSize(128, 128);
|
||||
right_frame_connector.mirror = true;
|
||||
setRotation(right_frame_connector, 0F, 0F, 0F);
|
||||
teslapole = new ModelRenderer(this, 0, 0);
|
||||
teslapole.addBox(-1F, -1F, -1F, 2, 15, 2);
|
||||
teslapole.setRotationPoint(0F, 9F, 0F);
|
||||
teslapole.setTextureSize(128, 128);
|
||||
teslapole.mirror = true;
|
||||
setRotation(teslapole, 0F, 0F, 0F);
|
||||
Coil1 = new ModelRenderer(this, 17, 0);
|
||||
Coil1.addBox(-1.5F, -0.5F, -1.5F, 3, 1, 3);
|
||||
Coil1.setRotationPoint(0F, 12.5F, 0F);
|
||||
Coil1.setTextureSize(128, 128);
|
||||
Coil1.mirror = true;
|
||||
setRotation(Coil1, 0F, 0F, 0F);
|
||||
coil2 = new ModelRenderer(this, 17, 0);
|
||||
coil2.addBox(-1.5F, -0.5F, -1.5F, 3, 1, 3);
|
||||
coil2.setRotationPoint(0F, 14F, 0F);
|
||||
coil2.setTextureSize(128, 128);
|
||||
coil2.mirror = true;
|
||||
setRotation(coil2, 0F, 0F, 0F);
|
||||
coil3 = new ModelRenderer(this, 17, 0);
|
||||
coil3.addBox(-1.5F, -0.5F, -1.5F, 3, 1, 3);
|
||||
coil3.setRotationPoint(0F, 9.5F, 0F);
|
||||
coil3.setTextureSize(128, 128);
|
||||
coil3.mirror = true;
|
||||
setRotation(coil3, 0F, 0F, 0F);
|
||||
coil4 = new ModelRenderer(this, 17, 0);
|
||||
coil4.addBox(-1.5F, -0.5F, -1.5F, 3, 1, 3);
|
||||
coil4.setRotationPoint(0F, 11F, 0F);
|
||||
coil4.setTextureSize(128, 128);
|
||||
coil4.mirror = true;
|
||||
setRotation(coil4, 0F, 0F, 0F);
|
||||
pole1 = new ModelRenderer(this, 5, 26);
|
||||
pole1.addBox(-0.5F, -1F, -0.5F, 1, 6, 1);
|
||||
pole1.setRotationPoint(0F, 18F, 6.5F);
|
||||
pole1.setTextureSize(128, 128);
|
||||
pole1.mirror = true;
|
||||
setRotation(pole1, 0F, 0F, 0F);
|
||||
pole2 = new ModelRenderer(this, 5, 26);
|
||||
pole2.addBox(-0.5F, -1F, -0.5F, 1, 6, 1);
|
||||
pole2.setRotationPoint(0F, 18F, -6.5F);
|
||||
pole2.setTextureSize(128, 128);
|
||||
pole2.mirror = true;
|
||||
setRotation(pole2, 0F, 0F, 0F);
|
||||
pole3 = new ModelRenderer(this, 5, 26);
|
||||
pole3.addBox(-0.5F, -1F, -0.5F, 1, 6, 1);
|
||||
pole3.setRotationPoint(-6.5F, 18F, 0F);
|
||||
pole3.setTextureSize(128, 128);
|
||||
pole3.mirror = true;
|
||||
setRotation(pole3, 0F, 0F, 0F);
|
||||
pole4 = new ModelRenderer(this, 5, 26);
|
||||
pole4.addBox(-0.5F, -1F, -0.5F, 1, 6, 1);
|
||||
pole4.setRotationPoint(6.5F, 18F, 0F);
|
||||
pole4.setTextureSize(128, 128);
|
||||
pole4.mirror = true;
|
||||
setRotation(pole4, 0F, 0F, 0F);
|
||||
poletop1 = new ModelRenderer(this, 31, 0);
|
||||
poletop1.addBox(-1F, -1F, -1F, 2, 2, 2);
|
||||
poletop1.setRotationPoint(0F, 16.5F, -6.5F);
|
||||
poletop1.setTextureSize(128, 128);
|
||||
poletop1.mirror = true;
|
||||
setRotation(poletop1, 0F, 0F, 0F);
|
||||
poletop2 = new ModelRenderer(this, 31, 0);
|
||||
poletop2.addBox(-1F, -1F, -1F, 2, 2, 2);
|
||||
poletop2.setRotationPoint(0F, 16.5F, 6.5F);
|
||||
poletop2.setTextureSize(128, 128);
|
||||
poletop2.mirror = true;
|
||||
setRotation(poletop2, 0F, 0F, 0F);
|
||||
poletop3 = new ModelRenderer(this, 31, 0);
|
||||
poletop3.addBox(-1F, -1F, -1F, 2, 2, 2);
|
||||
poletop3.setRotationPoint(6.5F, 16.5F, 0F);
|
||||
poletop3.setTextureSize(128, 128);
|
||||
poletop3.mirror = true;
|
||||
setRotation(poletop3, 0F, 0F, 0F);
|
||||
poletop4 = new ModelRenderer(this, 31, 0);
|
||||
poletop4.addBox(-1F, -1F, -1F, 2, 2, 2);
|
||||
poletop4.setRotationPoint(-6.5F, 16.5F, 0F);
|
||||
poletop4.setTextureSize(128, 128);
|
||||
poletop4.mirror = true;
|
||||
setRotation(poletop4, 0F, 0F, 0F);
|
||||
base1 = new ModelRenderer(this, 0, 55);
|
||||
base1.addBox(0F, 0F, 0F, 16, 1, 8);
|
||||
base1.setRotationPoint(-8F, 23F, -4F);
|
||||
base1.setTextureSize(128, 128);
|
||||
base1.mirror = true;
|
||||
setRotation(base1, 0F, 0F, 0F);
|
||||
base2 = new ModelRenderer(this, 0, 68);
|
||||
base2.addBox(0F, 0F, 0F, 8, 1, 5);
|
||||
base2.setRotationPoint(-4F, 23F, 3F);
|
||||
base2.setTextureSize(128, 128);
|
||||
base2.mirror = true;
|
||||
setRotation(base2, 0F, 0F, 0F);
|
||||
base3 = new ModelRenderer(this, 0, 79);
|
||||
base3.addBox(0F, 0F, 0F, 8, 1, 5);
|
||||
base3.setRotationPoint(-4F, 23F, -8F);
|
||||
base3.setTextureSize(128, 128);
|
||||
base3.mirror = true;
|
||||
setRotation(base3, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float f5)
|
||||
{
|
||||
if (doSpin)
|
||||
{
|
||||
Coil1.rotateAngleY = (float) Math.toRadians(Math.toDegrees(Coil1.rotateAngleY) + 3 < 360 ? Math.toDegrees(Coil1.rotateAngleY) + 3 : 0);
|
||||
coil2.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil2.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil2.rotateAngleY) + 3 : 0);
|
||||
coil3.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil3.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil3.rotateAngleY) + 3 : 0);
|
||||
coil4.rotateAngleY = (float) Math.toRadians(Math.toDegrees(coil4.rotateAngleY) + 3 < 360 ? Math.toDegrees(coil4.rotateAngleY) + 3 : 0);
|
||||
}
|
||||
|
||||
frame1.render(f5);
|
||||
frame2.render(f5);
|
||||
frame3.render(f5);
|
||||
frame4.render(f5);
|
||||
frame5.render(f5);
|
||||
frame6.render(f5);
|
||||
frame7.render(f5);
|
||||
frame8.render(f5);
|
||||
left_frame_connector.render(f5);
|
||||
right_frame_connector.render(f5);
|
||||
teslapole.render(f5);
|
||||
Coil1.render(f5);
|
||||
coil2.render(f5);
|
||||
coil3.render(f5);
|
||||
coil4.render(f5);
|
||||
pole1.render(f5);
|
||||
pole2.render(f5);
|
||||
pole3.render(f5);
|
||||
pole4.render(f5);
|
||||
poletop1.render(f5);
|
||||
poletop2.render(f5);
|
||||
poletop3.render(f5);
|
||||
poletop4.render(f5);
|
||||
base1.render(f5);
|
||||
base2.render(f5);
|
||||
base3.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
package mekanism.induction.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelTeslaBottom extends ModelBase
|
||||
{
|
||||
// fields
|
||||
ModelRenderer Base;
|
||||
ModelRenderer BackBottomSide;
|
||||
ModelRenderer FrontBottomSide;
|
||||
ModelRenderer SlantedFrontPanel;
|
||||
ModelRenderer SlantedPanelBase;
|
||||
ModelRenderer TopBase;
|
||||
ModelRenderer FrontTopPole;
|
||||
ModelRenderer SideTopPole;
|
||||
ModelRenderer LeftAntennae;
|
||||
ModelRenderer RightAntennae;
|
||||
ModelRenderer BackAntennae;
|
||||
ModelRenderer FrontAntennae;
|
||||
ModelRenderer TopBasePanel;
|
||||
ModelRenderer ChargePack;
|
||||
ModelRenderer WireLeftBottomPole;
|
||||
ModelRenderer WireLeftTopPole;
|
||||
ModelRenderer WireRightBottomPole;
|
||||
ModelRenderer WireRightTopPole;
|
||||
ModelRenderer BackRightConnector;
|
||||
ModelRenderer BackLeftConnector;
|
||||
ModelRenderer FrontLeftConnector;
|
||||
ModelRenderer FrontRightConnector;
|
||||
|
||||
public ModelTeslaBottom()
|
||||
{
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
Base = new ModelRenderer(this, 0, 0);
|
||||
Base.addBox(0F, 0F, 0F, 9, 10, 9);
|
||||
Base.setRotationPoint(-4.5F, 14F, -4.5F);
|
||||
Base.setTextureSize(128, 128);
|
||||
Base.mirror = true;
|
||||
setRotation(Base, 0F, 0F, 0F);
|
||||
BackBottomSide = new ModelRenderer(this, 38, 0);
|
||||
BackBottomSide.addBox(0F, 0F, 0F, 11, 7, 2);
|
||||
BackBottomSide.setRotationPoint(-5.5F, 17F, 1F);
|
||||
BackBottomSide.setTextureSize(128, 128);
|
||||
BackBottomSide.mirror = true;
|
||||
setRotation(BackBottomSide, 0F, 0F, 0F);
|
||||
FrontBottomSide = new ModelRenderer(this, 38, 0);
|
||||
FrontBottomSide.addBox(0F, 0F, 0F, 11, 7, 2);
|
||||
FrontBottomSide.setRotationPoint(-5.5F, 17F, -3F);
|
||||
FrontBottomSide.setTextureSize(128, 128);
|
||||
FrontBottomSide.mirror = true;
|
||||
setRotation(FrontBottomSide, 0F, 0F, 0F);
|
||||
SlantedFrontPanel = new ModelRenderer(this, 38, 10);
|
||||
SlantedFrontPanel.addBox(0F, 0F, 0F, 4, 6, 2);
|
||||
SlantedFrontPanel.setRotationPoint(-2F, 17F, -4F);
|
||||
SlantedFrontPanel.setTextureSize(128, 128);
|
||||
SlantedFrontPanel.mirror = true;
|
||||
setRotation(SlantedFrontPanel, -0.4234231F, 0F, 0F);
|
||||
SlantedPanelBase = new ModelRenderer(this, 51, 10);
|
||||
SlantedPanelBase.addBox(0F, 0F, 0F, 6, 3, 2);
|
||||
SlantedPanelBase.setRotationPoint(-3F, 21F, -6.5F);
|
||||
SlantedPanelBase.setTextureSize(128, 128);
|
||||
SlantedPanelBase.mirror = true;
|
||||
setRotation(SlantedPanelBase, 0F, 0F, 0F);
|
||||
TopBase = new ModelRenderer(this, 0, 20);
|
||||
TopBase.addBox(0F, 0F, 0F, 6, 5, 6);
|
||||
TopBase.setRotationPoint(-3F, 9F, -3F);
|
||||
TopBase.setTextureSize(128, 128);
|
||||
TopBase.mirror = true;
|
||||
setRotation(TopBase, 0F, 0F, 0F);
|
||||
FrontTopPole = new ModelRenderer(this, 0, 32);
|
||||
FrontTopPole.addBox(0F, 0F, 0F, 2, 2, 8);
|
||||
FrontTopPole.setRotationPoint(-1F, 10F, -4F);
|
||||
FrontTopPole.setTextureSize(128, 128);
|
||||
FrontTopPole.mirror = true;
|
||||
setRotation(FrontTopPole, 0F, 0F, 0F);
|
||||
SideTopPole = new ModelRenderer(this, 0, 43);
|
||||
SideTopPole.addBox(0F, 0F, 0F, 8, 2, 2);
|
||||
SideTopPole.setRotationPoint(-4F, 10F, -1F);
|
||||
SideTopPole.setTextureSize(128, 128);
|
||||
SideTopPole.mirror = true;
|
||||
setRotation(SideTopPole, 0F, 0F, 0F);
|
||||
LeftAntennae = new ModelRenderer(this, 25, 20);
|
||||
LeftAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
|
||||
LeftAntennae.setRotationPoint(-4.5F, 8.8F, -0.5F);
|
||||
LeftAntennae.setTextureSize(128, 128);
|
||||
LeftAntennae.mirror = true;
|
||||
setRotation(LeftAntennae, 0F, 0F, 0F);
|
||||
RightAntennae = new ModelRenderer(this, 30, 20);
|
||||
RightAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
|
||||
RightAntennae.setRotationPoint(3.5F, 8.8F, -0.5F);
|
||||
RightAntennae.setTextureSize(128, 128);
|
||||
RightAntennae.mirror = true;
|
||||
setRotation(RightAntennae, 0F, 0F, 0F);
|
||||
BackAntennae = new ModelRenderer(this, 25, 25);
|
||||
BackAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
|
||||
BackAntennae.setRotationPoint(-0.5F, 8.8F, 3.5F);
|
||||
BackAntennae.setTextureSize(128, 128);
|
||||
BackAntennae.mirror = true;
|
||||
setRotation(BackAntennae, 0F, 0F, 0F);
|
||||
FrontAntennae = new ModelRenderer(this, 30, 25);
|
||||
FrontAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
|
||||
FrontAntennae.setRotationPoint(-0.5F, 8.8F, -4.5F);
|
||||
FrontAntennae.setTextureSize(128, 128);
|
||||
FrontAntennae.mirror = true;
|
||||
setRotation(FrontAntennae, 0F, 0F, 0F);
|
||||
TopBasePanel = new ModelRenderer(this, 36, 20);
|
||||
TopBasePanel.addBox(0F, 0F, 0F, 7, 1, 7);
|
||||
TopBasePanel.setRotationPoint(-3.5F, 13F, -3.5F);
|
||||
TopBasePanel.setTextureSize(128, 128);
|
||||
TopBasePanel.mirror = true;
|
||||
setRotation(TopBasePanel, 0F, 0F, 0F);
|
||||
ChargePack = new ModelRenderer(this, 37, 29);
|
||||
ChargePack.addBox(0F, 0F, 0F, 6, 7, 3);
|
||||
ChargePack.setRotationPoint(-3F, 17F, 3.5F);
|
||||
ChargePack.setTextureSize(128, 128);
|
||||
ChargePack.mirror = true;
|
||||
setRotation(ChargePack, 0F, 0F, 0F);
|
||||
WireLeftBottomPole = new ModelRenderer(this, 21, 32);
|
||||
WireLeftBottomPole.addBox(0F, 0F, 0F, 1, 10, 1);
|
||||
WireLeftBottomPole.setRotationPoint(-2F, 11.86667F, 6F);
|
||||
WireLeftBottomPole.setTextureSize(128, 128);
|
||||
WireLeftBottomPole.mirror = true;
|
||||
setRotation(WireLeftBottomPole, 0F, 0F, 0F);
|
||||
WireLeftTopPole = new ModelRenderer(this, 26, 32);
|
||||
WireLeftTopPole.addBox(0F, 0F, 0F, 1, 1, 4);
|
||||
WireLeftTopPole.setRotationPoint(-2F, 10.86667F, 3F);
|
||||
WireLeftTopPole.setTextureSize(128, 128);
|
||||
WireLeftTopPole.mirror = true;
|
||||
setRotation(WireLeftTopPole, 0F, 0F, 0F);
|
||||
WireRightBottomPole = new ModelRenderer(this, 21, 32);
|
||||
WireRightBottomPole.addBox(0F, 0F, 0F, 1, 10, 1);
|
||||
WireRightBottomPole.setRotationPoint(1F, 11.86667F, 6F);
|
||||
WireRightBottomPole.setTextureSize(128, 128);
|
||||
WireRightBottomPole.mirror = true;
|
||||
setRotation(WireRightBottomPole, 0F, 0F, 0F);
|
||||
WireRightTopPole = new ModelRenderer(this, 26, 38);
|
||||
WireRightTopPole.addBox(0F, 0F, 0F, 1, 1, 4);
|
||||
WireRightTopPole.setRotationPoint(1F, 10.86667F, 3F);
|
||||
WireRightTopPole.setTextureSize(128, 128);
|
||||
WireRightTopPole.mirror = true;
|
||||
setRotation(WireRightTopPole, 0F, 0F, 0F);
|
||||
BackRightConnector = new ModelRenderer(this, 65, 0);
|
||||
BackRightConnector.addBox(0F, 0F, 0F, 1, 1, 1);
|
||||
BackRightConnector.setRotationPoint(1F, 8F, 1.066667F);
|
||||
BackRightConnector.setTextureSize(128, 128);
|
||||
BackRightConnector.mirror = true;
|
||||
setRotation(BackRightConnector, 0F, 0F, 0F);
|
||||
BackLeftConnector = new ModelRenderer(this, 65, 0);
|
||||
BackLeftConnector.addBox(0F, 0F, 0F, 1, 1, 1);
|
||||
BackLeftConnector.setRotationPoint(-2F, 8F, 1F);
|
||||
BackLeftConnector.setTextureSize(128, 128);
|
||||
BackLeftConnector.mirror = true;
|
||||
setRotation(BackLeftConnector, 0F, 0F, 0F);
|
||||
FrontLeftConnector = new ModelRenderer(this, 65, 0);
|
||||
FrontLeftConnector.addBox(0F, 0F, 0F, 1, 1, 1);
|
||||
FrontLeftConnector.setRotationPoint(-2F, 8F, -2F);
|
||||
FrontLeftConnector.setTextureSize(128, 128);
|
||||
FrontLeftConnector.mirror = true;
|
||||
setRotation(FrontLeftConnector, 0F, 0F, 0F);
|
||||
FrontRightConnector = new ModelRenderer(this, 65, 0);
|
||||
FrontRightConnector.addBox(0F, 0F, 0F, 1, 1, 1);
|
||||
FrontRightConnector.setRotationPoint(1F, 8F, -2F);
|
||||
FrontRightConnector.setTextureSize(128, 128);
|
||||
FrontRightConnector.mirror = true;
|
||||
setRotation(FrontRightConnector, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float f5)
|
||||
{
|
||||
Base.render(f5);
|
||||
BackBottomSide.render(f5);
|
||||
FrontBottomSide.render(f5);
|
||||
SlantedFrontPanel.render(f5);
|
||||
SlantedPanelBase.render(f5);
|
||||
TopBase.render(f5);
|
||||
FrontTopPole.render(f5);
|
||||
SideTopPole.render(f5);
|
||||
LeftAntennae.render(f5);
|
||||
RightAntennae.render(f5);
|
||||
BackAntennae.render(f5);
|
||||
FrontAntennae.render(f5);
|
||||
TopBasePanel.render(f5);
|
||||
ChargePack.render(f5);
|
||||
WireLeftBottomPole.render(f5);
|
||||
WireLeftTopPole.render(f5);
|
||||
WireRightBottomPole.render(f5);
|
||||
WireRightTopPole.render(f5);
|
||||
BackRightConnector.render(f5);
|
||||
BackLeftConnector.render(f5);
|
||||
FrontLeftConnector.render(f5);
|
||||
FrontRightConnector.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
package mekanism.induction.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelTeslaMiddle extends ModelBase
|
||||
{
|
||||
// fields
|
||||
ModelRenderer Base;
|
||||
ModelRenderer Collumn1;
|
||||
ModelRenderer Collumn2;
|
||||
ModelRenderer CrossCollumn1;
|
||||
ModelRenderer Collumn3;
|
||||
ModelRenderer Ball;
|
||||
ModelRenderer Plate;
|
||||
ModelRenderer TopBase;
|
||||
ModelRenderer FrontPole;
|
||||
ModelRenderer SidePole;
|
||||
ModelRenderer FrontAntennae;
|
||||
ModelRenderer BackAntennae;
|
||||
ModelRenderer LeftAntennae;
|
||||
ModelRenderer RightAntennae;
|
||||
ModelRenderer CrossCollumn2;
|
||||
ModelRenderer CrossCollumn3;
|
||||
ModelRenderer Collumn4;
|
||||
ModelRenderer CrossCollumn4;
|
||||
ModelRenderer BallStand;
|
||||
ModelRenderer FrontTopLeftPole;
|
||||
ModelRenderer FrontTopRightPole;
|
||||
ModelRenderer SideTopFirstPole;
|
||||
ModelRenderer SodeTopLastPole;
|
||||
|
||||
public ModelTeslaMiddle()
|
||||
{
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
Base = new ModelRenderer(this, 0, 0);
|
||||
Base.addBox(0F, 0F, 0F, 6, 6, 6);
|
||||
Base.setRotationPoint(-3F, 18F, -3F);
|
||||
Base.setTextureSize(128, 128);
|
||||
Base.mirror = true;
|
||||
setRotation(Base, 0F, 0F, 0F);
|
||||
Collumn1 = new ModelRenderer(this, 0, 20);
|
||||
Collumn1.addBox(0F, 0F, 0F, 1, 4, 1);
|
||||
Collumn1.setRotationPoint(-3F, 14F, -3F);
|
||||
Collumn1.setTextureSize(128, 128);
|
||||
Collumn1.mirror = true;
|
||||
setRotation(Collumn1, 0F, 0F, 0F);
|
||||
Collumn2 = new ModelRenderer(this, 0, 20);
|
||||
Collumn2.addBox(0F, 0F, 0F, 1, 4, 1);
|
||||
Collumn2.setRotationPoint(2F, 14F, -3F);
|
||||
Collumn2.setTextureSize(128, 128);
|
||||
Collumn2.mirror = true;
|
||||
setRotation(Collumn2, 0F, 0F, 0F);
|
||||
CrossCollumn1 = new ModelRenderer(this, 5, 20);
|
||||
CrossCollumn1.addBox(0F, 0F, 0F, 4, 1, 1);
|
||||
CrossCollumn1.setRotationPoint(-2F, 15.5F, -3F);
|
||||
CrossCollumn1.setTextureSize(128, 128);
|
||||
CrossCollumn1.mirror = true;
|
||||
setRotation(CrossCollumn1, 0F, 0F, 0F);
|
||||
Collumn3 = new ModelRenderer(this, 0, 20);
|
||||
Collumn3.addBox(0F, 0F, 0F, 1, 4, 1);
|
||||
Collumn3.setRotationPoint(2F, 14F, 2F);
|
||||
Collumn3.setTextureSize(128, 128);
|
||||
Collumn3.mirror = true;
|
||||
setRotation(Collumn3, 0F, 0F, 0F);
|
||||
Ball = new ModelRenderer(this, 0, 15);
|
||||
Ball.addBox(-1F, -1F, -1F, 2, 2, 2);
|
||||
Ball.setRotationPoint(0F, 16F, 0F);
|
||||
Ball.setTextureSize(128, 128);
|
||||
Ball.mirror = true;
|
||||
setRotation(Ball, 0F, 0F, 0F);
|
||||
Plate = new ModelRenderer(this, 25, 0);
|
||||
Plate.addBox(0F, 0F, 0F, 7, 1, 7);
|
||||
Plate.setRotationPoint(-3.5F, 13F, -3.5F);
|
||||
Plate.setTextureSize(128, 128);
|
||||
Plate.mirror = true;
|
||||
setRotation(Plate, 0F, 0F, 0F);
|
||||
TopBase = new ModelRenderer(this, 25, 9);
|
||||
TopBase.addBox(0F, 0F, 0F, 4, 5, 4);
|
||||
TopBase.setRotationPoint(-2F, 8F, -2F);
|
||||
TopBase.setTextureSize(128, 128);
|
||||
TopBase.mirror = true;
|
||||
setRotation(TopBase, 0F, 0F, 0F);
|
||||
FrontPole = new ModelRenderer(this, 0, 26);
|
||||
FrontPole.addBox(0F, 0F, 0F, 2, 2, 8);
|
||||
FrontPole.setRotationPoint(-1F, 20F, -4F);
|
||||
FrontPole.setTextureSize(128, 128);
|
||||
FrontPole.mirror = true;
|
||||
setRotation(FrontPole, 0F, 0F, 0F);
|
||||
SidePole = new ModelRenderer(this, 0, 37);
|
||||
SidePole.addBox(0F, 0F, 0F, 8, 2, 2);
|
||||
SidePole.setRotationPoint(-4F, 20F, -1F);
|
||||
SidePole.setTextureSize(128, 128);
|
||||
SidePole.mirror = true;
|
||||
setRotation(SidePole, 0F, 0F, 0F);
|
||||
FrontAntennae = new ModelRenderer(this, 25, 19);
|
||||
FrontAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
|
||||
FrontAntennae.setRotationPoint(-0.5F, 18.8F, -4.466667F);
|
||||
FrontAntennae.setTextureSize(128, 128);
|
||||
FrontAntennae.mirror = true;
|
||||
setRotation(FrontAntennae, 0F, 0F, 0F);
|
||||
BackAntennae = new ModelRenderer(this, 25, 19);
|
||||
BackAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
|
||||
BackAntennae.setRotationPoint(-0.5F, 18.8F, 3.533333F);
|
||||
BackAntennae.setTextureSize(128, 128);
|
||||
BackAntennae.mirror = true;
|
||||
setRotation(BackAntennae, 0F, 0F, 0F);
|
||||
LeftAntennae = new ModelRenderer(this, 25, 19);
|
||||
LeftAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
|
||||
LeftAntennae.setRotationPoint(-4.5F, 18.8F, -0.5F);
|
||||
LeftAntennae.setTextureSize(128, 128);
|
||||
LeftAntennae.mirror = true;
|
||||
setRotation(LeftAntennae, 0F, 0F, 0F);
|
||||
RightAntennae = new ModelRenderer(this, 25, 19);
|
||||
RightAntennae.addBox(0F, 0F, 0F, 1, 3, 1);
|
||||
RightAntennae.setRotationPoint(3.5F, 18.8F, -0.5F);
|
||||
RightAntennae.setTextureSize(128, 128);
|
||||
RightAntennae.mirror = true;
|
||||
setRotation(RightAntennae, 0F, 0F, 0F);
|
||||
CrossCollumn2 = new ModelRenderer(this, 30, 19);
|
||||
CrossCollumn2.addBox(0F, 0F, 0F, 1, 1, 4);
|
||||
CrossCollumn2.setRotationPoint(2F, 15.5F, -2F);
|
||||
CrossCollumn2.setTextureSize(128, 128);
|
||||
CrossCollumn2.mirror = true;
|
||||
setRotation(CrossCollumn2, 0F, 0F, 0F);
|
||||
CrossCollumn3 = new ModelRenderer(this, 5, 20);
|
||||
CrossCollumn3.addBox(0F, 0F, 0F, 4, 1, 1);
|
||||
CrossCollumn3.setRotationPoint(-2F, 15.5F, 2F);
|
||||
CrossCollumn3.setTextureSize(128, 128);
|
||||
CrossCollumn3.mirror = true;
|
||||
setRotation(CrossCollumn3, 0F, 0F, 0F);
|
||||
Collumn4 = new ModelRenderer(this, 0, 20);
|
||||
Collumn4.addBox(0F, 0F, 0F, 1, 4, 1);
|
||||
Collumn4.setRotationPoint(-3F, 14F, 2F);
|
||||
Collumn4.setTextureSize(128, 128);
|
||||
Collumn4.mirror = true;
|
||||
setRotation(Collumn4, 0F, 0F, 0F);
|
||||
CrossCollumn4 = new ModelRenderer(this, 30, 19);
|
||||
CrossCollumn4.addBox(0F, 0F, 0F, 1, 1, 4);
|
||||
CrossCollumn4.setRotationPoint(-3F, 15.5F, -2F);
|
||||
CrossCollumn4.setTextureSize(128, 128);
|
||||
CrossCollumn4.mirror = true;
|
||||
setRotation(CrossCollumn4, 0F, 0F, 0F);
|
||||
BallStand = new ModelRenderer(this, 9, 16);
|
||||
BallStand.addBox(0F, 0F, 0F, 1, 1, 1);
|
||||
BallStand.setRotationPoint(-0.5F, 17F, -0.5F);
|
||||
BallStand.setTextureSize(128, 128);
|
||||
BallStand.mirror = true;
|
||||
setRotation(BallStand, 0F, 0F, 0F);
|
||||
FrontTopLeftPole = new ModelRenderer(this, 42, 9);
|
||||
FrontTopLeftPole.addBox(0F, 0F, 0F, 1, 4, 5);
|
||||
FrontTopLeftPole.setRotationPoint(-1.5F, 9F, -2.5F);
|
||||
FrontTopLeftPole.setTextureSize(128, 128);
|
||||
FrontTopLeftPole.mirror = true;
|
||||
setRotation(FrontTopLeftPole, 0F, 0F, 0F);
|
||||
FrontTopRightPole = new ModelRenderer(this, 42, 9);
|
||||
FrontTopRightPole.addBox(0F, 0F, 0F, 1, 4, 5);
|
||||
FrontTopRightPole.setRotationPoint(0.5F, 9F, -2.5F);
|
||||
FrontTopRightPole.setTextureSize(128, 128);
|
||||
FrontTopRightPole.mirror = true;
|
||||
setRotation(FrontTopRightPole, 0F, 0F, 0F);
|
||||
SideTopFirstPole = new ModelRenderer(this, 42, 19);
|
||||
SideTopFirstPole.addBox(0F, 0F, 0F, 5, 4, 1);
|
||||
SideTopFirstPole.setRotationPoint(-2.5F, 9F, -1.5F);
|
||||
SideTopFirstPole.setTextureSize(128, 128);
|
||||
SideTopFirstPole.mirror = true;
|
||||
setRotation(SideTopFirstPole, 0F, 0F, 0F);
|
||||
SodeTopLastPole = new ModelRenderer(this, 42, 19);
|
||||
SodeTopLastPole.addBox(0F, 0F, 0F, 5, 4, 1);
|
||||
SodeTopLastPole.setRotationPoint(-2.5F, 9F, 0.5F);
|
||||
SodeTopLastPole.setTextureSize(128, 128);
|
||||
SodeTopLastPole.mirror = true;
|
||||
setRotation(SodeTopLastPole, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float f5)
|
||||
{
|
||||
Base.render(f5);
|
||||
Collumn1.render(f5);
|
||||
Collumn2.render(f5);
|
||||
CrossCollumn1.render(f5);
|
||||
Collumn3.render(f5);
|
||||
Ball.render(f5);
|
||||
Plate.render(f5);
|
||||
TopBase.render(f5);
|
||||
FrontPole.render(f5);
|
||||
SidePole.render(f5);
|
||||
FrontAntennae.render(f5);
|
||||
BackAntennae.render(f5);
|
||||
LeftAntennae.render(f5);
|
||||
RightAntennae.render(f5);
|
||||
CrossCollumn2.render(f5);
|
||||
CrossCollumn3.render(f5);
|
||||
Collumn4.render(f5);
|
||||
CrossCollumn4.render(f5);
|
||||
BallStand.render(f5);
|
||||
FrontTopLeftPole.render(f5);
|
||||
FrontTopRightPole.render(f5);
|
||||
SideTopFirstPole.render(f5);
|
||||
SodeTopLastPole.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
package mekanism.induction.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelTeslaTop extends ModelBase
|
||||
{
|
||||
// fields
|
||||
ModelRenderer Base;
|
||||
ModelRenderer Collumn1;
|
||||
ModelRenderer Collumn2;
|
||||
ModelRenderer Collumn3;
|
||||
ModelRenderer Collumn4;
|
||||
ModelRenderer CrossCollumn1;
|
||||
ModelRenderer CrossCollumn2;
|
||||
ModelRenderer CrossCollumn3;
|
||||
ModelRenderer CrossCollumn4;
|
||||
ModelRenderer CrossCollumn5;
|
||||
ModelRenderer CrossCollumn6;
|
||||
ModelRenderer CrossCollumn7;
|
||||
ModelRenderer CrossCollumn8;
|
||||
ModelRenderer HolderLeft;
|
||||
ModelRenderer FrontCoil;
|
||||
ModelRenderer RightCoil;
|
||||
ModelRenderer BackCoil;
|
||||
ModelRenderer LeftCoil;
|
||||
ModelRenderer LFSCoil;
|
||||
ModelRenderer RFSCoil;
|
||||
ModelRenderer RBSCoil;
|
||||
ModelRenderer LBSCoil;
|
||||
|
||||
public ModelTeslaTop()
|
||||
{
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
Base = new ModelRenderer(this, 0, 0);
|
||||
Base.addBox(0F, 0F, 0F, 4, 4, 4);
|
||||
Base.setRotationPoint(-2F, 20F, -2F);
|
||||
Base.setTextureSize(128, 128);
|
||||
Base.mirror = true;
|
||||
setRotation(Base, 0F, 0F, 0F);
|
||||
Collumn1 = new ModelRenderer(this, 0, 9);
|
||||
Collumn1.addBox(0F, 0F, 0F, 1, 6, 1);
|
||||
Collumn1.setRotationPoint(1F, 14F, 1F);
|
||||
Collumn1.setTextureSize(128, 128);
|
||||
Collumn1.mirror = true;
|
||||
setRotation(Collumn1, 0F, 0F, 0F);
|
||||
Collumn2 = new ModelRenderer(this, 0, 9);
|
||||
Collumn2.addBox(0F, 0F, 0F, 1, 6, 1);
|
||||
Collumn2.setRotationPoint(1F, 14F, -2F);
|
||||
Collumn2.setTextureSize(128, 128);
|
||||
Collumn2.mirror = true;
|
||||
setRotation(Collumn2, 0F, 0F, 0F);
|
||||
Collumn3 = new ModelRenderer(this, 0, 9);
|
||||
Collumn3.addBox(0F, 0F, 0F, 1, 6, 1);
|
||||
Collumn3.setRotationPoint(-2F, 14F, -2F);
|
||||
Collumn3.setTextureSize(128, 128);
|
||||
Collumn3.mirror = true;
|
||||
setRotation(Collumn3, 0F, 0F, 0F);
|
||||
Collumn4 = new ModelRenderer(this, 0, 9);
|
||||
Collumn4.addBox(0F, 0F, 0F, 1, 6, 1);
|
||||
Collumn4.setRotationPoint(-2F, 14F, 1F);
|
||||
Collumn4.setTextureSize(128, 128);
|
||||
Collumn4.mirror = true;
|
||||
setRotation(Collumn4, 0F, 0F, 0F);
|
||||
CrossCollumn1 = new ModelRenderer(this, 17, 0);
|
||||
CrossCollumn1.addBox(0F, 0F, 0F, 1, 1, 2);
|
||||
CrossCollumn1.setRotationPoint(-2F, 16.5F, -1F);
|
||||
CrossCollumn1.setTextureSize(128, 128);
|
||||
CrossCollumn1.mirror = true;
|
||||
setRotation(CrossCollumn1, 0F, 0F, 0F);
|
||||
CrossCollumn2 = new ModelRenderer(this, 17, 0);
|
||||
CrossCollumn2.addBox(0F, 0F, 0F, 2, 1, 1);
|
||||
CrossCollumn2.setRotationPoint(-1F, 15.5F, -2F);
|
||||
CrossCollumn2.setTextureSize(128, 128);
|
||||
CrossCollumn2.mirror = true;
|
||||
setRotation(CrossCollumn2, 0F, 0F, 0F);
|
||||
CrossCollumn3 = new ModelRenderer(this, 17, 0);
|
||||
CrossCollumn3.addBox(0F, 0F, 0F, 1, 1, 2);
|
||||
CrossCollumn3.setRotationPoint(-2F, 14.5F, -1F);
|
||||
CrossCollumn3.setTextureSize(128, 128);
|
||||
CrossCollumn3.mirror = true;
|
||||
setRotation(CrossCollumn3, 0F, 0F, 0F);
|
||||
CrossCollumn4 = new ModelRenderer(this, 17, 0);
|
||||
CrossCollumn4.addBox(0F, 0F, 0F, 1, 1, 2);
|
||||
CrossCollumn4.setRotationPoint(1F, 14.5F, -1F);
|
||||
CrossCollumn4.setTextureSize(128, 128);
|
||||
CrossCollumn4.mirror = true;
|
||||
setRotation(CrossCollumn4, 0F, 0F, 0F);
|
||||
CrossCollumn5 = new ModelRenderer(this, 17, 0);
|
||||
CrossCollumn5.addBox(0F, 0F, 0F, 1, 1, 2);
|
||||
CrossCollumn5.setRotationPoint(1F, 16.5F, -1F);
|
||||
CrossCollumn5.setTextureSize(128, 128);
|
||||
CrossCollumn5.mirror = true;
|
||||
setRotation(CrossCollumn5, 0F, 0F, 0F);
|
||||
CrossCollumn6 = new ModelRenderer(this, 17, 0);
|
||||
CrossCollumn6.addBox(0F, 0F, 0F, 2, 1, 1);
|
||||
CrossCollumn6.setRotationPoint(-1F, 15.5F, 1F);
|
||||
CrossCollumn6.setTextureSize(128, 128);
|
||||
CrossCollumn6.mirror = true;
|
||||
setRotation(CrossCollumn6, 0F, 0F, 0F);
|
||||
CrossCollumn7 = new ModelRenderer(this, 17, 0);
|
||||
CrossCollumn7.addBox(0F, 0F, 0F, 2, 1, 1);
|
||||
CrossCollumn7.setRotationPoint(-1F, 17.5F, -2F);
|
||||
CrossCollumn7.setTextureSize(128, 128);
|
||||
CrossCollumn7.mirror = true;
|
||||
setRotation(CrossCollumn7, 0F, 0F, 0F);
|
||||
CrossCollumn8 = new ModelRenderer(this, 17, 0);
|
||||
CrossCollumn8.addBox(0F, 0F, 0F, 2, 1, 1);
|
||||
CrossCollumn8.setRotationPoint(-1F, 17.5F, 1F);
|
||||
CrossCollumn8.setTextureSize(128, 128);
|
||||
CrossCollumn8.mirror = true;
|
||||
setRotation(CrossCollumn8, 0F, 0F, 0F);
|
||||
HolderLeft = new ModelRenderer(this, 5, 9);
|
||||
HolderLeft.addBox(0F, 0F, 0F, 2, 5, 2);
|
||||
HolderLeft.setRotationPoint(-1F, 10.5F, -1F);
|
||||
HolderLeft.setTextureSize(128, 128);
|
||||
HolderLeft.mirror = true;
|
||||
setRotation(HolderLeft, 0F, 0F, 0F);
|
||||
FrontCoil = new ModelRenderer(this, 26, 0);
|
||||
FrontCoil.addBox(0F, 0F, 0F, 6, 2, 1);
|
||||
FrontCoil.setRotationPoint(-3F, 11F, -4F);
|
||||
FrontCoil.setTextureSize(128, 128);
|
||||
FrontCoil.mirror = true;
|
||||
setRotation(FrontCoil, 0F, 0F, 0F);
|
||||
RightCoil = new ModelRenderer(this, 26, 4);
|
||||
RightCoil.addBox(0F, 0F, 0F, 1, 2, 6);
|
||||
RightCoil.setRotationPoint(3F, 11.02222F, -3F);
|
||||
RightCoil.setTextureSize(128, 128);
|
||||
RightCoil.mirror = true;
|
||||
setRotation(RightCoil, 0F, 0F, 0F);
|
||||
BackCoil = new ModelRenderer(this, 26, 0);
|
||||
BackCoil.addBox(0F, 0F, 0F, 6, 2, 1);
|
||||
BackCoil.setRotationPoint(-3F, 11F, 3F);
|
||||
BackCoil.setTextureSize(128, 128);
|
||||
BackCoil.mirror = true;
|
||||
setRotation(BackCoil, 0F, 0F, 0F);
|
||||
LeftCoil = new ModelRenderer(this, 26, 4);
|
||||
LeftCoil.addBox(0F, 0F, 0F, 1, 2, 6);
|
||||
LeftCoil.setRotationPoint(-4F, 11.02222F, -3F);
|
||||
LeftCoil.setTextureSize(128, 128);
|
||||
LeftCoil.mirror = true;
|
||||
setRotation(LeftCoil, 0F, 0F, 0F);
|
||||
LFSCoil = new ModelRenderer(this, 0, 20);
|
||||
LFSCoil.addBox(0F, 0F, 0F, 1, 2, 1);
|
||||
LFSCoil.setRotationPoint(-3F, 11F, -3F);
|
||||
LFSCoil.setTextureSize(128, 128);
|
||||
LFSCoil.mirror = true;
|
||||
setRotation(LFSCoil, 0F, 0F, 0F);
|
||||
RFSCoil = new ModelRenderer(this, 0, 20);
|
||||
RFSCoil.addBox(0F, 0F, 0F, 1, 2, 1);
|
||||
RFSCoil.setRotationPoint(2F, 11F, -3F);
|
||||
RFSCoil.setTextureSize(128, 128);
|
||||
RFSCoil.mirror = true;
|
||||
setRotation(RFSCoil, 0F, 0F, 0F);
|
||||
RBSCoil = new ModelRenderer(this, 0, 20);
|
||||
RBSCoil.addBox(0F, 0F, 0F, 1, 2, 1);
|
||||
RBSCoil.setRotationPoint(2F, 11F, 2F);
|
||||
RBSCoil.setTextureSize(128, 128);
|
||||
RBSCoil.mirror = true;
|
||||
setRotation(RBSCoil, 0F, 0F, 0F);
|
||||
LBSCoil = new ModelRenderer(this, 0, 20);
|
||||
LBSCoil.addBox(0F, 0F, 0F, 1, 2, 1);
|
||||
LBSCoil.setRotationPoint(-3F, 11F, 2F);
|
||||
LBSCoil.setTextureSize(128, 128);
|
||||
LBSCoil.mirror = true;
|
||||
setRotation(LBSCoil, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float f5)
|
||||
{
|
||||
Base.render(f5);
|
||||
Collumn1.render(f5);
|
||||
Collumn2.render(f5);
|
||||
Collumn3.render(f5);
|
||||
Collumn4.render(f5);
|
||||
CrossCollumn1.render(f5);
|
||||
CrossCollumn2.render(f5);
|
||||
CrossCollumn3.render(f5);
|
||||
CrossCollumn4.render(f5);
|
||||
CrossCollumn5.render(f5);
|
||||
CrossCollumn6.render(f5);
|
||||
CrossCollumn7.render(f5);
|
||||
CrossCollumn8.render(f5);
|
||||
HolderLeft.render(f5);
|
||||
FrontCoil.render(f5);
|
||||
RightCoil.render(f5);
|
||||
BackCoil.render(f5);
|
||||
LeftCoil.render(f5);
|
||||
LFSCoil.render(f5);
|
||||
RFSCoil.render(f5);
|
||||
RBSCoil.render(f5);
|
||||
LBSCoil.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.client.render;
|
||||
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.induction.client.InductionClientProxy;
|
||||
import mekanism.induction.common.block.BlockBattery;
|
||||
import mekanism.induction.common.block.BlockEMContractor;
|
||||
import mekanism.induction.common.block.BlockTesla;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static final BlockRenderingHandler INSTANCE = new BlockRenderingHandler();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if(block instanceof BlockTesla)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0.5, 1.5, 0.5);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TeslaBottom.png"));
|
||||
RenderTesla.bottom.render(0.0625f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if(block instanceof BlockEMContractor)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0.5, 1.5, 0.5);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectromagneticContractor.png"));
|
||||
RenderEMContractor.model.render(0.0625f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if(block instanceof BlockBattery)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0.5, 1.42, 0.5);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Battery.png"));
|
||||
RenderBattery.model.render(0.0625f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
if(block instanceof BlockBattery)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return InductionClientProxy.INDUCTION_RENDER_ID;
|
||||
}
|
||||
}
|
|
@ -1,264 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.client.render;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.induction.client.model.ModelBattery;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderBattery extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static final ModelBattery model = new ModelBattery();
|
||||
|
||||
private EntityItem fakeBattery;
|
||||
private Random random = new Random();
|
||||
protected RenderManager renderManager;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float partialTick)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
if(((TileEntityBattery)t).structure.isMultiblock)
|
||||
{
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BatteryOn.png"));
|
||||
}
|
||||
else {
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Battery.png"));
|
||||
}
|
||||
|
||||
model.render(0.0625f);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(Minecraft.getMinecraft().gameSettings.fancyGraphics)
|
||||
{
|
||||
if(fakeBattery == null)
|
||||
{
|
||||
fakeBattery = new EntityItem(t.worldObj, 0, 0, 0, new ItemStack(Mekanism.EnergyTablet));
|
||||
fakeBattery.age = 10;
|
||||
}
|
||||
|
||||
if(renderManager == null)
|
||||
{
|
||||
renderManager = RenderManager.instance;
|
||||
}
|
||||
|
||||
int renderAmount = Math.min(((TileEntityBattery)t).clientCells, 16);
|
||||
|
||||
if(renderAmount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
|
||||
for(int slot = 0; slot < 4; slot++)
|
||||
{
|
||||
Vector3 sideVec = new Vector3(t).modifyPositionFromSide(correctSide(direction));
|
||||
Block block = Block.blocksList[sideVec.getBlockID(t.worldObj)];
|
||||
|
||||
if(block != null && block.isOpaqueCube())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y + 0.7F, (float)z + 0.5F);
|
||||
|
||||
float translateX = 0;
|
||||
float translateY = 0;
|
||||
|
||||
switch(slot)
|
||||
{
|
||||
case 0:
|
||||
translateX = 0.25F;
|
||||
break;
|
||||
case 1:
|
||||
translateX = 0.25F;
|
||||
translateY = -0.5F;
|
||||
break;
|
||||
case 2:
|
||||
translateX = -0.25F;
|
||||
translateY = -0.5F;
|
||||
break;
|
||||
case 3:
|
||||
translateX = -0.25F;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(direction)
|
||||
{
|
||||
case NORTH:
|
||||
GL11.glTranslatef(-0.5F, 0, 0);
|
||||
GL11.glTranslatef(0, translateY, translateX);
|
||||
GL11.glRotatef(90, 0, 1, 0);
|
||||
break;
|
||||
case SOUTH:
|
||||
GL11.glTranslatef(0, 0, -0.5F);
|
||||
GL11.glTranslatef(translateX, translateY, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GL11.glTranslatef(0.5F, 0, 0);
|
||||
GL11.glTranslatef(0, translateY, translateX);
|
||||
GL11.glRotatef(90, 0, 1, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GL11.glTranslatef(0, 0, 0.5F);
|
||||
GL11.glTranslatef(translateX, translateY, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
GL11.glScalef(0.4F, 0.4F, 0.4F);
|
||||
GL11.glTranslatef(0.0F, -0.15F, 0.0F);
|
||||
|
||||
renderItemSimple(fakeBattery);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(--renderAmount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ForgeDirection correctSide(ForgeDirection side)
|
||||
{
|
||||
switch(side)
|
||||
{
|
||||
case NORTH:
|
||||
return ForgeDirection.WEST;
|
||||
case SOUTH:
|
||||
return ForgeDirection.NORTH;
|
||||
case EAST:
|
||||
return ForgeDirection.SOUTH;
|
||||
case WEST:
|
||||
return ForgeDirection.EAST;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderItemSimple(EntityItem entityItem)
|
||||
{
|
||||
if(entityItem != null)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
ItemStack itemStack = entityItem.getEntityItem();
|
||||
|
||||
for(int k = 0; k < itemStack.getItem().getRenderPasses(itemStack.getItemDamage()); ++k)
|
||||
{
|
||||
Icon icon = itemStack.getItem().getIcon(itemStack, k);
|
||||
|
||||
if(icon == null)
|
||||
{
|
||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||
ResourceLocation resourcelocation = texturemanager.getResourceLocation(entityItem.getEntityItem().getItemSpriteNumber());
|
||||
icon = ((TextureMap) texturemanager.getTexture(resourcelocation)).getAtlasSprite("missingno");
|
||||
}
|
||||
|
||||
float f4 = icon.getMinU();
|
||||
float f5 = icon.getMaxU();
|
||||
float f6 = icon.getMinV();
|
||||
float f7 = icon.getMaxV();
|
||||
float f8 = 1.0F;
|
||||
float f9 = 0.5F;
|
||||
float f10 = 0.25F;
|
||||
float f11;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
float f12 = 0.0625F;
|
||||
f11 = 0.021875F;
|
||||
ItemStack itemstack = entityItem.getEntityItem();
|
||||
int j = itemstack.stackSize;
|
||||
byte b0 = getMiniItemCount(itemstack);
|
||||
|
||||
GL11.glTranslatef(-f9, -f10, -((f12 + f11) * b0 / 2.0F));
|
||||
|
||||
for(int kj = 0; kj < b0; ++kj)
|
||||
{
|
||||
// Makes items offset when in 3D, like when in 2D, looks much better. Considered
|
||||
// a
|
||||
// vanilla bug...
|
||||
if(kj > 0)
|
||||
{
|
||||
float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
GL11.glTranslatef(x, y, f12 + f11);
|
||||
}
|
||||
else {
|
||||
GL11.glTranslatef(0f, 0f, f12 + f11);
|
||||
}
|
||||
|
||||
if(itemstack.getItemSpriteNumber() == 0)
|
||||
{
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
}
|
||||
else {
|
||||
bindTexture(TextureMap.locationItemsTexture);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, icon.getIconWidth(), icon.getIconHeight(), f12);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public byte getMiniItemCount(ItemStack stack)
|
||||
{
|
||||
byte ret = 1;
|
||||
|
||||
if(stack.stackSize > 1)
|
||||
ret = 2;
|
||||
if(stack.stackSize > 15)
|
||||
ret = 3;
|
||||
if(stack.stackSize > 31)
|
||||
ret = 4;
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package mekanism.induction.client.render;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.induction.client.model.ModelEMContractor;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderEMContractor extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static final ModelEMContractor model = new ModelEMContractor(false);
|
||||
public static final ModelEMContractor MODEL_SPIN = new ModelEMContractor(true);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float partialTick)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
switch(ForgeDirection.getOrientation(((TileEntityEMContractor)t).getFacing()))
|
||||
{
|
||||
case DOWN:
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glTranslatef(0, -2, 0);
|
||||
break;
|
||||
case UP:
|
||||
break;
|
||||
case NORTH:
|
||||
GL11.glTranslatef(1, 1, 0);
|
||||
GL11.glRotatef(90, 0, 0, 1);
|
||||
break;
|
||||
case SOUTH:
|
||||
GL11.glTranslatef(-1, 1, 0);
|
||||
GL11.glRotatef(-90, 0, 0, 1);
|
||||
break;
|
||||
case WEST:
|
||||
GL11.glTranslatef(0, 1, 1);
|
||||
GL11.glRotatef(-90, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GL11.glTranslatef(0, 1, -1);
|
||||
GL11.glRotatef(90, 1, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if(((TileEntityEMContractor) t).suck)
|
||||
{
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectromagneticContractor.png"));
|
||||
}
|
||||
else {
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectromagneticContractorOn.png"));
|
||||
}
|
||||
|
||||
if(((TileEntityEMContractor)t).canFunction() && !Mekanism.proxy.isPaused())
|
||||
{
|
||||
MODEL_SPIN.render(0.0625f);
|
||||
}
|
||||
else {
|
||||
model.render(0.0625f);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.client.render;
|
||||
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.induction.client.model.ModelTeslaBottom;
|
||||
import mekanism.induction.client.model.ModelTeslaMiddle;
|
||||
import mekanism.induction.client.model.ModelTeslaTop;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderTesla extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static final ModelTeslaBottom bottom = new ModelTeslaBottom();
|
||||
public static final ModelTeslaMiddle middle = new ModelTeslaMiddle();
|
||||
public static final ModelTeslaTop top = new ModelTeslaTop();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
switch (t.getBlockMetadata())
|
||||
{
|
||||
default:
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TeslaBottom.png"));
|
||||
bottom.render(0.0625f);
|
||||
break;
|
||||
case 1:
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TeslaMiddle.png"));
|
||||
middle.render(0.0625f);
|
||||
break;
|
||||
case 2:
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TeslaTop.png"));
|
||||
top.render(0.0625f);
|
||||
break;
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
|
||||
public class BatteryManager
|
||||
{
|
||||
public static final int CELLS_PER_BATTERY = 16;
|
||||
|
||||
public static class SlotOut extends Slot
|
||||
{
|
||||
public SlotOut(IInventory inventory, int index, int x, int y)
|
||||
{
|
||||
super(inventory, index, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemstack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotBattery extends Slot
|
||||
{
|
||||
public SlotBattery(IInventory inventory, int index, int x, int y)
|
||||
{
|
||||
super(inventory, index, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemstack)
|
||||
{
|
||||
return itemstack.getItem() instanceof IItemElectric;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,291 +0,0 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.util.ListUtils;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class BatteryUpdateProtocol
|
||||
{
|
||||
/** The battery nodes that have already been iterated over. */
|
||||
public Set<TileEntityBattery> iteratedNodes = new HashSet<TileEntityBattery>();
|
||||
|
||||
/** The structures found, all connected by some nodes to the pointer. */
|
||||
public SynchronizedBatteryData structureFound = null;
|
||||
|
||||
/** The original block the calculation is getting run from. */
|
||||
public TileEntity pointer;
|
||||
|
||||
public BatteryUpdateProtocol(TileEntity tileEntity)
|
||||
{
|
||||
pointer = tileEntity;
|
||||
}
|
||||
|
||||
private void loopThrough(TileEntity tile)
|
||||
{
|
||||
if(structureFound == null)
|
||||
{
|
||||
World worldObj = tile.worldObj;
|
||||
|
||||
int origX = tile.xCoord, origY = tile.yCoord, origZ = tile.zCoord;
|
||||
|
||||
boolean isCorner = true;
|
||||
boolean rightBlocks = true;
|
||||
|
||||
Set<Object3D> locations = new HashSet<Object3D>();
|
||||
|
||||
int xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0;
|
||||
|
||||
int x = 0, y = 0, z = 0;
|
||||
|
||||
if((isBattery(origX + 1, origY, origZ) && isBattery(origX - 1, origY, origZ)) || (isBattery(origX, origY + 1, origZ) && isBattery(origX, origY - 1, origZ)) || (isBattery(origX, origY, origZ + 1) && isBattery(origX, origY, origZ - 1)))
|
||||
{
|
||||
isCorner = false;
|
||||
}
|
||||
|
||||
if(isCorner)
|
||||
{
|
||||
if(isBattery(origX + 1, origY, origZ))
|
||||
{
|
||||
xmin = 0;
|
||||
|
||||
while(isBattery(origX + x + 1, origY, origZ))
|
||||
{
|
||||
x++;
|
||||
}
|
||||
|
||||
xmax = x;
|
||||
}
|
||||
else {
|
||||
xmax = 0;
|
||||
|
||||
while(isBattery(origX + x - 1, origY, origZ))
|
||||
{
|
||||
x--;
|
||||
}
|
||||
|
||||
xmin = x;
|
||||
}
|
||||
|
||||
if(isBattery(origX, origY + 1, origZ))
|
||||
{
|
||||
ymin = 0;
|
||||
|
||||
while(isBattery(origX, origY + y + 1, origZ))
|
||||
{
|
||||
y++;
|
||||
}
|
||||
|
||||
ymax = y;
|
||||
}
|
||||
else {
|
||||
ymax = 0;
|
||||
|
||||
while(isBattery(origX, origY + y - 1, origZ))
|
||||
{
|
||||
y--;
|
||||
}
|
||||
|
||||
ymin = y;
|
||||
}
|
||||
|
||||
if(isBattery(origX, origY, origZ + 1))
|
||||
{
|
||||
zmin = 0;
|
||||
|
||||
while(isBattery(origX, origY, origZ + z + 1))
|
||||
{
|
||||
z++;
|
||||
}
|
||||
|
||||
zmax = z;
|
||||
}
|
||||
else {
|
||||
zmax = 0;
|
||||
|
||||
while(isBattery(origX, origY, origZ + z - 1))
|
||||
{
|
||||
z--;
|
||||
}
|
||||
|
||||
zmin = z;
|
||||
}
|
||||
|
||||
for(x = xmin; x <= xmax; x++)
|
||||
{
|
||||
for(y = ymin; y <= ymax; y++)
|
||||
{
|
||||
for(z = zmin; z <= zmax; z++)
|
||||
{
|
||||
if(!isBattery(origX + x, origY + y, origZ + z))
|
||||
{
|
||||
rightBlocks = false;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
locations.add(Object3D.get(tile).translate(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
if(!rightBlocks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!rightBlocks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(locations.size() >= 1 && locations.size() < 512)
|
||||
{
|
||||
if(rightBlocks && isCorner)
|
||||
{
|
||||
SynchronizedBatteryData structure = new SynchronizedBatteryData();
|
||||
structure.locations = locations;
|
||||
|
||||
if(structure.getVolume() > 1)
|
||||
{
|
||||
structure.isMultiblock = true;
|
||||
}
|
||||
|
||||
if(structure.locations.contains(Object3D.get(pointer)))
|
||||
{
|
||||
structureFound = structure;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iteratedNodes.add((TileEntityBattery) tile);
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = Object3D.get(tile).getFromSide(side).getTileEntity(tile.worldObj);
|
||||
|
||||
if(tileEntity instanceof TileEntityBattery)
|
||||
{
|
||||
if(!iteratedNodes.contains(tileEntity))
|
||||
{
|
||||
loopThrough(tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBattery(int x, int y, int z)
|
||||
{
|
||||
if(pointer.worldObj.getBlockTileEntity(x, y, z) instanceof TileEntityBattery)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void disperseCells()
|
||||
{
|
||||
SynchronizedBatteryData oldStructure = null;
|
||||
|
||||
for(TileEntityBattery tile : iteratedNodes)
|
||||
{
|
||||
if(tile.structure.isMultiblock)
|
||||
{
|
||||
oldStructure = tile.structure;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(oldStructure != null)
|
||||
{
|
||||
int maxCells = iteratedNodes.size() * BatteryManager.CELLS_PER_BATTERY;
|
||||
|
||||
List<ItemStack> rejected = ListUtils.capRemains(oldStructure.inventory, maxCells);
|
||||
ejectItems(rejected, Object3D.get(pointer));
|
||||
|
||||
ArrayList<List<ItemStack>> inventories = ListUtils.split(ListUtils.cap(oldStructure.inventory, maxCells), iteratedNodes.size());
|
||||
List<TileEntityBattery> iterList = ListUtils.asList(iteratedNodes);
|
||||
|
||||
boolean didVisibleInventory = false;
|
||||
|
||||
for(int i = 0; i < iterList.size(); i++)
|
||||
{
|
||||
TileEntityBattery tile = iterList.get(i);
|
||||
tile.structure = SynchronizedBatteryData.getBase(tile, inventories.get(i));
|
||||
|
||||
if(!didVisibleInventory)
|
||||
{
|
||||
tile.structure.visibleInventory = oldStructure.visibleInventory;
|
||||
didVisibleInventory = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ejectItems(List<ItemStack> items, Object3D vec)
|
||||
{
|
||||
for(ItemStack itemStack : items)
|
||||
{
|
||||
float motion = 0.7F;
|
||||
double motionX = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionY = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionZ = (pointer.worldObj.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
|
||||
EntityItem entityItem = new EntityItem(pointer.worldObj, vec.xCoord + motionX, vec.yCoord + motionY, vec.zCoord + motionZ, itemStack);
|
||||
|
||||
pointer.worldObj.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBatteries()
|
||||
{
|
||||
loopThrough(pointer);
|
||||
|
||||
if(structureFound != null)
|
||||
{
|
||||
for(TileEntityBattery tileEntity : iteratedNodes)
|
||||
{
|
||||
if(!structureFound.locations.contains(Object3D.get(tileEntity)))
|
||||
{
|
||||
disperseCells();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for(Object3D obj : structureFound.locations)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery)obj.getTileEntity(pointer.worldObj);
|
||||
|
||||
structureFound.inventory = ListUtils.merge(structureFound.inventory, tileEntity.structure.inventory);
|
||||
|
||||
if(tileEntity.structure.hasVisibleInventory())
|
||||
{
|
||||
structureFound.visibleInventory = tileEntity.structure.visibleInventory;
|
||||
}
|
||||
|
||||
tileEntity.structure = structureFound;
|
||||
}
|
||||
|
||||
List<ItemStack> rejected = ListUtils.capRemains(structureFound.inventory, structureFound.getMaxCells());
|
||||
ejectItems(rejected, Object3D.get(pointer));
|
||||
|
||||
structureFound.inventory = ListUtils.cap(structureFound.inventory, structureFound.getMaxCells());
|
||||
}
|
||||
else {
|
||||
disperseCells();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.common;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.induction.common.inventory.container.ContainerBattery;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class InductionCommonProxy implements IGuiHandler
|
||||
{
|
||||
public void registerRenderers() {}
|
||||
|
||||
public void loadConfiguration()
|
||||
{
|
||||
Mekanism.configuration.load();
|
||||
MekanismInduction.SOUND_FXS = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "TeslaSoundFXs", MekanismInduction.SOUND_FXS).getBoolean(MekanismInduction.SOUND_FXS);
|
||||
MekanismInduction.MAX_CONTRACTOR_DISTANCE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxEMContractor Path", MekanismInduction.MAX_CONTRACTOR_DISTANCE).getInt(MekanismInduction.MAX_CONTRACTOR_DISTANCE);
|
||||
|
||||
TileEntityEMContractor.ACCELERATION = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ContractorItemAcceleration", TileEntityEMContractor.ACCELERATION).getDouble(TileEntityEMContractor.ACCELERATION);
|
||||
TileEntityEMContractor.MAX_REACH = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ContractorMaxItemReach", TileEntityEMContractor.MAX_REACH).getInt(TileEntityEMContractor.MAX_REACH);
|
||||
TileEntityEMContractor.MAX_SPEED = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ContractorMaxItemSpeed", TileEntityEMContractor.MAX_SPEED).getDouble(TileEntityEMContractor.MAX_SPEED);
|
||||
TileEntityEMContractor.PUSH_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ContractorItemPushDelay", TileEntityEMContractor.PUSH_DELAY).getInt(TileEntityEMContractor.PUSH_DELAY);
|
||||
Mekanism.configuration.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(tileEntity instanceof TileEntityBattery)
|
||||
{
|
||||
return new ContainerBattery(player.inventory, ((TileEntityBattery)tileEntity));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b, boolean split) {}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
|
||||
{
|
||||
renderElectricShock(world, start, target, r, g, b, true);
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, Vector3 color)
|
||||
{
|
||||
renderElectricShock(world, start, target, (float)color.x, (float)color.y, (float)color.z);
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, Vector3 color, boolean split)
|
||||
{
|
||||
renderElectricShock(world, start, target, (float)color.x, (float)color.y, (float)color.z, split);
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target)
|
||||
{
|
||||
renderElectricShock(world, start, target, true);
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, boolean b)
|
||||
{
|
||||
renderElectricShock(world, start, target, 0.55f, 0.7f, 1f, b);
|
||||
}
|
||||
|
||||
public boolean isFancy()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import mekanism.common.IModule;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismRecipe;
|
||||
import mekanism.common.Tier.EnergyCubeTier;
|
||||
import mekanism.common.Version;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.induction.common.block.BlockBattery;
|
||||
import mekanism.induction.common.block.BlockEMContractor;
|
||||
import mekanism.induction.common.block.BlockTesla;
|
||||
import mekanism.induction.common.item.ItemBlockContractor;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import mekanism.induction.common.tileentity.TileEntityTesla;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@Mod(modid = "MekanismInduction", name = "MekanismInduction", version = "5.6.0", dependencies = "required-after:Mekanism;after:MekanismGenerators;after:ForgeMultipart")
|
||||
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
|
||||
public class MekanismInduction implements IModule
|
||||
{
|
||||
@Instance("MekanismInduction")
|
||||
public static MekanismInduction instance;
|
||||
|
||||
@SidedProxy(clientSide = "mekanism.induction.client.InductionClientProxy", serverSide = "mekanism.induction.common.InductionCommonProxy")
|
||||
public static InductionCommonProxy proxy;
|
||||
|
||||
/** MekanismInduction version number */
|
||||
public static Version versionNumber = new Version(5, 6, 0);
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*/
|
||||
public static boolean SOUND_FXS = true;
|
||||
|
||||
/** Block ID by Jyzarc */
|
||||
private static final int BLOCK_ID_PREFIX = 3200;
|
||||
/** Item ID by Horfius */
|
||||
private static final int ITEM_ID_PREFIX = 20150;
|
||||
public static int MAX_CONTRACTOR_DISTANCE = 200;
|
||||
|
||||
private static int NEXT_BLOCK_ID = BLOCK_ID_PREFIX;
|
||||
private static int NEXT_ITEM_ID = ITEM_ID_PREFIX;
|
||||
|
||||
public static int getNextBlockID()
|
||||
{
|
||||
return NEXT_BLOCK_ID++;
|
||||
}
|
||||
|
||||
public static int getNextItemID()
|
||||
{
|
||||
return NEXT_ITEM_ID++;
|
||||
}
|
||||
|
||||
//Blocks
|
||||
public static Block Tesla;
|
||||
public static Block ElectromagneticContractor;
|
||||
public static Block Battery;
|
||||
|
||||
public static final Vector3[] DYE_COLORS = new Vector3[] { new Vector3(), new Vector3(1, 0, 0), new Vector3(0, 0.608, 0.232), new Vector3(0.588, 0.294, 0), new Vector3(0, 0, 1), new Vector3(0.5, 0, 05), new Vector3(0, 1, 1), new Vector3(0.8, 0.8, 0.8), new Vector3(0.3, 0.3, 0.3), new Vector3(1, 0.412, 0.706), new Vector3(0.616, 1, 0), new Vector3(1, 1, 0), new Vector3(0.46f, 0.932, 1), new Vector3(0.5, 0.2, 0.5), new Vector3(0.7, 0.5, 0.1), new Vector3(1, 1, 1) };
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt)
|
||||
{
|
||||
NetworkRegistry.instance().registerGuiHandler(this, MekanismInduction.proxy);
|
||||
MinecraftForge.EVENT_BUS.register(new MultimeterEventHandler());
|
||||
|
||||
//Blocks
|
||||
Tesla = new BlockTesla(Mekanism.configuration.getBlock("Tesla", getNextBlockID()).getInt()).setUnlocalizedName("Tesla");
|
||||
ElectromagneticContractor = new BlockEMContractor(Mekanism.configuration.getBlock("ElectromagneticContractor", getNextBlockID()).getInt()).setUnlocalizedName("ElectromagneticContractor");
|
||||
Battery = new BlockBattery(Mekanism.configuration.getBlock("Battery", getNextBlockID()).getInt()).setUnlocalizedName("Battery");
|
||||
|
||||
GameRegistry.registerBlock(Tesla, "Tesla");
|
||||
GameRegistry.registerBlock(ElectromagneticContractor, ItemBlockContractor.class, "ElectromagneticContractor");
|
||||
GameRegistry.registerBlock(Battery, "Battery");
|
||||
|
||||
//Tiles
|
||||
GameRegistry.registerTileEntity(TileEntityTesla.class, "Tesla");
|
||||
GameRegistry.registerTileEntity(TileEntityEMContractor.class, "ElectromagneticContractor");
|
||||
GameRegistry.registerTileEntity(TileEntityBattery.class, "Battery");
|
||||
|
||||
MekanismInduction.proxy.registerRenderers();
|
||||
MekanismInduction.proxy.loadConfiguration();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent evt)
|
||||
{
|
||||
//Add this module to the core list
|
||||
Mekanism.modulesLoaded.add(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent evt)
|
||||
{
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(Tesla), new Object[] {"WEW", " C ", " I ", 'W', Mekanism.EnrichedAlloy, 'E', Item.eyeOfEnder, 'C', Mekanism.EnergyTablet.getUnchargedItem(), 'I', new ItemStack(Mekanism.BasicBlock, 1, 8)}));
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(Battery, 4), new Object[] {"RRR", "CIC", "RRR", 'R', Item.redstone, 'I', MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), 'C', "circuitBasic"}));
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(ElectromagneticContractor), new Object[] {" I ", "GCG", "WWW", 'W', "ingotSteel", 'C', Mekanism.EnergyTablet.getUnchargedItem(), 'G', "ingotOsmium", 'I', "ingotSteel"}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion()
|
||||
{
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Induction";
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import universalelectricity.core.electricity.ElectricalEvent.ElectricityProductionEvent;
|
||||
import universalelectricity.core.grid.IElectricityNetwork;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class MultimeterEventHandler
|
||||
{
|
||||
private static final HashMap<IElectricityNetwork, Float> networkEnergyCache = new HashMap<IElectricityNetwork, Float>();
|
||||
private static long lastCheckTime = 0;
|
||||
|
||||
public static HashMap<IElectricityNetwork, Float> getCache(World worldObj)
|
||||
{
|
||||
HashMap<IElectricityNetwork, Float> returnCache = (HashMap<IElectricityNetwork, Float>) networkEnergyCache.clone();
|
||||
|
||||
if (Math.abs(worldObj.getWorldTime() - lastCheckTime) >= 40)
|
||||
{
|
||||
lastCheckTime = worldObj.getWorldTime();
|
||||
networkEnergyCache.clear();
|
||||
}
|
||||
|
||||
return returnCache;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void event(ElectricityProductionEvent evt)
|
||||
{
|
||||
IElectricityNetwork network = evt.network;
|
||||
|
||||
if (evt.electricityPack.getWatts() != 0)
|
||||
{
|
||||
networkEnergyCache.put(network, evt.electricityPack.getWatts());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Uses the well known A* Pathfinding algorithm.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class PathfinderEMContractor
|
||||
{
|
||||
public final Set<Object3D> openSet, closedSet;
|
||||
|
||||
public final HashMap<Object3D, Object3D> navMap;
|
||||
|
||||
public final HashMap<Object3D, Double> gScore, fScore;
|
||||
|
||||
public final Object3D target;
|
||||
|
||||
public List<Object3D> results;
|
||||
|
||||
private World world;
|
||||
|
||||
public PathfinderEMContractor(World w, Object3D t)
|
||||
{
|
||||
world = w;
|
||||
target = t;
|
||||
|
||||
openSet = new HashSet<Object3D>();
|
||||
closedSet = new HashSet<Object3D>();
|
||||
navMap = new HashMap<Object3D, Object3D>();
|
||||
gScore = new HashMap<Object3D, Double>();
|
||||
fScore = new HashMap<Object3D, Double>();
|
||||
results = new ArrayList<Object3D>();
|
||||
}
|
||||
|
||||
public boolean find(final Object3D start)
|
||||
{
|
||||
openSet.add(start);
|
||||
gScore.put(start, 0d);
|
||||
fScore.put(start, gScore.get(start) + getEstimate(start, target));
|
||||
|
||||
int blockCount = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
Object3D neighbor = target.translate(direction.offsetX, direction.offsetY, direction.offsetZ);
|
||||
|
||||
if(!TileEntityEMContractor.canBePath(world, neighbor))
|
||||
{
|
||||
blockCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if(blockCount >= 6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double maxSearchDistance = start.distanceTo(target) * 2;
|
||||
|
||||
while(!openSet.isEmpty())
|
||||
{
|
||||
Object3D currentNode = null;
|
||||
double lowestFScore = 0;
|
||||
|
||||
for(Object3D node : openSet)
|
||||
{
|
||||
if(currentNode == null || fScore.get(node) < lowestFScore)
|
||||
{
|
||||
currentNode = node;
|
||||
lowestFScore = fScore.get(node);
|
||||
}
|
||||
}
|
||||
|
||||
if(currentNode == null && start.distanceTo(currentNode) > maxSearchDistance)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(currentNode.equals(target))
|
||||
{
|
||||
results = reconstructPath(navMap, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
openSet.remove(currentNode);
|
||||
closedSet.add(currentNode);
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
Object3D neighbor = currentNode.getFromSide(direction);
|
||||
|
||||
if(TileEntityEMContractor.canBePath(world, neighbor))
|
||||
{
|
||||
double tentativeG = gScore.get(currentNode) + currentNode.distanceTo(neighbor);
|
||||
|
||||
if(closedSet.contains(neighbor))
|
||||
{
|
||||
if(tentativeG >= gScore.get(neighbor))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(!openSet.contains(neighbor) || tentativeG < gScore.get(neighbor))
|
||||
{
|
||||
navMap.put(neighbor, currentNode);
|
||||
gScore.put(neighbor, tentativeG);
|
||||
fScore.put(neighbor, gScore.get(neighbor) + getEstimate(neighbor, target));
|
||||
openSet.add(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<Object3D> reconstructPath(HashMap<Object3D, Object3D> naviMap, Object3D currentNode)
|
||||
{
|
||||
List<Object3D> path = new ArrayList<Object3D>();
|
||||
path.add(currentNode);
|
||||
|
||||
if(naviMap.containsKey(currentNode))
|
||||
{
|
||||
path.addAll(reconstructPath(naviMap, naviMap.get(currentNode)));
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private double getEstimate(Object3D start, Object3D target2)
|
||||
{
|
||||
return start.distanceTo(target2);
|
||||
}
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.util.ListUtils;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
|
||||
public class SynchronizedBatteryData
|
||||
{
|
||||
public Set<Object3D> locations = new HashSet<Object3D>();
|
||||
|
||||
public List<ItemStack> inventory = new ArrayList<ItemStack>();
|
||||
|
||||
/**
|
||||
* Slot 0: Cell input slot Slot 1: Battery charge slot Slot 2: Battery discharge slot
|
||||
*/
|
||||
public ItemStack[] visibleInventory = new ItemStack[3];
|
||||
|
||||
public ItemStack tempStack;
|
||||
|
||||
public boolean isMultiblock;
|
||||
|
||||
public boolean didTick;
|
||||
|
||||
public boolean wroteInventory;
|
||||
|
||||
public int getMaxCells()
|
||||
{
|
||||
return getVolume() * BatteryManager.CELLS_PER_BATTERY;
|
||||
}
|
||||
|
||||
public int getVolume()
|
||||
{
|
||||
return locations.size();
|
||||
}
|
||||
|
||||
public boolean addCell(ItemStack cell)
|
||||
{
|
||||
if(inventory.size() < getMaxCells())
|
||||
{
|
||||
inventory.add(cell);
|
||||
sortInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void sortInventory()
|
||||
{
|
||||
Object[] array = ListUtils.copy(inventory).toArray();
|
||||
|
||||
ItemStack[] toSort = new ItemStack[array.length];
|
||||
|
||||
for(int i = 0; i < array.length; i++)
|
||||
{
|
||||
toSort[i] = (ItemStack) array[i];
|
||||
}
|
||||
|
||||
boolean cont = true;
|
||||
ItemStack temp;
|
||||
|
||||
while(cont)
|
||||
{
|
||||
cont = false;
|
||||
|
||||
for(int i = 0; i < toSort.length - 1; i++)
|
||||
{
|
||||
if(((IItemElectric) toSort[i].getItem()).getElectricityStored(toSort[i]) < ((IItemElectric) toSort[i + 1].getItem()).getElectricityStored(toSort[i + 1]))
|
||||
{
|
||||
temp = toSort[i];
|
||||
toSort[i] = toSort[i + 1];
|
||||
toSort[i + 1] = temp;
|
||||
cont = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inventory = new ArrayList<ItemStack>();
|
||||
|
||||
for(ItemStack itemStack : toSort)
|
||||
{
|
||||
inventory.add(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasVisibleInventory()
|
||||
{
|
||||
for(ItemStack itemStack : visibleInventory)
|
||||
{
|
||||
if(itemStack != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static SynchronizedBatteryData getBase(TileEntityBattery tileEntity, List<ItemStack> inventory)
|
||||
{
|
||||
SynchronizedBatteryData structure = getBase(tileEntity);
|
||||
structure.inventory = inventory;
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
public static SynchronizedBatteryData getBase(TileEntityBattery tileEntity)
|
||||
{
|
||||
SynchronizedBatteryData structure = new SynchronizedBatteryData();
|
||||
structure.locations.add(new Object3D(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * locations.hashCode();
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(!(obj instanceof SynchronizedBatteryData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SynchronizedBatteryData data = (SynchronizedBatteryData) obj;
|
||||
|
||||
if(!data.locations.equals(locations))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.induction.ITesla;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class TeslaGrid
|
||||
{
|
||||
private static final TeslaGrid INSTANCE_CLIENT = new TeslaGrid();
|
||||
private static final TeslaGrid INSTANCE_SERVER = new TeslaGrid();
|
||||
|
||||
private final Set<ITesla> tileEntities = new HashSet<ITesla>();
|
||||
|
||||
public void register(ITesla iTesla)
|
||||
{
|
||||
Iterator<ITesla> it = tileEntities.iterator();
|
||||
|
||||
while(it.hasNext())
|
||||
{
|
||||
ITesla tesla = it.next();
|
||||
|
||||
if(tesla instanceof TileEntity)
|
||||
{
|
||||
if(!((TileEntity) tesla).isInvalid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
it.remove();
|
||||
|
||||
}
|
||||
|
||||
tileEntities.add(iTesla);
|
||||
}
|
||||
|
||||
public void unregister(ITesla iTesla)
|
||||
{
|
||||
tileEntities.remove(iTesla);
|
||||
}
|
||||
|
||||
public Set<ITesla> get()
|
||||
{
|
||||
return tileEntities;
|
||||
}
|
||||
|
||||
public static TeslaGrid instance()
|
||||
{
|
||||
if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||
{
|
||||
return INSTANCE_SERVER;
|
||||
}
|
||||
|
||||
return INSTANCE_CLIENT;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.common;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class ThreadEMPathfinding extends Thread
|
||||
{
|
||||
private boolean isCompleted = false;
|
||||
private PathfinderEMContractor pathfinder;
|
||||
private Object3D start;
|
||||
|
||||
public ThreadEMPathfinding(PathfinderEMContractor p, Object3D s)
|
||||
{
|
||||
pathfinder = p;
|
||||
start = s;
|
||||
setPriority(Thread.MIN_PRIORITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
pathfinder.find(start);
|
||||
isCompleted = true;
|
||||
}
|
||||
|
||||
public PathfinderEMContractor getPath()
|
||||
{
|
||||
if(isCompleted)
|
||||
{
|
||||
return pathfinder;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,187 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.common.block;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.ListUtils;
|
||||
import mekanism.induction.client.render.BlockRenderingHandler;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* A block that detects power.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockBattery extends Block implements ITileEntityProvider
|
||||
{
|
||||
public BlockBattery(int id)
|
||||
{
|
||||
super(id, Material.piston);
|
||||
this.setCreativeTab(Mekanism.tabMekanism);
|
||||
this.setTextureName("mekanism:machine");
|
||||
setHardness(5F);
|
||||
setResistance(10F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
ItemStack itemStack = ListUtils.getTop(tileEntity.structure.inventory);
|
||||
|
||||
if (tileEntity.structure.inventory.remove(itemStack))
|
||||
{
|
||||
entityPlayer.dropPlayerItem(itemStack);
|
||||
tileEntity.updateAllClients();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float xClick, float yClick, float zClick)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (entityPlayer.isSneaking())
|
||||
{
|
||||
boolean result = tileEntity.toggleSide(ForgeDirection.getOrientation(side));
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entityPlayer.addChatMessage("Toggled side to: " + (result ? "input" : "output"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entityPlayer.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if (entityPlayer.getCurrentEquippedItem().itemID == Mekanism.EnergyTablet.itemID)
|
||||
{
|
||||
if (side != 0 && side != 1)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tileEntity.structure.addCell(entityPlayer.getCurrentEquippedItem()))
|
||||
{
|
||||
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
|
||||
tileEntity.updateAllClients();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if(entityPlayer.getCurrentEquippedItem() != null && entityPlayer.getCurrentEquippedItem().itemID == MekanismInduction.Battery.blockID)
|
||||
{
|
||||
if(!tileEntity.structure.isMultiblock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
entityPlayer.openGui(MekanismInduction.instance, 0, world, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (id == blockID)
|
||||
{
|
||||
TileEntityBattery battery = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
battery.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileEntityBattery battery = (TileEntityBattery)world.getBlockTileEntity(x, y, z);
|
||||
|
||||
battery.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (!tileEntity.structure.isMultiblock)
|
||||
{
|
||||
for (ItemStack itemStack : tileEntity.structure.inventory)
|
||||
{
|
||||
float motion = 0.7F;
|
||||
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
|
||||
EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack);
|
||||
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.removeBlockByPlayer(world, player, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockRenderingHandler.INSTANCE.getRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityBattery();
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
package mekanism.induction.common.block;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.induction.client.render.BlockRenderingHandler;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockEMContractor extends Block implements ITileEntityProvider
|
||||
{
|
||||
public BlockEMContractor(int id)
|
||||
{
|
||||
super(id, Material.piston);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
setTextureName("mekanism:machine");
|
||||
setHardness(5F);
|
||||
setResistance(10F);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockRenderingHandler.INSTANCE.getRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float posX, float posY, float posZ)
|
||||
{
|
||||
TileEntityEMContractor contractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(player.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if(player.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
||||
{
|
||||
contractor.setDye(player.getCurrentEquippedItem().getItemDamage());
|
||||
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(player.getCurrentEquippedItem().getItem() instanceof ItemConfigurator)
|
||||
{
|
||||
ItemConfigurator item = ((ItemConfigurator)player.getCurrentEquippedItem().getItem());
|
||||
|
||||
if(item.getState(player.getCurrentEquippedItem()) == 3)
|
||||
{
|
||||
Object3D linkVec = item.getLink(player.getCurrentEquippedItem());
|
||||
|
||||
if(linkVec != null)
|
||||
{
|
||||
if(linkVec.getTileEntity(world) instanceof TileEntityEMContractor)
|
||||
{
|
||||
contractor.setLink((TileEntityEMContractor)linkVec.getTileEntity(world), true);
|
||||
|
||||
if(world.isRemote)
|
||||
{
|
||||
player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("text.contractor.success") + "!");
|
||||
}
|
||||
|
||||
item.clearLink(player.getCurrentEquippedItem());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!player.isSneaking())
|
||||
{
|
||||
contractor.incrementFacing();
|
||||
}
|
||||
else {
|
||||
contractor.suck = !contractor.suck;
|
||||
contractor.updatePath();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
|
||||
{
|
||||
TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(!world.isRemote && !tileContractor.isLatched())
|
||||
{
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ);
|
||||
|
||||
if(tileEntity instanceof IInventory)
|
||||
{
|
||||
tileContractor.setFacing((short)side.getOpposite().ordinal());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityEMContractor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,172 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.common.block;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.item.ItemConfigurator;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.induction.client.render.BlockRenderingHandler;
|
||||
import mekanism.induction.common.tileentity.TileEntityTesla;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockTesla extends Block implements ITileEntityProvider
|
||||
{
|
||||
public BlockTesla(int id)
|
||||
{
|
||||
super(id, Material.piston);
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
setTextureName("mekanism:machine");
|
||||
setHardness(5F);
|
||||
setResistance(10F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
((TileEntityTesla) tileEntity).updatePositionStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
TileEntity t = world.getBlockTileEntity(x, y, z);
|
||||
TileEntityTesla tileEntity = ((TileEntityTesla) t).getControllingTelsa();
|
||||
|
||||
if(player.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if(player.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
||||
{
|
||||
tileEntity.setDye(player.getCurrentEquippedItem().getItemDamage());
|
||||
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(player.getCurrentEquippedItem().itemID == Item.redstone.itemID)
|
||||
{
|
||||
boolean status = tileEntity.toggleEntityAttack();
|
||||
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
player.addChatMessage("Toggled entity attack to: " + status);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(player.getCurrentEquippedItem().getItem() instanceof ItemConfigurator)
|
||||
{
|
||||
if(tileEntity.linked == null)
|
||||
{
|
||||
ItemConfigurator item = ((ItemConfigurator)player.getCurrentEquippedItem().getItem());
|
||||
|
||||
if(item.getState(player.getCurrentEquippedItem()) == 3)
|
||||
{
|
||||
Object3D linkObj = item.getLink(player.getCurrentEquippedItem());
|
||||
|
||||
if(linkObj != null)
|
||||
{
|
||||
if(!world.isRemote)
|
||||
{
|
||||
int dimID = item.getLink(player.getCurrentEquippedItem()).dimensionId;
|
||||
World otherWorld = MinecraftServer.getServer().worldServerForDimension(dimID);
|
||||
|
||||
if(linkObj.getTileEntity(otherWorld) instanceof TileEntityTesla)
|
||||
{
|
||||
tileEntity.setLink(new Vector3(((TileEntityTesla)linkObj.getTileEntity(otherWorld)).getTopTelsa()), dimID, true);
|
||||
|
||||
player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("text.tesla.success") + "!");
|
||||
|
||||
item.clearLink(player.getCurrentEquippedItem());
|
||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "ambient.weather.thunder", 5, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
tileEntity.setLink(null, world.provider.dimensionId, true);
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
player.addChatMessage("Unlinked Tesla.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
boolean receiveMode = tileEntity.toggleReceive();
|
||||
|
||||
if(world.isRemote)
|
||||
{
|
||||
player.addChatMessage("Tesla receive mode is now " + receiveMode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
((TileEntityTesla) tileEntity).updatePositionStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileEntityTesla();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockRenderingHandler.INSTANCE.getRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package mekanism.induction.common.inventory.container;
|
||||
|
||||
import mekanism.induction.common.BatteryManager.SlotBattery;
|
||||
import mekanism.induction.common.BatteryManager.SlotOut;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerBattery extends Container
|
||||
{
|
||||
private TileEntityBattery tileEntity;
|
||||
|
||||
public ContainerBattery(InventoryPlayer inventory, TileEntityBattery unit)
|
||||
{
|
||||
tileEntity = unit;
|
||||
|
||||
addSlotToContainer(new SlotBattery(unit, 0, 8, 22));
|
||||
addSlotToContainer(new SlotOut(unit, 1, 8, 58));
|
||||
addSlotToContainer(new SlotBattery(unit, 2, 31, 22));
|
||||
addSlotToContainer(new SlotBattery(unit, 3, 31, 58));
|
||||
|
||||
int slotX;
|
||||
|
||||
for(slotX = 0; slotX < 3; ++slotX)
|
||||
{
|
||||
for(int slotY = 0; slotY < 9; ++slotY)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 125 + slotX * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotX = 0; slotX < 9; ++slotX)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 183));
|
||||
}
|
||||
|
||||
tileEntity.playersUsing.add(inventory.player);
|
||||
tileEntity.openChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotID, int par2, int par3, EntityPlayer par4EntityPlayer)
|
||||
{
|
||||
ItemStack stack = super.slotClick(slotID, par2, par3, par4EntityPlayer);
|
||||
|
||||
if(slotID == 1)
|
||||
{
|
||||
ItemStack itemstack = ((Slot)inventorySlots.get(slotID)).getStack();
|
||||
ItemStack itemstack1 = itemstack == null ? null : itemstack.copy();
|
||||
inventoryItemStacks.set(slotID, itemstack1);
|
||||
|
||||
for(int j = 0; j < crafters.size(); ++j)
|
||||
{
|
||||
((ICrafting)crafters.get(j)).sendSlotContents(this, slotID, itemstack1);
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
|
||||
tileEntity.closeChest();
|
||||
tileEntity.playersUsing.remove(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotID)
|
||||
{
|
||||
if(slotID != 1)
|
||||
{
|
||||
return super.transferStackInSlot(par1EntityPlayer, slotID);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package mekanism.induction.common.item;
|
||||
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class ItemBlockContractor extends ItemBlock
|
||||
{
|
||||
public ItemBlockContractor(int id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||
{
|
||||
boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
|
||||
|
||||
if(place)
|
||||
{
|
||||
TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z);
|
||||
tileContractor.setFacing((short)ForgeDirection.getOrientation(side).ordinal());
|
||||
|
||||
if(!tileContractor.isLatched())
|
||||
{
|
||||
for(ForgeDirection side1 : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x + side1.offsetX, y + side1.offsetY, z + side1.offsetZ);
|
||||
|
||||
if(tileEntity instanceof IInventory)
|
||||
{
|
||||
tileContractor.setFacing((short)side1.getOpposite().ordinal());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return place;
|
||||
}
|
||||
}
|
|
@ -1,598 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package mekanism.induction.common.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.tileentity.TileEntityElectricBlock;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.ListUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.induction.common.BatteryUpdateProtocol;
|
||||
import mekanism.induction.common.SynchronizedBatteryData;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
/**
|
||||
* A modular battery with no GUI.
|
||||
*
|
||||
* @author AidanBrady
|
||||
*/
|
||||
public class TileEntityBattery extends TileEntityElectricBlock
|
||||
{
|
||||
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
|
||||
|
||||
public SynchronizedBatteryData structure = SynchronizedBatteryData.getBase(this);
|
||||
|
||||
public SynchronizedBatteryData prevStructure;
|
||||
|
||||
public double clientEnergy;
|
||||
public int clientCells;
|
||||
public double clientMaxEnergy;
|
||||
public int clientVolume;
|
||||
|
||||
private EnumSet inputSides = EnumSet.allOf(ForgeDirection.class);
|
||||
|
||||
public TileEntityBattery()
|
||||
{
|
||||
super("Battery", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(ticker == 5 && !structure.isMultiblock)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
if(structure.visibleInventory[0] != null)
|
||||
{
|
||||
if(structure.inventory.size() < structure.getMaxCells())
|
||||
{
|
||||
if(structure.visibleInventory[0].itemID == Mekanism.EnergyTablet.itemID)
|
||||
{
|
||||
structure.inventory.add(structure.visibleInventory[0]);
|
||||
structure.visibleInventory[0] = null;
|
||||
structure.sortInventory();
|
||||
|
||||
updateAllClients();
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(structure.visibleInventory[1] != null)
|
||||
{
|
||||
ItemStack itemStack = structure.visibleInventory[1];
|
||||
IEnergizedItem battery = (IEnergizedItem)itemStack.getItem();
|
||||
|
||||
double energyStored = getMaxEnergy();
|
||||
double batteryNeeded = battery.getMaxEnergy(itemStack) - battery.getEnergy(itemStack);
|
||||
double toGive = Math.min(energyStored, Math.min(battery.getMaxTransfer(itemStack), batteryNeeded));
|
||||
|
||||
battery.setEnergy(itemStack, battery.getEnergy(itemStack) + remove(toGive, true));
|
||||
}
|
||||
|
||||
if(structure.visibleInventory[2] != null)
|
||||
{
|
||||
ItemStack itemStack = structure.visibleInventory[2];
|
||||
IEnergizedItem battery = (IEnergizedItem)itemStack.getItem();
|
||||
|
||||
double energyNeeded = getMaxEnergy() - getEnergy();
|
||||
double batteryStored = battery.getEnergy(itemStack);
|
||||
double toReceive = Math.min(energyNeeded, Math.min(battery.getMaxTransfer(itemStack), batteryStored));
|
||||
battery.setEnergy(itemStack, battery.getEnergy(itemStack) - add(toReceive, true));
|
||||
}
|
||||
|
||||
if(prevStructure != structure)
|
||||
{
|
||||
for(EntityPlayer player : playersUsing)
|
||||
{
|
||||
player.closeScreen();
|
||||
}
|
||||
|
||||
updateClient();
|
||||
}
|
||||
|
||||
prevStructure = structure;
|
||||
|
||||
structure.wroteInventory = false;
|
||||
structure.didTick = false;
|
||||
|
||||
if(playersUsing.size() > 0)
|
||||
{
|
||||
updateClient();
|
||||
}
|
||||
|
||||
for(EntityPlayer player : playersUsing)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), player);
|
||||
}
|
||||
|
||||
CableUtils.emit(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
return structure.getVolume()*1000;
|
||||
}
|
||||
|
||||
public void updateClient()
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
}
|
||||
|
||||
public void updateAllClients()
|
||||
{
|
||||
for(Object3D vec : structure.locations)
|
||||
{
|
||||
TileEntityBattery battery = (TileEntityBattery)vec.getTileEntity(worldObj);
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(battery), battery.getNetworkedData(new ArrayList())));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
//Main inventory
|
||||
if(nbtTags.hasKey("CellItems"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("CellItems");
|
||||
structure.inventory = new ArrayList<ItemStack>();
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
|
||||
int slotID = tagCompound.getInteger("Slot");
|
||||
structure.inventory.add(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
|
||||
//Visible inventory
|
||||
if(nbtTags.hasKey("VisibleItems"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("VisibleItems");
|
||||
structure.visibleInventory = new ItemStack[3];
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if(slotID >= 0 && slotID < structure.visibleInventory.length)
|
||||
{
|
||||
if(slotID == 0)
|
||||
{
|
||||
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
else {
|
||||
setInventorySlotContents(slotID + 1, ItemStack.loadItemStackFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inputSides = EnumSet.noneOf(ForgeDirection.class);
|
||||
|
||||
NBTTagList tagList = nbtTags.getTagList("inputSides");
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound) tagList.tagAt(tagCount);
|
||||
byte side = tagCompound.getByte("side");
|
||||
inputSides.add(ForgeDirection.getOrientation(side));
|
||||
}
|
||||
|
||||
inputSides.remove(ForgeDirection.UNKNOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
if(!structure.wroteInventory)
|
||||
{
|
||||
//Inventory
|
||||
if(structure.inventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int slotCount = 0; slotCount < structure.inventory.size(); slotCount++)
|
||||
{
|
||||
if(structure.inventory.get(slotCount) != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("Slot", slotCount);
|
||||
structure.inventory.get(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("CellItems", tagList);
|
||||
}
|
||||
|
||||
//Visible inventory
|
||||
if(structure.visibleInventory != null)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int slotCount = 0; slotCount < structure.visibleInventory.length; slotCount++)
|
||||
{
|
||||
if(slotCount > 0)
|
||||
{
|
||||
slotCount++;
|
||||
}
|
||||
|
||||
if(getStackInSlot(slotCount) != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) slotCount);
|
||||
getStackInSlot(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("VisibleItems", tagList);
|
||||
}
|
||||
|
||||
structure.wroteInventory = true;
|
||||
|
||||
/**
|
||||
* Save the input sides.
|
||||
*/
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
Iterator<ForgeDirection> it = inputSides.iterator();
|
||||
|
||||
while(it.hasNext())
|
||||
{
|
||||
ForgeDirection dir = it.next();
|
||||
|
||||
if(dir != ForgeDirection.UNKNOWN)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("side", (byte) dir.ordinal());
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("inputSides", tagList);
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if(!worldObj.isRemote && (structure == null || !structure.didTick))
|
||||
{
|
||||
new BatteryUpdateProtocol(this).updateBatteries();
|
||||
|
||||
if(structure != null)
|
||||
{
|
||||
structure.didTick = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double add(double amount, boolean doAdd)
|
||||
{
|
||||
double added = 0;
|
||||
|
||||
for(ItemStack itemStack : structure.inventory)
|
||||
{
|
||||
if(itemStack.getItem() instanceof IEnergizedItem)
|
||||
{
|
||||
IEnergizedItem battery = (IEnergizedItem)itemStack.getItem();
|
||||
|
||||
double needed = amount - added;
|
||||
double itemAdd = Math.min(battery.getMaxEnergy(itemStack) - battery.getEnergy(itemStack), needed);
|
||||
|
||||
if(doAdd)
|
||||
{
|
||||
battery.setEnergy(itemStack, battery.getEnergy(itemStack) + itemAdd);
|
||||
}
|
||||
|
||||
added += itemAdd;
|
||||
|
||||
if(amount == added)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
public double remove(double amount, boolean doRemove)
|
||||
{
|
||||
List<ItemStack> inverse = ListUtils.inverse(structure.inventory);
|
||||
|
||||
float removed = 0;
|
||||
|
||||
for(ItemStack itemStack : inverse)
|
||||
{
|
||||
if(itemStack.getItem() instanceof IEnergizedItem)
|
||||
{
|
||||
IEnergizedItem battery = (IEnergizedItem)itemStack.getItem();
|
||||
|
||||
double needed = amount - removed;
|
||||
double itemRemove = Math.min(battery.getEnergy(itemStack), needed);
|
||||
|
||||
if(doRemove)
|
||||
{
|
||||
battery.setEnergy(itemStack, battery.getEnergy(itemStack) - itemRemove);
|
||||
}
|
||||
|
||||
removed += itemRemove;
|
||||
|
||||
if(amount == removed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy)
|
||||
{
|
||||
double stored = getEnergy();
|
||||
|
||||
if(energy > stored)
|
||||
{
|
||||
add(energy-stored, true);
|
||||
}
|
||||
else if(energy < stored)
|
||||
{
|
||||
remove(stored-energy, true);
|
||||
}
|
||||
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxEnergy()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
float max = 0;
|
||||
|
||||
for(ItemStack itemStack : structure.inventory)
|
||||
{
|
||||
if(itemStack != null)
|
||||
{
|
||||
if(itemStack.getItem() instanceof IEnergizedItem)
|
||||
{
|
||||
max += ((IEnergizedItem)itemStack.getItem()).getMaxEnergy(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
else {
|
||||
return clientMaxEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergy()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
double energy = 0;
|
||||
|
||||
for(ItemStack itemStack : structure.inventory)
|
||||
{
|
||||
if(itemStack != null)
|
||||
{
|
||||
if(itemStack.getItem() instanceof IEnergizedItem)
|
||||
{
|
||||
energy += ((IEnergizedItem)itemStack.getItem()).getEnergy(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return energy;
|
||||
}
|
||||
else {
|
||||
return clientEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput input)
|
||||
{
|
||||
structure.isMultiblock = input.readBoolean();
|
||||
|
||||
clientEnergy = input.readDouble();
|
||||
clientCells = input.readInt();
|
||||
clientMaxEnergy = input.readDouble();
|
||||
clientVolume = input.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
data.add(structure.isMultiblock);
|
||||
|
||||
data.add(getEnergy());
|
||||
data.add(structure.inventory.size());
|
||||
data.add(getMaxEnergy());
|
||||
data.add(structure.getVolume());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
return structure.visibleInventory[0];
|
||||
}
|
||||
else if(i == 1)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
return ListUtils.getTop(structure.inventory);
|
||||
}
|
||||
else {
|
||||
return structure.tempStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return structure.visibleInventory[i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotID, int amount)
|
||||
{
|
||||
MekanismUtils.saveChunk(this);
|
||||
|
||||
if(getStackInSlot(slotID) != null)
|
||||
{
|
||||
ItemStack tempStack;
|
||||
|
||||
if(getStackInSlot(slotID).stackSize <= amount)
|
||||
{
|
||||
tempStack = getStackInSlot(slotID);
|
||||
setInventorySlotContents(slotID, null);
|
||||
return tempStack;
|
||||
}
|
||||
else {
|
||||
tempStack = getStackInSlot(slotID).splitStack(amount);
|
||||
|
||||
if(getStackInSlot(slotID).stackSize == 0)
|
||||
{
|
||||
setInventorySlotContents(slotID, null);
|
||||
}
|
||||
|
||||
return tempStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
{
|
||||
return getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
MekanismUtils.saveChunk(this);
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
structure.visibleInventory[0] = itemstack;
|
||||
}
|
||||
else if(i == 1)
|
||||
{
|
||||
if(itemstack == null)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
structure.inventory.remove(ListUtils.getTop(structure.inventory));
|
||||
}
|
||||
else {
|
||||
structure.tempStack = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
structure.tempStack = itemstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
structure.visibleInventory[i - 1] = itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItem() instanceof IItemElectric;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getConsumingSides()
|
||||
{
|
||||
EnumSet set = inputSides.clone();
|
||||
set.remove(ForgeDirection.UNKNOWN);
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getOutputtingSides()
|
||||
{
|
||||
EnumSet set = EnumSet.complementOf(inputSides);
|
||||
set.remove(ForgeDirection.UNKNOWN);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the input/output sides of the battery.
|
||||
*/
|
||||
public boolean toggleSide(ForgeDirection orientation)
|
||||
{
|
||||
if(inputSides.contains(orientation))
|
||||
{
|
||||
inputSides.remove(orientation);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
inputSides.add(orientation);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleInventory()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,575 +0,0 @@
|
|||
package mekanism.induction.common.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketDataRequest;
|
||||
import mekanism.common.tileentity.TileEntityBasicBlock;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import mekanism.induction.common.PathfinderEMContractor;
|
||||
import mekanism.induction.common.ThreadEMPathfinding;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFluid;
|
||||
import net.minecraft.block.BlockLadder;
|
||||
import net.minecraft.block.BlockSnow;
|
||||
import net.minecraft.block.BlockVine;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityEMContractor extends TileEntityBasicBlock
|
||||
{
|
||||
public static int MAX_REACH = 40;
|
||||
public static int PUSH_DELAY = 5;
|
||||
public static double MAX_SPEED = .2;
|
||||
public static double ACCELERATION = .02;
|
||||
|
||||
private int pushDelay;
|
||||
|
||||
private AxisAlignedBB operationBounds;
|
||||
private AxisAlignedBB suckBounds;
|
||||
|
||||
/**
|
||||
* true = suck, false = push
|
||||
*/
|
||||
public boolean suck = true;
|
||||
|
||||
private ThreadEMPathfinding thread;
|
||||
private PathfinderEMContractor pathfinder;
|
||||
private Set<EntityItem> pathfindingTrackers = new HashSet<EntityItem>();
|
||||
private TileEntityEMContractor linked;
|
||||
private int lastCalcTime = 0;
|
||||
|
||||
/** Color of beam */
|
||||
private int dyeID = TileEntityTesla.DEFAULT_COLOR;
|
||||
private Object3D tempLinkVector;
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if(ticker == 1)
|
||||
{
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
pushDelay = Math.max(0, pushDelay - 1);
|
||||
|
||||
if(tempLinkVector != null)
|
||||
{
|
||||
if(tempLinkVector.getTileEntity(worldObj) instanceof TileEntityEMContractor)
|
||||
{
|
||||
setLink((TileEntityEMContractor)tempLinkVector.getTileEntity(worldObj), true);
|
||||
}
|
||||
|
||||
tempLinkVector = null;
|
||||
}
|
||||
|
||||
if(canFunction())
|
||||
{
|
||||
TileEntity inventoryTile = getLatched();
|
||||
IInventory inventory = (IInventory)inventoryTile;
|
||||
|
||||
if(!suck && pushDelay == 0)
|
||||
{
|
||||
ItemStack retrieved = InventoryUtils.takeTopItemFromInventory(inventory, ForgeDirection.OPPOSITES[getFacing()]);
|
||||
|
||||
if(retrieved != null)
|
||||
{
|
||||
EntityItem item = getItemWithPosition(retrieved);
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
|
||||
pushDelay = PUSH_DELAY;
|
||||
}
|
||||
}
|
||||
else if(suck)
|
||||
{
|
||||
if(suckBounds != null)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
for(EntityItem item : (List<EntityItem>)worldObj.getEntitiesWithinAABB(EntityItem.class, suckBounds))
|
||||
{
|
||||
ItemStack remains = InventoryUtils.putStackInInventory(inventory, item.getEntityItem(), ForgeDirection.OPPOSITES[getFacing()], false);
|
||||
|
||||
if(remains == null)
|
||||
{
|
||||
item.setDead();
|
||||
}
|
||||
else {
|
||||
item.setEntityItemStack(remains);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(thread != null)
|
||||
{
|
||||
PathfinderEMContractor newPath = thread.getPath();
|
||||
|
||||
if(newPath != null)
|
||||
{
|
||||
pathfinder = newPath;
|
||||
thread = null;
|
||||
}
|
||||
}
|
||||
|
||||
final int renderFrequency = MekanismInduction.proxy.isFancy() ? 1 + worldObj.rand.nextInt(2) : 10 + worldObj.rand.nextInt(2);
|
||||
final boolean renderBeam = ticker % renderFrequency == 0 && hasLink() && linked.suck != suck;
|
||||
|
||||
if(hasLink())
|
||||
{
|
||||
if(!suck)
|
||||
{
|
||||
if(renderBeam)
|
||||
{
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(this).translate(0.5), new Vector3(this).translate(new Vector3(getFacing())).translate(0.5), MekanismInduction.DYE_COLORS[dyeID], false);
|
||||
}
|
||||
|
||||
//Push entity along path.
|
||||
if(pathfinder != null)
|
||||
{
|
||||
for(int i = 0; i < pathfinder.results.size(); i++)
|
||||
{
|
||||
Object3D result = pathfinder.results.get(i);
|
||||
|
||||
if(TileEntityEMContractor.canBePath(worldObj, result))
|
||||
{
|
||||
if(i - 1 >= 0)
|
||||
{
|
||||
Object3D prevResult = pathfinder.results.get(i - 1);
|
||||
|
||||
Object3D difference = prevResult.difference(result);
|
||||
final ForgeDirection direction = toForge(difference);
|
||||
|
||||
if(renderBeam)
|
||||
{
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, toVec(prevResult).translate(0.5), toVec(result).translate(0.5), MekanismInduction.DYE_COLORS[dyeID], false);
|
||||
}
|
||||
|
||||
AxisAlignedBB bounds = AxisAlignedBB.getAABBPool().getAABB(result.xCoord, result.yCoord, result.zCoord, result.xCoord + 1, result.yCoord + 1, result.zCoord + 1);
|
||||
List<EntityItem> entities = worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
|
||||
|
||||
for(EntityItem entityItem : entities)
|
||||
{
|
||||
moveEntity(entityItem, direction, result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
updatePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
updatePath();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(renderBeam)
|
||||
{
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(this).translate(0.5), new Vector3(this).translate(new Vector3(getFacing())).translate(0.5), MekanismInduction.DYE_COLORS[dyeID], false);
|
||||
}
|
||||
|
||||
pathfinder = null;
|
||||
|
||||
Object3D searchVec = Object3D.get(this).getFromSide(ForgeDirection.getOrientation(getFacing()));
|
||||
AxisAlignedBB searchBounds = AxisAlignedBB.getAABBPool().getAABB(searchVec.xCoord, searchVec.yCoord, searchVec.zCoord, searchVec.xCoord + 1, searchVec.yCoord + 1, searchVec.zCoord + 1);
|
||||
|
||||
if(searchBounds != null)
|
||||
{
|
||||
for(EntityItem entityItem : (List<EntityItem>)worldObj.getEntitiesWithinAABB(EntityItem.class, searchBounds))
|
||||
{
|
||||
if(renderBeam)
|
||||
{
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem), MekanismInduction.DYE_COLORS[dyeID], false);
|
||||
}
|
||||
|
||||
moveEntity(entityItem, ForgeDirection.getOrientation(getFacing()), Object3D.get(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!hasLink())
|
||||
{
|
||||
for(EntityItem entityItem : (List<EntityItem>)worldObj.getEntitiesWithinAABB(EntityItem.class, operationBounds))
|
||||
{
|
||||
moveEntity(entityItem, ForgeDirection.getOrientation(getFacing()), Object3D.get(this));
|
||||
}
|
||||
}
|
||||
|
||||
if(linked != null && linked.isInvalid())
|
||||
{
|
||||
linked = null;
|
||||
}
|
||||
|
||||
lastCalcTime--;
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector3 toVec(Object3D obj)
|
||||
{
|
||||
return new Vector3(obj.xCoord, obj.yCoord, obj.zCoord);
|
||||
}
|
||||
|
||||
private static ForgeDirection toForge(Object3D obj)
|
||||
{
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if(side.offsetX == obj.xCoord && side.offsetY == obj.yCoord && side.offsetZ == obj.zCoord)
|
||||
{
|
||||
return side;
|
||||
}
|
||||
}
|
||||
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public static boolean canBePath(World world, Object3D position)
|
||||
{
|
||||
Block block = Block.blocksList[position.getBlockId(world)];
|
||||
return block == null || (block instanceof BlockSnow || block instanceof BlockVine || block instanceof BlockLadder || ((block instanceof BlockFluid || block instanceof IFluidBlock) && block.blockID != Block.lavaMoving.blockID && block.blockID != Block.lavaStill.blockID));
|
||||
}
|
||||
|
||||
private boolean hasLink()
|
||||
{
|
||||
return linked != null && !linked.isInvalid() && linked.linked == this;
|
||||
}
|
||||
|
||||
private void moveEntity(EntityItem entityItem, ForgeDirection direction, Object3D lockVector)
|
||||
{
|
||||
switch(direction)
|
||||
{
|
||||
case DOWN:
|
||||
entityItem.setPosition(lockVector.xCoord + 0.5, entityItem.posY, lockVector.zCoord + 0.5);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY - ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionY = Math.min(MAX_SPEED, entityItem.motionY + .04 + ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case UP:
|
||||
entityItem.setPosition(lockVector.xCoord + 0.5, entityItem.posY, lockVector.zCoord + 0.5);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionY = Math.min(MAX_SPEED, entityItem.motionY + .04 + ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY - ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case NORTH:
|
||||
entityItem.setPosition(lockVector.xCoord + 0.5, lockVector.yCoord + 0.5, entityItem.posZ);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionY = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ - ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ + ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case SOUTH:
|
||||
entityItem.setPosition(lockVector.xCoord + 0.5, lockVector.yCoord + 0.5, entityItem.posZ);
|
||||
|
||||
entityItem.motionX = 0;
|
||||
entityItem.motionY = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ + ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ - ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case WEST:
|
||||
entityItem.setPosition(entityItem.posX, lockVector.yCoord + 0.5, lockVector.zCoord + 0.5);
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX - ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX + ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
case EAST:
|
||||
entityItem.setPosition(entityItem.posX, lockVector.yCoord + 0.5, lockVector.zCoord + 0.5);
|
||||
|
||||
entityItem.motionY = 0;
|
||||
entityItem.motionZ = 0;
|
||||
|
||||
if(!suck)
|
||||
{
|
||||
entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX + ACCELERATION);
|
||||
}
|
||||
else {
|
||||
entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX - ACCELERATION);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
entityItem.ticksExisted = 1;
|
||||
entityItem.isAirBorne = true;
|
||||
entityItem.delayBeforeCanPickup = 1;
|
||||
entityItem.age = Math.max(entityItem.age - 1, 0);
|
||||
}
|
||||
|
||||
private EntityItem getItemWithPosition(ItemStack toSend)
|
||||
{
|
||||
EntityItem item = null;
|
||||
|
||||
switch(ForgeDirection.getOrientation(getFacing()))
|
||||
{
|
||||
case DOWN:
|
||||
item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.2, zCoord + 0.5, toSend);
|
||||
break;
|
||||
case UP:
|
||||
item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, toSend);
|
||||
break;
|
||||
case NORTH:
|
||||
item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord - 0.2, toSend);
|
||||
break;
|
||||
case SOUTH:
|
||||
item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 1.2, toSend);
|
||||
break;
|
||||
case WEST:
|
||||
item = new EntityItem(worldObj, xCoord - 0.2, yCoord + 0.5, zCoord + 0.5, toSend);
|
||||
break;
|
||||
case EAST:
|
||||
item = new EntityItem(worldObj, xCoord + 1.2, yCoord + 0.5, zCoord + 0.5, toSend);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item.motionX = 0;
|
||||
item.motionY = 0;
|
||||
item.motionZ = 0;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public void updateBounds()
|
||||
{
|
||||
switch(ForgeDirection.getOrientation(getFacing()))
|
||||
{
|
||||
case DOWN:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, Math.max(yCoord - MAX_REACH, 1), zCoord, xCoord + 1, yCoord, zCoord + 1);
|
||||
suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord - 0.1, zCoord, xCoord + 1, yCoord, zCoord + 1);
|
||||
break;
|
||||
case UP:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, Math.min(yCoord + 1 + MAX_REACH, 255), zCoord + 1);
|
||||
suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 1.1, zCoord + 1);
|
||||
break;
|
||||
case NORTH:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord - MAX_REACH, xCoord + 1, yCoord + 1, zCoord);
|
||||
suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord - 0.1, xCoord + 1, yCoord + 1, zCoord);
|
||||
break;
|
||||
case SOUTH:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord + 1, xCoord + 1, yCoord + 1, zCoord + 1 + MAX_REACH);
|
||||
suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord + 1, xCoord + 1, yCoord + 1, zCoord + 1.1);
|
||||
break;
|
||||
case WEST:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord - MAX_REACH, yCoord, zCoord, xCoord, yCoord + 1, zCoord + 1);
|
||||
suckBounds = AxisAlignedBB.getBoundingBox(xCoord - 0.1, yCoord, zCoord, xCoord, yCoord + 1, zCoord + 1);
|
||||
break;
|
||||
case EAST:
|
||||
operationBounds = AxisAlignedBB.getBoundingBox(xCoord + 1, yCoord, zCoord, xCoord + 1 + MAX_REACH, yCoord + 1, zCoord + 1);
|
||||
suckBounds = AxisAlignedBB.getBoundingBox(xCoord + 1, yCoord, zCoord, xCoord + 1.1, yCoord + 1, zCoord + 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLatched()
|
||||
{
|
||||
return getLatched() != null;
|
||||
}
|
||||
|
||||
public TileEntity getLatched()
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(getFacing()).getOpposite();
|
||||
|
||||
TileEntity tile = worldObj.getBlockTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ);
|
||||
|
||||
if(tile instanceof IInventory)
|
||||
{
|
||||
return tile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void incrementFacing()
|
||||
{
|
||||
setFacing((short)(facing == 5 ? 0 : facing+1));
|
||||
}
|
||||
|
||||
public boolean canFunction()
|
||||
{
|
||||
return isLatched() && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
suck = nbtTags.getBoolean("suck");
|
||||
dyeID = nbtTags.getInteger("dyeID");
|
||||
|
||||
if(nbtTags.hasKey("link"))
|
||||
{
|
||||
tempLinkVector = Object3D.read(nbtTags.getCompoundTag("link"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("suck", suck);
|
||||
nbtTags.setInteger("dyeID", dyeID);
|
||||
|
||||
if(linked != null)
|
||||
{
|
||||
nbtTags.setCompoundTag("link", Object3D.get(linked).write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
suck = dataStream.readBoolean();
|
||||
dyeID = dataStream.readInt();
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
tempLinkVector = new Object3D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||
}
|
||||
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(suck);
|
||||
data.add(dyeID);
|
||||
|
||||
if(linked != null)
|
||||
{
|
||||
data.add(true);
|
||||
|
||||
data.add(linked.xCoord);
|
||||
data.add(linked.yCoord);
|
||||
data.add(linked.zCoord);
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Link between two TileEntities, do pathfinding operation.
|
||||
*/
|
||||
public void setLink(TileEntityEMContractor tileEntity, boolean setOpponent)
|
||||
{
|
||||
if(linked != null && setOpponent)
|
||||
{
|
||||
linked.setLink(null, false);
|
||||
}
|
||||
|
||||
linked = tileEntity;
|
||||
|
||||
if(setOpponent)
|
||||
{
|
||||
linked.setLink(this, false);
|
||||
}
|
||||
|
||||
updatePath();
|
||||
}
|
||||
|
||||
public void updatePath()
|
||||
{
|
||||
if(thread == null && linked != null && lastCalcTime <= 0)
|
||||
{
|
||||
pathfinder = null;
|
||||
|
||||
Object3D start = Object3D.get(this).getFromSide(ForgeDirection.getOrientation(getFacing()));
|
||||
Object3D target = Object3D.get(linked).getFromSide(ForgeDirection.getOrientation(linked.getFacing()));
|
||||
|
||||
if(start.distanceTo(target) < MekanismInduction.MAX_CONTRACTOR_DISTANCE)
|
||||
{
|
||||
if(TileEntityEMContractor.canBePath(worldObj, start) && TileEntityEMContractor.canBePath(worldObj, target))
|
||||
{
|
||||
thread = new ThreadEMPathfinding(new PathfinderEMContractor(worldObj, target), start);
|
||||
thread.start();
|
||||
lastCalcTime = 40;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDye(int dye)
|
||||
{
|
||||
dyeID = dye;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
|
@ -1,591 +0,0 @@
|
|||
package mekanism.induction.common.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.induction.ITesla;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketDataRequest;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.tileentity.TileEntityElectricBlock;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import mekanism.induction.common.TeslaGrid;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
/**
|
||||
* The Tesla TileEntity.
|
||||
*
|
||||
* - Redstone (Prevent Output Toggle) - Right click (Prevent Input Toggle)
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileEntityTesla extends TileEntityElectricBlock implements ITesla
|
||||
{
|
||||
public static final int DEFAULT_COLOR = 12;
|
||||
public static final double TRANSFER_CAP = 10000;
|
||||
private int dyeID = DEFAULT_COLOR;
|
||||
|
||||
private boolean canReceive = true;
|
||||
private boolean attackEntities = true;
|
||||
|
||||
/** Client side to do sparks */
|
||||
private boolean doTransfer = true;
|
||||
|
||||
/** Prevents transfer loops */
|
||||
private final Set<TileEntityTesla> outputBlacklist = new HashSet<TileEntityTesla>();
|
||||
private final Set<TileEntityTesla> connectedTeslas = new HashSet<TileEntityTesla>();
|
||||
|
||||
/**
|
||||
* Caching
|
||||
*/
|
||||
private TileEntityTesla topCache = null;
|
||||
private TileEntityTesla controlCache = null;
|
||||
|
||||
/**
|
||||
* Quantum Tesla
|
||||
*/
|
||||
public Vector3 linked;
|
||||
public int linkDim;
|
||||
|
||||
/**
|
||||
* Client
|
||||
*/
|
||||
private int zapCounter = 0;
|
||||
private boolean isLinkedClient;
|
||||
|
||||
public TileEntityTesla()
|
||||
{
|
||||
super("Telsa", TRANSFER_CAP);
|
||||
inventory = new ItemStack[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if(ticker == 1)
|
||||
{
|
||||
TeslaGrid.instance().register(this);
|
||||
}
|
||||
|
||||
boolean doPacketUpdate = getEnergy() > 0;
|
||||
|
||||
//Only transfer if it is the bottom controlling Tesla tower.
|
||||
if(isController())
|
||||
{
|
||||
CableUtils.emit(this);
|
||||
|
||||
if(ticker % (5 + worldObj.rand.nextInt(2)) == 0 && ((worldObj.isRemote && doTransfer) || (getEnergy() > 0 && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))))
|
||||
{
|
||||
final TileEntityTesla topTesla = getTopTelsa();
|
||||
final Vector3 topTeslaVector = new Vector3(topTesla);
|
||||
|
||||
//Quantum transportation.
|
||||
if(linked != null || isLinkedClient)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
World dimWorld = MinecraftServer.getServer().worldServerForDimension(linkDim);
|
||||
|
||||
if(dimWorld != null)
|
||||
{
|
||||
TileEntity transferTile = linked.getTileEntity(dimWorld);
|
||||
|
||||
if(transferTile instanceof TileEntityTesla && !transferTile.isInvalid())
|
||||
{
|
||||
transfer(((TileEntityTesla)transferTile), getMaxEnergy()-getEnergy());
|
||||
|
||||
if(zapCounter % 5 == 0)
|
||||
{
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "mekanism:etc.Shock", (float)getEnergy() / 25000, 1.3f - 0.5f * (dyeID / 16f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, topTeslaVector.clone().translate(0.5), topTeslaVector.clone().translate(new Vector3(0.5, Double.POSITIVE_INFINITY, 0.5)), false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<ITesla> transferTeslaCoils = new ArrayList<ITesla>();
|
||||
|
||||
for(ITesla tesla : TeslaGrid.instance().get())
|
||||
{
|
||||
if(new Vector3((TileEntity)tesla).distance(new Vector3(this)) < getRange())
|
||||
{
|
||||
//Make sure Tesla is not part of this tower.
|
||||
if(!connectedTeslas.contains(tesla) && tesla.canReceive(this))
|
||||
{
|
||||
if(tesla instanceof TileEntityTesla)
|
||||
{
|
||||
if(((TileEntityTesla)tesla).getHeight() <= 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
tesla = ((TileEntityTesla)tesla).getControllingTelsa();
|
||||
}
|
||||
|
||||
transferTeslaCoils.add(tesla);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Sort by distance.
|
||||
Collections.sort(transferTeslaCoils, new Comparator() {
|
||||
public int compare(ITesla o1, ITesla o2)
|
||||
{
|
||||
double distance1 = new Vector3(topTesla).distance(new Vector3((TileEntity)o1));
|
||||
double distance2 = new Vector3(topTesla).distance(new Vector3((TileEntity)o2));
|
||||
|
||||
if(distance1 < distance2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if(distance1 > distance2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Object obj, Object obj1)
|
||||
{
|
||||
return compare((ITesla)obj, (ITesla)obj1);
|
||||
}
|
||||
});
|
||||
|
||||
if(transferTeslaCoils.size() > 0)
|
||||
{
|
||||
double transferEnergy = getEnergy() / transferTeslaCoils.size();
|
||||
int count = 0;
|
||||
boolean sentPacket = false;
|
||||
|
||||
for(ITesla tesla : transferTeslaCoils)
|
||||
{
|
||||
if(zapCounter % 5 == 0)
|
||||
{
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "mekanism:etc.Shock", (float)getEnergy() / 25000, 1.3f - 0.5f * (dyeID / 16f));
|
||||
}
|
||||
|
||||
Vector3 targetVector = new Vector3((TileEntity)tesla);
|
||||
|
||||
if(tesla instanceof TileEntityTesla)
|
||||
{
|
||||
((TileEntityTesla)tesla).getControllingTelsa().outputBlacklist.add(this);
|
||||
targetVector = new Vector3(((TileEntityTesla)tesla).getTopTelsa());
|
||||
}
|
||||
|
||||
double distance = topTeslaVector.distance(targetVector);
|
||||
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float)MekanismInduction.DYE_COLORS[dyeID].x, (float)MekanismInduction.DYE_COLORS[dyeID].y,
|
||||
(float)MekanismInduction.DYE_COLORS[dyeID].z);
|
||||
|
||||
transfer(tesla, Math.min(transferEnergy, TRANSFER_CAP));
|
||||
|
||||
if(!sentPacket && transferEnergy > 0)
|
||||
{
|
||||
sendPacket(2);
|
||||
}
|
||||
|
||||
if(attackEntities && zapCounter % 5 == 0)
|
||||
{
|
||||
MovingObjectPosition mop = topTeslaVector.clone().translate(0.5).rayTraceEntities(worldObj, targetVector.clone().translate(0.5));
|
||||
|
||||
if(mop != null && mop.entityHit != null)
|
||||
{
|
||||
if(mop.entityHit instanceof EntityLivingBase)
|
||||
{
|
||||
mop.entityHit.attackEntityFrom(DamageSource.magic, 4);
|
||||
MekanismInduction.proxy.renderElectricShock(worldObj, new Vector3(topTesla).clone().translate(0.5), new Vector3(mop.entityHit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count++ > 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zapCounter++;
|
||||
outputBlacklist.clear();
|
||||
|
||||
doTransfer = false;
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && getEnergy() > 0 != doPacketUpdate)
|
||||
{
|
||||
sendPacket(1);
|
||||
}
|
||||
}
|
||||
|
||||
clearCache();
|
||||
}
|
||||
|
||||
private void transfer(ITesla tesla, double transferEnergy)
|
||||
{
|
||||
transfer(-tesla.transfer(transferEnergy, true), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive(TileEntity tileEntity)
|
||||
{
|
||||
return canReceive && !outputBlacklist.contains(tileEntity) && getMaxEnergy()-getEnergy() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add((byte)1);
|
||||
data.add(dyeID);
|
||||
data.add(canReceive);
|
||||
data.add(attackEntities);
|
||||
data.add(linked != null);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do Tesla Beam.
|
||||
*/
|
||||
public ArrayList getTeslaPacket(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add((byte)2);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public void sendPacket(int id)
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
case 1:
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
break;
|
||||
case 2:
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getTeslaPacket(new ArrayList())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
switch(dataStream.readByte())
|
||||
{
|
||||
case 1:
|
||||
dyeID = dataStream.readInt();
|
||||
canReceive = dataStream.readBoolean();
|
||||
attackEntities = dataStream.readBoolean();
|
||||
isLinkedClient = dataStream.readBoolean();
|
||||
break;
|
||||
case 2:
|
||||
doTransfer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isController()
|
||||
{
|
||||
return worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0;
|
||||
}
|
||||
|
||||
private void clearCache()
|
||||
{
|
||||
topCache = null;
|
||||
controlCache = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transfer(double transferEnergy, boolean doTransfer)
|
||||
{
|
||||
if(isController() || getControllingTelsa() == this)
|
||||
{
|
||||
transferEnergy = Math.min(transferEnergy, getMaxEnergy()-getEnergy());
|
||||
|
||||
if(doTransfer)
|
||||
{
|
||||
setEnergy(getEnergy() + transferEnergy);
|
||||
}
|
||||
|
||||
sendPacket(1);
|
||||
return transferEnergy;
|
||||
}
|
||||
else {
|
||||
if(getEnergy() > 0)
|
||||
{
|
||||
transferEnergy += getEnergy();
|
||||
setEnergy(0);
|
||||
}
|
||||
|
||||
return getControllingTelsa().transfer(transferEnergy, doTransfer);
|
||||
}
|
||||
}
|
||||
|
||||
public int getRange()
|
||||
{
|
||||
return Math.min(4 * (getHeight() - 1), 50);
|
||||
}
|
||||
|
||||
public void updatePositionStatus()
|
||||
{
|
||||
boolean isTop = new Vector3(this).translate(new Vector3(0, 1, 0)).getTileEntity(worldObj) instanceof TileEntityTesla;
|
||||
boolean isBottom = new Vector3(this).translate(new Vector3(0, -1, 0)).getTileEntity(worldObj) instanceof TileEntityTesla;
|
||||
|
||||
if(isTop && isBottom)
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 3);
|
||||
}
|
||||
else if(isBottom)
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 2, 3);
|
||||
}
|
||||
else {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called only on bottom.
|
||||
*
|
||||
* @return The highest Tesla coil in this tower.
|
||||
*/
|
||||
public TileEntityTesla getTopTelsa()
|
||||
{
|
||||
if(topCache != null)
|
||||
{
|
||||
return topCache;
|
||||
}
|
||||
|
||||
connectedTeslas.clear();
|
||||
Vector3 checkPosition = new Vector3(this);
|
||||
TileEntityTesla returnTile = this;
|
||||
|
||||
while(true)
|
||||
{
|
||||
TileEntity t = checkPosition.getTileEntity(worldObj);
|
||||
|
||||
if(t instanceof TileEntityTesla)
|
||||
{
|
||||
connectedTeslas.add((TileEntityTesla)t);
|
||||
returnTile = (TileEntityTesla)t;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
checkPosition.y++;
|
||||
}
|
||||
|
||||
topCache = returnTile;
|
||||
return returnTile;
|
||||
}
|
||||
|
||||
/**
|
||||
* For non-controlling Tesla to use.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TileEntityTesla getControllingTelsa()
|
||||
{
|
||||
if(controlCache != null)
|
||||
{
|
||||
return controlCache;
|
||||
}
|
||||
|
||||
Vector3 checkPosition = new Vector3(this);
|
||||
TileEntityTesla returnTile = this;
|
||||
|
||||
while(true)
|
||||
{
|
||||
TileEntity t = checkPosition.getTileEntity(worldObj);
|
||||
|
||||
if(t instanceof TileEntityTesla)
|
||||
{
|
||||
returnTile = (TileEntityTesla)t;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
checkPosition.y--;
|
||||
}
|
||||
|
||||
controlCache = returnTile;
|
||||
return returnTile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called only on bottom.
|
||||
*
|
||||
* @return The highest Tesla coil in this tower.
|
||||
*/
|
||||
public int getHeight()
|
||||
{
|
||||
connectedTeslas.clear();
|
||||
int y = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
TileEntity t = new Vector3(this).translate(new Vector3(0, y, 0)).getTileEntity(worldObj);
|
||||
|
||||
if(t instanceof TileEntityTesla)
|
||||
{
|
||||
connectedTeslas.add((TileEntityTesla)t);
|
||||
y++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
TeslaGrid.instance().unregister(this);
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
{
|
||||
super.validate();
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketDataRequest().setParams(Object3D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
public void setDye(int id)
|
||||
{
|
||||
dyeID = id;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public boolean toggleReceive()
|
||||
{
|
||||
return canReceive = !canReceive;
|
||||
}
|
||||
|
||||
public boolean toggleEntityAttack()
|
||||
{
|
||||
boolean returnBool = attackEntities = !attackEntities;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return returnBool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
dyeID = nbt.getInteger("dyeID");
|
||||
canReceive = nbt.getBoolean("canReceive");
|
||||
attackEntities = nbt.getBoolean("attackEntities");
|
||||
|
||||
if(nbt.hasKey("link_x") && nbt.hasKey("link_y") && nbt.hasKey("link_z"))
|
||||
{
|
||||
linked = new Vector3(nbt.getInteger("link_x"), nbt.getInteger("link_y"), nbt.getInteger("link_z"));
|
||||
linkDim = nbt.getInteger("linkDim");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
nbtTags.setInteger("dyeID", dyeID);
|
||||
nbtTags.setBoolean("canReceive", canReceive);
|
||||
nbtTags.setBoolean("attackEntities", attackEntities);
|
||||
|
||||
if(linked != null)
|
||||
{
|
||||
nbtTags.setInteger("link_x", (int)linked.x);
|
||||
nbtTags.setInteger("link_y", (int)linked.y);
|
||||
nbtTags.setInteger("link_z", (int)linked.z);
|
||||
nbtTags.setInteger("linkDim", linkDim);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLink(Vector3 vector3, int dimID, boolean setOpponent)
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
World otherWorld = MinecraftServer.getServer().worldServerForDimension(linkDim);
|
||||
|
||||
if(setOpponent && linked != null && otherWorld != null)
|
||||
{
|
||||
TileEntity tileEntity = linked.getTileEntity(otherWorld);
|
||||
|
||||
if(tileEntity instanceof TileEntityTesla)
|
||||
{
|
||||
((TileEntityTesla)tileEntity).setLink(null, linkDim, false);
|
||||
}
|
||||
}
|
||||
|
||||
linked = vector3;
|
||||
linkDim = dimID;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
World newOtherWorld = MinecraftServer.getServer().worldServerForDimension(linkDim);
|
||||
|
||||
if(setOpponent && newOtherWorld != null && linked != null)
|
||||
{
|
||||
TileEntity tileEntity = linked.getTileEntity(newOtherWorld);
|
||||
|
||||
if(tileEntity instanceof TileEntityTesla)
|
||||
{
|
||||
((TileEntityTesla)tileEntity).setLink(new Vector3(this), worldObj.provider.dimensionId, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
return TRANSFER_CAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getOutputtingSides()
|
||||
{
|
||||
return EnumSet.of(ForgeDirection.DOWN);
|
||||
}
|
||||
}
|
BIN
resources/assets/mekanism/render/Balloon.png
Normal file
BIN
resources/assets/mekanism/render/Balloon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/assets/mekanism/sound/etc/Pop.ogg
Normal file
BIN
resources/assets/mekanism/sound/etc/Pop.ogg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue