Got wires working
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 225 B |
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 224 B |
After Width: | Height: | Size: 798 B |
|
@ -16,7 +16,9 @@ import resonantinduction.render.RenderBattery;
|
|||
import resonantinduction.render.RenderEMContractor;
|
||||
import resonantinduction.render.RenderMultimeter;
|
||||
import resonantinduction.render.RenderTesla;
|
||||
import resonantinduction.render.RenderWire;
|
||||
import resonantinduction.tesla.TileEntityTesla;
|
||||
import resonantinduction.wire.TileEntityWire;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
|
@ -42,6 +44,7 @@ public class ClientProxy extends CommonProxy
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultimeter.class, new RenderMultimeter());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBattery.class, new RenderBattery());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWire.class, new RenderWire());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,7 @@ import resonantinduction.tesla.BlockTesla;
|
|||
import resonantinduction.tesla.TileEntityTesla;
|
||||
import resonantinduction.wire.BlockWire;
|
||||
import resonantinduction.wire.ItemBlockWire;
|
||||
import resonantinduction.wire.TileEntityWire;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
@ -154,7 +155,6 @@ public class ResonantInduction
|
|||
itemCapacitor = new ItemCapacitor(getNextItemID());
|
||||
itemLinker = new ItemLinker(getNextItemID());
|
||||
|
||||
|
||||
// Blocks
|
||||
blockTesla = new BlockTesla(getNextBlockID());
|
||||
blockMultimeter = new BlockMultimeter(getNextBlockID());
|
||||
|
@ -179,6 +179,7 @@ public class ResonantInduction
|
|||
GameRegistry.registerTileEntity(TileEntityMultimeter.class, blockMultimeter.getUnlocalizedName());
|
||||
GameRegistry.registerTileEntity(TileEntityEMContractor.class, blockEMContractor.getUnlocalizedName());
|
||||
GameRegistry.registerTileEntity(TileEntityBattery.class, blockBattery.getUnlocalizedName());
|
||||
GameRegistry.registerTileEntity(TileEntityWire.class, blockWire.getUnlocalizedName());
|
||||
|
||||
ResonantInduction.proxy.registerRenderers();
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ import universalelectricity.core.vector.Vector3;
|
|||
*/
|
||||
public class PathfinderEMContractor
|
||||
{
|
||||
public Set<Vector3> openSet, closedSet;
|
||||
public final Set<Vector3> openSet, closedSet;
|
||||
|
||||
public HashMap<Vector3, Vector3> navMap;
|
||||
public final HashMap<Vector3, Vector3> navMap;
|
||||
|
||||
public HashMap<Vector3, Double> gScore, fScore;
|
||||
public final HashMap<Vector3, Double> gScore, fScore;
|
||||
|
||||
public Vector3 target;
|
||||
public final Vector3 target;
|
||||
|
||||
public List<Vector3> results;
|
||||
|
||||
|
@ -37,10 +37,7 @@ public class PathfinderEMContractor
|
|||
{
|
||||
this.world = world;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public boolean find(Vector3 start)
|
||||
{
|
||||
/**
|
||||
* Instantiate Variables
|
||||
*/
|
||||
|
@ -50,9 +47,12 @@ public class PathfinderEMContractor
|
|||
this.gScore = new HashMap<Vector3, Double>();
|
||||
this.fScore = new HashMap<Vector3, Double>();
|
||||
this.results = new ArrayList<Vector3>();
|
||||
}
|
||||
|
||||
public boolean find(Vector3 start)
|
||||
{
|
||||
this.openSet.add(start);
|
||||
this.gScore.put(start, (double) 0);
|
||||
this.gScore.put(start, 0d);
|
||||
this.fScore.put(start, this.gScore.get(start) + getEstimate(start, this.target));
|
||||
|
||||
int blockCount = 0;
|
||||
|
|
|
@ -51,28 +51,21 @@ public abstract class ItemCoordLink extends ItemBase
|
|||
|
||||
public Vector3 getLink(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null || !(itemStack.getTagCompound().hasKey("bindX") && itemStack.getTagCompound().hasKey("bindY") && itemStack.getTagCompound().hasKey("bindZ")))
|
||||
if (itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("position"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int x = itemStack.stackTagCompound.getInteger("bindX");
|
||||
int y = itemStack.stackTagCompound.getInteger("bindY");
|
||||
int z = itemStack.stackTagCompound.getInteger("bindZ");
|
||||
|
||||
return new Vector3(x, y, z);
|
||||
return new Vector3(itemStack.getTagCompound().getCompoundTag("position"));
|
||||
}
|
||||
|
||||
public void setLink(ItemStack itemStack, Vector3 vec, int dimID)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
if (itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.stackTagCompound.setInteger("bindX", (int) vec.x);
|
||||
itemStack.stackTagCompound.setInteger("bindY", (int) vec.y);
|
||||
itemStack.stackTagCompound.setInteger("bindZ", (int) vec.z);
|
||||
itemStack.getTagCompound().setCompoundTag("position", vec.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
itemStack.stackTagCompound.setInteger("dimID", dimID);
|
||||
}
|
||||
|
|
130
src/resonantinduction/model/ModelCopperWire.java
Normal file
|
@ -0,0 +1,130 @@
|
|||
package resonantinduction.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCopperWire extends ModelBase
|
||||
{
|
||||
// fields
|
||||
ModelRenderer Middle;
|
||||
ModelRenderer Right;
|
||||
ModelRenderer Left;
|
||||
ModelRenderer Back;
|
||||
ModelRenderer Front;
|
||||
ModelRenderer Top;
|
||||
ModelRenderer Bottom;
|
||||
|
||||
public ModelCopperWire()
|
||||
{
|
||||
textureWidth = 64;
|
||||
textureHeight = 32;
|
||||
Middle = new ModelRenderer(this, 0, 0);
|
||||
Middle.addBox(-1F, -1F, -1F, 4, 4, 4);
|
||||
Middle.setRotationPoint(-1F, 15F, -1F);
|
||||
Middle.setTextureSize(64, 32);
|
||||
Middle.mirror = true;
|
||||
setRotation(Middle, 0F, 0F, 0F);
|
||||
Right = new ModelRenderer(this, 21, 0);
|
||||
Right.addBox(0F, 0F, 0F, 6, 4, 4);
|
||||
Right.setRotationPoint(2F, 14F, -2F);
|
||||
Right.setTextureSize(64, 32);
|
||||
Right.mirror = true;
|
||||
setRotation(Right, 0F, 0F, 0F);
|
||||
Left = new ModelRenderer(this, 21, 0);
|
||||
Left.addBox(0F, 0F, 0F, 6, 4, 4);
|
||||
Left.setRotationPoint(-8F, 14F, -2F);
|
||||
Left.setTextureSize(64, 32);
|
||||
Left.mirror = true;
|
||||
setRotation(Left, 0F, 0F, 0F);
|
||||
Back = new ModelRenderer(this, 0, 11);
|
||||
Back.addBox(0F, 0F, 0F, 4, 4, 6);
|
||||
Back.setRotationPoint(-2F, 14F, 2F);
|
||||
Back.setTextureSize(64, 32);
|
||||
Back.mirror = true;
|
||||
setRotation(Back, 0F, 0F, 0F);
|
||||
Front = new ModelRenderer(this, 0, 11);
|
||||
Front.addBox(0F, 0F, 0F, 4, 4, 6);
|
||||
Front.setRotationPoint(-2F, 14F, -8F);
|
||||
Front.setTextureSize(64, 32);
|
||||
Front.mirror = true;
|
||||
setRotation(Front, 0F, 0F, 0F);
|
||||
Top = new ModelRenderer(this, 21, 11);
|
||||
Top.addBox(0F, 0F, 0F, 4, 6, 4);
|
||||
Top.setRotationPoint(-2F, 8F, -2F);
|
||||
Top.setTextureSize(64, 32);
|
||||
Top.mirror = true;
|
||||
setRotation(Top, 0F, 0F, 0F);
|
||||
Bottom = new ModelRenderer(this, 21, 11);
|
||||
Bottom.addBox(0F, 0F, 0F, 4, 6, 4);
|
||||
Bottom.setRotationPoint(-2F, 18F, -2F);
|
||||
Bottom.setTextureSize(64, 32);
|
||||
Bottom.mirror = true;
|
||||
setRotation(Bottom, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
|
||||
{
|
||||
super.render(entity, f, f1, f2, f3, f4, f5);
|
||||
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
|
||||
this.renderMiddle();
|
||||
this.renderBottom();
|
||||
this.renderTop();
|
||||
this.renderLeft();
|
||||
this.renderRight();
|
||||
this.renderBack();
|
||||
this.renderFront();
|
||||
}
|
||||
|
||||
public void renderMiddle()
|
||||
{
|
||||
Middle.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderBottom()
|
||||
{
|
||||
Bottom.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderTop()
|
||||
{
|
||||
Top.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderLeft()
|
||||
{
|
||||
Left.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderRight()
|
||||
{
|
||||
Right.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderBack()
|
||||
{
|
||||
Back.render(0.0625F);
|
||||
}
|
||||
|
||||
public void renderFront()
|
||||
{
|
||||
Front.render(0.0625F);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotationAngles(float x, float y, float z, float f3, float f4, float f5, Entity entity)
|
||||
{
|
||||
super.setRotationAngles(x, y, z, f3, f4, f5, entity);
|
||||
}
|
||||
}
|
128
src/resonantinduction/render/RenderWire.java
Normal file
|
@ -0,0 +1,128 @@
|
|||
package resonantinduction.render;
|
||||
|
||||
import ic2.api.Direction;
|
||||
import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.ResonantInduction;
|
||||
import resonantinduction.model.ModelCopperWire;
|
||||
import resonantinduction.wire.TileEntityWire;
|
||||
import universalelectricity.compatibility.Compatibility;
|
||||
import universalelectricity.core.block.IConnector;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderWire extends TileEntitySpecialRenderer
|
||||
{
|
||||
private static final ResourceLocation COPPER_TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "wireCopper.png");
|
||||
public static final ModelCopperWire WIRE_MODEL = new ModelCopperWire();
|
||||
|
||||
public void renderModelAt(TileEntityWire tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
// Texture file
|
||||
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(COPPER_TEXTURE);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
|
||||
List<TileEntity> adjecentConnections = new ArrayList<TileEntity>();
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity adjacentTile = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity), side);
|
||||
|
||||
if (adjacentTile instanceof IConnector)
|
||||
{
|
||||
if (((IConnector) adjacentTile).canConnect(side.getOpposite()))
|
||||
{
|
||||
adjecentConnections.add(adjacentTile);
|
||||
}
|
||||
else
|
||||
{
|
||||
adjecentConnections.add(null);
|
||||
}
|
||||
}
|
||||
else if (Compatibility.isIndustrialCraft2Loaded() && adjacentTile instanceof IEnergyTile)
|
||||
{
|
||||
if (adjacentTile instanceof IEnergyAcceptor)
|
||||
{
|
||||
if (((IEnergyAcceptor) adjacentTile).acceptsEnergyFrom(tileEntity, Direction.values()[(i + 2) % 6].getInverse()))
|
||||
{
|
||||
adjecentConnections.add(adjacentTile);
|
||||
}
|
||||
else
|
||||
{
|
||||
adjecentConnections.add(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
adjecentConnections.add(adjacentTile);
|
||||
}
|
||||
}
|
||||
else if (Compatibility.isBuildcraftLoaded() && adjacentTile instanceof IPowerReceptor)
|
||||
{
|
||||
adjecentConnections.add(adjacentTile);
|
||||
}
|
||||
else
|
||||
{
|
||||
adjecentConnections.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (adjecentConnections.toArray()[0] != null)
|
||||
{
|
||||
WIRE_MODEL.renderBottom();
|
||||
}
|
||||
|
||||
if (adjecentConnections.toArray()[1] != null)
|
||||
{
|
||||
WIRE_MODEL.renderTop();
|
||||
}
|
||||
|
||||
if (adjecentConnections.toArray()[2] != null)
|
||||
{
|
||||
WIRE_MODEL.renderBack();
|
||||
}
|
||||
|
||||
if (adjecentConnections.toArray()[3] != null)
|
||||
{
|
||||
WIRE_MODEL.renderFront();
|
||||
}
|
||||
|
||||
if (adjecentConnections.toArray()[4] != null)
|
||||
{
|
||||
WIRE_MODEL.renderLeft();
|
||||
}
|
||||
|
||||
if (adjecentConnections.toArray()[5] != null)
|
||||
{
|
||||
WIRE_MODEL.renderRight();
|
||||
}
|
||||
|
||||
WIRE_MODEL.renderMiddle();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.renderModelAt((TileEntityWire) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
}
|
|
@ -1,11 +1,15 @@
|
|||
package resonantinduction.wire;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.ResonantInduction;
|
||||
import resonantinduction.TabRI;
|
||||
import universalelectricity.prefab.block.BlockConductor;
|
||||
|
||||
/**
|
||||
|
@ -26,6 +30,7 @@ public class BlockWire extends BlockConductor
|
|||
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
Block.setBurnProperties(this.blockID, 30, 60);
|
||||
this.func_111022_d(ResonantInduction.PREFIX + "wire");
|
||||
this.setCreativeTab(TabRI.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,4 +68,14 @@ public class BlockWire extends BlockConductor
|
|||
{
|
||||
return new TileEntityWire();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < EnumWire.values().length - 1; i++)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
package resonantinduction.wire;
|
||||
|
||||
/**
|
||||
* An enumerator for different wire materials.
|
||||
* An enumerator for different wire materials. The metadata of the wire determines the type of the
|
||||
* wire.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
|
|
|
@ -47,9 +47,9 @@ public class ItemBlockWire extends ItemBlock
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
for (int i = 0; i < EnumWire.values().length - 1; i++)
|
||||
for (int i = 0; i < EnumWire.values().length; i++)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon(this.getUnlocalizedName(new ItemStack(this.itemID, 1, i)).replaceAll("tile.", ResonantInduction.PREFIX));
|
||||
this.icons[i] = iconRegister.registerIcon(this.getUnlocalizedName(new ItemStack(this.itemID, 1, i)).replaceAll("tile.", ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
|