Readded universal wires into Mekanism Induction
|
@ -7,11 +7,13 @@ import mekanism.induction.client.render.RenderBattery;
|
|||
import mekanism.induction.client.render.RenderEMContractor;
|
||||
import mekanism.induction.client.render.RenderMultimeter;
|
||||
import mekanism.induction.client.render.RenderTesla;
|
||||
import mekanism.induction.client.render.RenderWire;
|
||||
import mekanism.induction.common.InductionCommonProxy;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import mekanism.induction.common.tileentity.TileEntityMultimeter;
|
||||
import mekanism.induction.common.tileentity.TileEntityTesla;
|
||||
import mekanism.induction.common.tileentity.TileEntityWire;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -42,6 +44,7 @@ public class InductionClientProxy extends InductionCommonProxy
|
|||
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
|
||||
|
@ -61,6 +64,25 @@ public class InductionClientProxy extends InductionCommonProxy
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused()
|
||||
{
|
||||
if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic())
|
||||
{
|
||||
GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
|
||||
|
||||
if (screen != null)
|
||||
{
|
||||
if (screen.doesGuiPauseGame())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFancy()
|
||||
{
|
||||
|
|
|
@ -4,11 +4,9 @@ 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.MekanismInduction;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -26,7 +24,7 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
|
|||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
switch(((TileEntityEMContractor) t).getFacing())
|
||||
switch (((TileEntityEMContractor) t).getFacing())
|
||||
{
|
||||
case DOWN:
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
|
@ -52,19 +50,21 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
|
|||
break;
|
||||
}
|
||||
|
||||
if(((TileEntityEMContractor)t).suck)
|
||||
if (((TileEntityEMContractor) t).suck)
|
||||
{
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectromagneticContractor.png"));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectromagneticContractorOn.png"));
|
||||
}
|
||||
|
||||
if(((TileEntityEMContractor)t).canFunction() && !Mekanism.proxy.isPaused())
|
||||
if (((TileEntityEMContractor) t).canFunction() && !Mekanism.proxy.isPaused())
|
||||
{
|
||||
MODEL_SPIN.render(0.0625f);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
model.render(0.0625f);
|
||||
}
|
||||
|
||||
|
|
189
common/mekanism/induction/client/render/RenderPartWire.java
Normal file
|
@ -0,0 +1,189 @@
|
|||
package mekanism.induction.client.render;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import mekanism.induction.common.wire.PartConductor;
|
||||
import mekanism.induction.common.wire.PartWire;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import codechicken.lib.colour.Colour;
|
||||
import codechicken.lib.colour.ColourRGBA;
|
||||
import codechicken.lib.lighting.LightModel;
|
||||
import codechicken.lib.render.CCModel;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import codechicken.lib.render.ColourMultiplier;
|
||||
import codechicken.lib.render.IconTransformation;
|
||||
import codechicken.lib.render.TextureUtils;
|
||||
import codechicken.lib.vec.Rotation;
|
||||
import codechicken.lib.vec.SwapYZ;
|
||||
import codechicken.lib.vec.Translation;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author unpairedbracket
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderPartWire
|
||||
{
|
||||
private static final ResourceLocation WIRE_SHINE = new ResourceLocation(MekanismInduction.DOMAIN, MekanismInduction.MODEL_TEXTURE_DIRECTORY + "white.png");
|
||||
public static final Map<String, CCModel> models;
|
||||
public static final Map<String, CCModel> shinyModels;
|
||||
public static Icon wireIcon;
|
||||
public static Icon insulationIcon;
|
||||
public static Icon breakIcon;
|
||||
public static FloatBuffer location = BufferUtils.createFloatBuffer(4);
|
||||
public static FloatBuffer specular = BufferUtils.createFloatBuffer(4);
|
||||
public static FloatBuffer zero = BufferUtils.createFloatBuffer(4);
|
||||
public static FloatBuffer defaultAmbient = BufferUtils.createFloatBuffer(4);
|
||||
public static final RenderPartWire INSTANCE = new RenderPartWire();
|
||||
|
||||
static
|
||||
{
|
||||
models = CCModel.parseObjModels(new ResourceLocation("resonantinduction", "models/wire.obj"), 7, new SwapYZ());
|
||||
for (CCModel c : models.values())
|
||||
{
|
||||
c.apply(new Translation(.5, 0, .5));
|
||||
c.computeLighting(LightModel.standardLightModel);
|
||||
c.shrinkUVs(0.0005);
|
||||
}
|
||||
|
||||
shinyModels = CCModel.parseObjModels(new ResourceLocation("resonantinduction", "models/wireShine.obj"), 7, new SwapYZ());
|
||||
for (CCModel c : shinyModels.values())
|
||||
{
|
||||
c.apply(new Translation(.5, 0, .5));
|
||||
c.computeLighting(LightModel.standardLightModel);
|
||||
c.shrinkUVs(0.0005);
|
||||
}
|
||||
|
||||
loadBuffer(location, 0, 0, 0, 1);
|
||||
loadBuffer(specular, 1, 1, 1, 1);
|
||||
loadBuffer(zero, 0, 0, 0, 0);
|
||||
loadBuffer(defaultAmbient, 0.4F, 0.4F, 0.4F, 1);
|
||||
|
||||
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, zero);
|
||||
|
||||
GL11.glLight(GL11.GL_LIGHT3, GL11.GL_SPECULAR, specular);
|
||||
|
||||
GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, specular);
|
||||
GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, zero);
|
||||
GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, zero);
|
||||
GL11.glMaterialf(GL11.GL_FRONT, GL11.GL_SHININESS, 128f);
|
||||
|
||||
}
|
||||
|
||||
public static void loadBuffer(FloatBuffer buffer, float... src)
|
||||
{
|
||||
buffer.clear();
|
||||
buffer.put(src);
|
||||
buffer.flip();
|
||||
}
|
||||
|
||||
public void renderShine(PartWire wire, double x, double y, double z, float f)
|
||||
{
|
||||
if (wire != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_LIGHT0);
|
||||
GL11.glDisable(GL11.GL_LIGHT1);
|
||||
GL11.glEnable(GL11.GL_LIGHT3);
|
||||
GL11.glLight(GL11.GL_LIGHT3, GL11.GL_POSITION, location);
|
||||
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, zero);
|
||||
|
||||
CCRenderState.reset();
|
||||
CCRenderState.useNormals(true);
|
||||
CCRenderState.changeTexture(WIRE_SHINE);
|
||||
CCRenderState.startDrawing(7);
|
||||
renderSideShine(ForgeDirection.UNKNOWN, wire);
|
||||
byte renderSides = wire.getAllCurrentConnections();
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (PartConductor.connectionMapContainsSide(renderSides, side))
|
||||
renderSideShine(side, wire);
|
||||
}
|
||||
CCRenderState.draw();
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_LIGHT0);
|
||||
GL11.glEnable(GL11.GL_LIGHT1);
|
||||
GL11.glDisable(GL11.GL_LIGHT3);
|
||||
|
||||
GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, defaultAmbient);
|
||||
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerIcons(IconRegister iconReg)
|
||||
{
|
||||
wireIcon = iconReg.registerIcon("resonantinduction:models/wire");
|
||||
insulationIcon = iconReg.registerIcon("resonantinduction:models/insulation" + (MekanismInduction.LO_FI_INSULATION ? "tiny" : ""));
|
||||
breakIcon = iconReg.registerIcon("resonantinduction:wire");
|
||||
}
|
||||
|
||||
public void renderStatic(PartWire wire)
|
||||
{
|
||||
TextureUtils.bindAtlas(0);
|
||||
CCRenderState.reset();
|
||||
CCRenderState.useModelColours(true);
|
||||
CCRenderState.setBrightness(wire.world(), wire.x(), wire.y(), wire.z());
|
||||
renderSide(ForgeDirection.UNKNOWN, wire);
|
||||
byte renderSides = wire.getAllCurrentConnections();
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (PartConductor.connectionMapContainsSide(renderSides, side))
|
||||
renderSide(side, wire);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderSide(ForgeDirection side, PartWire wire)
|
||||
{
|
||||
String name = side.name().toLowerCase();
|
||||
name = name.equals("unknown") ? "center" : name;
|
||||
Vector3 materialColour = wire.getMaterial().color;
|
||||
Colour colour = new ColourRGBA(materialColour.x, materialColour.y, materialColour.z, 1);
|
||||
renderPart(wireIcon, models.get(name), wire.x(), wire.y(), wire.z(), colour);
|
||||
if (wire.isInsulated())
|
||||
{
|
||||
Vector3 vecColour = MekanismInduction.DYE_COLORS[wire.dyeID];
|
||||
Colour insulationColour = new ColourRGBA(vecColour.x, vecColour.y, vecColour.z, 1);
|
||||
renderPart(insulationIcon, models.get(name + "Insulation"), wire.x(), wire.y(), wire.z(), insulationColour);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderSideShine(ForgeDirection side, PartWire wire)
|
||||
{
|
||||
String name = side.name().toLowerCase();
|
||||
name = name.equals("unknown") ? "center" : name;
|
||||
Vector3 materialColour = wire.getMaterial().color;
|
||||
renderPartShine(shinyModels.get(name));
|
||||
}
|
||||
|
||||
public void renderPart(Icon icon, CCModel cc, double x, double y, double z, Colour colour)
|
||||
{
|
||||
cc.render(0, cc.verts.length, Rotation.sideOrientation(0, Rotation.rotationTo(0, 2)).at(codechicken.lib.vec.Vector3.center).with(new Translation(x, y, z)), new IconTransformation(icon), new ColourMultiplier(colour));
|
||||
}
|
||||
|
||||
public void renderPartShine(CCModel cc)
|
||||
{
|
||||
cc.render(null, 0, 0);
|
||||
}
|
||||
}
|
136
common/mekanism/induction/client/render/RenderWire.java
Normal file
|
@ -0,0 +1,136 @@
|
|||
package mekanism.induction.client.render;
|
||||
|
||||
import mekanism.induction.client.model.ModelInsulation;
|
||||
import mekanism.induction.client.model.ModelWire;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import mekanism.induction.common.tileentity.TileEntityWire;
|
||||
import mekanism.induction.common.wire.EnumWireMaterial;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* TODO: Use ISBRH.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderWire extends TileEntitySpecialRenderer
|
||||
{
|
||||
private static final ResourceLocation WIRE_TEXTURE = new ResourceLocation(MekanismInduction.DOMAIN, MekanismInduction.MODEL_TEXTURE_DIRECTORY + "wire.png");
|
||||
private static final ResourceLocation INSULATION_TEXTURE = new ResourceLocation(MekanismInduction.DOMAIN, MekanismInduction.MODEL_TEXTURE_DIRECTORY + "insulation.png");
|
||||
public static final ModelWire WIRE_MODEL = new ModelWire();
|
||||
public static final ModelInsulation INSULATION_MODEL = new ModelInsulation();
|
||||
|
||||
public void renderModelAt(TileEntityWire tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
if (tileEntity != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glScalef(1, -1, -1);
|
||||
|
||||
EnumWireMaterial material = tileEntity.getMaterial();
|
||||
// Texture file
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(WIRE_TEXTURE);
|
||||
GL11.glColor4d(material.color.x, material.color.y, material.color.z, 1);
|
||||
|
||||
tileEntity.adjacentConnections = null;
|
||||
TileEntity[] adjacentConnections = tileEntity.getAdjacentConnections();
|
||||
|
||||
if (adjacentConnections != null)
|
||||
{
|
||||
if (adjacentConnections[0] != null)
|
||||
{
|
||||
WIRE_MODEL.renderBottom();
|
||||
}
|
||||
|
||||
if (adjacentConnections[1] != null)
|
||||
{
|
||||
WIRE_MODEL.renderTop();
|
||||
}
|
||||
|
||||
if (adjacentConnections[2] != null)
|
||||
{
|
||||
WIRE_MODEL.renderBack();
|
||||
}
|
||||
|
||||
if (adjacentConnections[3] != null)
|
||||
{
|
||||
WIRE_MODEL.renderFront();
|
||||
}
|
||||
|
||||
if (adjacentConnections[4] != null)
|
||||
{
|
||||
WIRE_MODEL.renderLeft();
|
||||
}
|
||||
|
||||
if (adjacentConnections[5] != null)
|
||||
{
|
||||
WIRE_MODEL.renderRight();
|
||||
}
|
||||
}
|
||||
|
||||
WIRE_MODEL.renderMiddle();
|
||||
|
||||
if (tileEntity.isInsulated)
|
||||
{
|
||||
// Texture file
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(INSULATION_TEXTURE);
|
||||
Vector3 insulationColor = MekanismInduction.DYE_COLORS[tileEntity.dyeID];
|
||||
GL11.glColor4d(insulationColor.x, insulationColor.y, insulationColor.z, 1);
|
||||
|
||||
if (adjacentConnections != null)
|
||||
{
|
||||
if (adjacentConnections[0] != null)
|
||||
{
|
||||
INSULATION_MODEL.renderBottom(0.0625f);
|
||||
}
|
||||
|
||||
if (adjacentConnections[1] != null)
|
||||
{
|
||||
INSULATION_MODEL.renderTop(0.0625f);
|
||||
}
|
||||
|
||||
if (adjacentConnections[2] != null)
|
||||
{
|
||||
INSULATION_MODEL.renderBack(0.0625f);
|
||||
}
|
||||
|
||||
if (adjacentConnections[3] != null)
|
||||
{
|
||||
INSULATION_MODEL.renderFront(0.0625f);
|
||||
}
|
||||
|
||||
if (adjacentConnections[4] != null)
|
||||
{
|
||||
INSULATION_MODEL.renderLeft(0.0625f);
|
||||
}
|
||||
|
||||
if (adjacentConnections[5] != null)
|
||||
{
|
||||
INSULATION_MODEL.renderRight(0.0625f);
|
||||
}
|
||||
}
|
||||
|
||||
INSULATION_MODEL.renderMiddle(0.0625f);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.renderModelAt((TileEntityWire) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.generators.common.MekanismGenerators;
|
||||
import mekanism.induction.common.inventory.container.ContainerBattery;
|
||||
import mekanism.induction.common.inventory.container.ContainerMultimeter;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
|
@ -23,12 +22,10 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
|||
*/
|
||||
public class InductionCommonProxy implements IGuiHandler
|
||||
{
|
||||
public void registerRenderers() {}
|
||||
|
||||
public void loadConfiguration()
|
||||
public void registerRenderers()
|
||||
{
|
||||
Mekanism.configuration.load();
|
||||
MekanismInduction.FURNACE_WATTAGE = (float)Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage Per Tick", MekanismInduction.FURNACE_WATTAGE).getDouble(MekanismInduction.FURNACE_WATTAGE);
|
||||
MekanismInduction.FURNACE_WATTAGE = (float) Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage Per Tick", MekanismInduction.FURNACE_WATTAGE).getDouble(MekanismInduction.FURNACE_WATTAGE);
|
||||
MekanismInduction.MAX_CONTRACTOR_DISTANCE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MekanismInduction.MAX_CONTRACTOR_DISTANCE).getInt(MekanismInduction.MAX_CONTRACTOR_DISTANCE);
|
||||
|
||||
TileEntityEMContractor.ACCELERATION = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", TileEntityEMContractor.ACCELERATION).getDouble(TileEntityEMContractor.ACCELERATION);
|
||||
|
@ -61,6 +58,11 @@ public class InductionCommonProxy implements IGuiHandler
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean isPaused()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b, boolean split)
|
||||
{
|
||||
|
||||
|
@ -68,31 +70,33 @@ public class InductionCommonProxy implements IGuiHandler
|
|||
|
||||
public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b)
|
||||
{
|
||||
renderElectricShock(world, start, target, r, g, b, true);
|
||||
this.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);
|
||||
this.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);
|
||||
this.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);
|
||||
this.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);
|
||||
this.renderElectricShock(world, start, target, 0.55f, 0.7f, 1f, b);
|
||||
|
||||
}
|
||||
|
||||
public boolean isFancy()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import ic2.api.item.Items;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.common.IModule;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismRecipe;
|
||||
|
@ -10,25 +14,33 @@ import mekanism.induction.common.block.BlockBattery;
|
|||
import mekanism.induction.common.block.BlockEMContractor;
|
||||
import mekanism.induction.common.block.BlockMultimeter;
|
||||
import mekanism.induction.common.block.BlockTesla;
|
||||
import mekanism.induction.common.block.BlockWire;
|
||||
import mekanism.induction.common.item.ItemBlockContractor;
|
||||
import mekanism.induction.common.item.ItemBlockMultimeter;
|
||||
import mekanism.induction.common.item.ItemBlockWire;
|
||||
import mekanism.induction.common.item.ItemLinker;
|
||||
import mekanism.induction.common.tileentity.TileEntityBattery;
|
||||
import mekanism.induction.common.tileentity.TileEntityEMContractor;
|
||||
import mekanism.induction.common.tileentity.TileEntityMultimeter;
|
||||
import mekanism.induction.common.tileentity.TileEntityTesla;
|
||||
import mekanism.induction.common.tileentity.TileEntityWire;
|
||||
import mekanism.induction.common.wire.EnumWireMaterial;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import universalelectricity.compatibility.Compatibility;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import calclavia.lib.UniversalRecipes;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
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.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
|
@ -50,8 +62,26 @@ public class MekanismInduction implements IModule
|
|||
/** MekanismInduction version number */
|
||||
public static Version versionNumber = new Version(5, 6, 0);
|
||||
|
||||
//Settings
|
||||
/**
|
||||
* Directory Information
|
||||
*/
|
||||
public static final String DOMAIN = "mekanism";
|
||||
public static final String PREFIX = DOMAIN + ":";
|
||||
public static final String DIRECTORY = "/assets/" + DOMAIN + "/";
|
||||
public static final String TEXTURE_DIRECTORY = "textures/";
|
||||
public static final String GUI_DIRECTORY = "gui/";
|
||||
public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/";
|
||||
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/";
|
||||
public static final String MODEL_TEXTURE_DIRECTORY = "render/";
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*/
|
||||
public static float FURNACE_WATTAGE = 10;
|
||||
public static boolean SOUND_FXS = true;
|
||||
public static boolean LO_FI_INSULATION = false;
|
||||
public static boolean SHINY_SILVER = true;
|
||||
public static boolean REPLACE_FURNACE = true;
|
||||
|
||||
/** Block ID by Jyzarc */
|
||||
private static final int BLOCK_ID_PREFIX = 3200;
|
||||
|
@ -72,14 +102,18 @@ public class MekanismInduction implements IModule
|
|||
return NEXT_ITEM_ID++;
|
||||
}
|
||||
|
||||
//Items
|
||||
// Items
|
||||
public static Item Linker;
|
||||
/** With Forge Multipart; Use EnumWireMaterial reference. **/
|
||||
private static Item itemPartWire;
|
||||
|
||||
//Blocks
|
||||
// Blocks
|
||||
public static Block Tesla;
|
||||
public static Block Multimeter;
|
||||
public static Block ElectromagneticContractor;
|
||||
public static Block Battery;
|
||||
/** Without Forge Multipart **/
|
||||
private static Block blockWire;
|
||||
public static Block blockAdvancedFurnaceIdle, blockAdvancedFurnaceBurning;
|
||||
|
||||
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) };
|
||||
|
@ -91,15 +125,56 @@ public class MekanismInduction implements IModule
|
|||
MinecraftForge.EVENT_BUS.register(new MultimeterEventHandler());
|
||||
Mekanism.configuration.load();
|
||||
|
||||
//Items
|
||||
Linker = new ItemLinker(Mekanism.configuration.get(Configuration.CATEGORY_ITEM, "Linker", getNextItemID()).getInt()).setUnlocalizedName("Linker");
|
||||
// Config
|
||||
FURNACE_WATTAGE = (float) Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage", FURNACE_WATTAGE).getDouble(FURNACE_WATTAGE) / 20;
|
||||
SOUND_FXS = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS);
|
||||
LO_FI_INSULATION = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Use lo-fi insulation texture", LO_FI_INSULATION).getBoolean(LO_FI_INSULATION);
|
||||
SHINY_SILVER = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Shiny silver wires", SHINY_SILVER).getBoolean(SHINY_SILVER);
|
||||
MAX_CONTRACTOR_DISTANCE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE);
|
||||
REPLACE_FURNACE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Replace vanilla furnace", REPLACE_FURNACE).getBoolean(REPLACE_FURNACE);
|
||||
|
||||
//Blocks
|
||||
TileEntityEMContractor.ACCELERATION = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", TileEntityEMContractor.ACCELERATION).getDouble(TileEntityEMContractor.ACCELERATION);
|
||||
TileEntityEMContractor.MAX_REACH = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", TileEntityEMContractor.MAX_REACH).getInt(TileEntityEMContractor.MAX_REACH);
|
||||
TileEntityEMContractor.MAX_SPEED = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Speed", TileEntityEMContractor.MAX_SPEED).getDouble(TileEntityEMContractor.MAX_SPEED);
|
||||
TileEntityEMContractor.PUSH_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Contractor Item Push Delay", TileEntityEMContractor.PUSH_DELAY).getInt(TileEntityEMContractor.PUSH_DELAY);
|
||||
|
||||
// Items
|
||||
Linker = new ItemLinker(Mekanism.configuration.get(Mekanism.configuration.CATEGORY_ITEM, "Linker", getNextItemID()).getInt()).setUnlocalizedName("Linker");
|
||||
|
||||
if (Loader.isModLoaded("ForgeMultipart"))
|
||||
{
|
||||
try
|
||||
{
|
||||
itemPartWire = (Item) Class.forName("resonantinduction.wire.multipart.ItemPartWire").getConstructor(Integer.TYPE).newInstance(getNextItemID());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Mekanism.logger.severe("Failed to load multipart wire.");
|
||||
}
|
||||
}
|
||||
|
||||
// Blocks
|
||||
Tesla = new BlockTesla(Mekanism.configuration.getBlock("Tesla", getNextBlockID()).getInt()).setUnlocalizedName("Tesla");
|
||||
Multimeter = new BlockMultimeter(Mekanism.configuration.getBlock("Multimeter", getNextBlockID()).getInt()).setUnlocalizedName("Multimeter");
|
||||
ElectromagneticContractor = new BlockEMContractor(Mekanism.configuration.getBlock("ElectromagneticContractor", getNextBlockID()).getInt()).setUnlocalizedName("ElectromagneticContractor");
|
||||
Battery = new BlockBattery(Mekanism.configuration.getBlock("Battery", getNextBlockID()).getInt()).setUnlocalizedName("Battery");
|
||||
|
||||
if (itemPartWire == null)
|
||||
{
|
||||
blockWire = new BlockWire(getNextBlockID());
|
||||
}
|
||||
|
||||
if (REPLACE_FURNACE)
|
||||
{
|
||||
blockAdvancedFurnaceIdle = BlockAdvancedFurnace.createNew(false);
|
||||
blockAdvancedFurnaceBurning = BlockAdvancedFurnace.createNew(true);
|
||||
|
||||
GameRegistry.registerBlock(blockAdvancedFurnaceIdle, "ri_" + blockAdvancedFurnaceIdle.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(blockAdvancedFurnaceBurning, "ri_" + blockAdvancedFurnaceBurning.getUnlocalizedName() + "2");
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityAdvancedFurnace.class, blockAdvancedFurnaceIdle.getUnlocalizedName());
|
||||
}
|
||||
|
||||
Mekanism.configuration.save();
|
||||
|
||||
GameRegistry.registerItem(Linker, "Linker");
|
||||
|
@ -109,13 +184,39 @@ public class MekanismInduction implements IModule
|
|||
GameRegistry.registerBlock(ElectromagneticContractor, ItemBlockContractor.class, "ElectromagneticContractor");
|
||||
GameRegistry.registerBlock(Battery, "Battery");
|
||||
|
||||
//Tiles
|
||||
// Tiles
|
||||
if (blockWire != null)
|
||||
{
|
||||
GameRegistry.registerBlock(blockWire, ItemBlockWire.class, blockWire.getUnlocalizedName());
|
||||
}
|
||||
|
||||
// Tiles
|
||||
GameRegistry.registerTileEntity(TileEntityTesla.class, "Tesla");
|
||||
GameRegistry.registerTileEntity(TileEntityMultimeter.class, "Multimeter");
|
||||
GameRegistry.registerTileEntity(TileEntityEMContractor.class, "ElectromagneticContractor");
|
||||
GameRegistry.registerTileEntity(TileEntityBattery.class, "Battery");
|
||||
|
||||
if (blockWire != null)
|
||||
{
|
||||
GameRegistry.registerTileEntity(TileEntityWire.class, blockWire.getUnlocalizedName());
|
||||
}
|
||||
|
||||
MekanismInduction.proxy.registerRenderers();
|
||||
|
||||
if (itemPartWire != null)
|
||||
{
|
||||
for (EnumWireMaterial material : EnumWireMaterial.values())
|
||||
{
|
||||
material.setWire(itemPartWire);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (EnumWireMaterial material : EnumWireMaterial.values())
|
||||
{
|
||||
material.setWire(blockWire);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -124,26 +225,102 @@ public class MekanismInduction implements IModule
|
|||
// Add this module to the core list
|
||||
Mekanism.modulesLoaded.add(this);
|
||||
|
||||
if (itemPartWire != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("mekanism.induction.common..MultipartMI").newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
Mekanism.logger.severe("Failed to initiate Resonant Induction multipart module.");
|
||||
}
|
||||
}
|
||||
|
||||
Compatibility.initiate();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent evt)
|
||||
{
|
||||
|
||||
/**
|
||||
* Recipes
|
||||
*/
|
||||
final ItemStack defaultWire = EnumWireMaterial.IRON.getWire();
|
||||
|
||||
/** Linker **/
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(Linker), new Object[] {" E ", "GCG", " E ", 'E', Item.eyeOfEnder, 'C', Mekanism.EnergyTablet.getUnchargedItem(), 'G', "ingotOsmium"}));
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(Linker), new Object[] { " E ", "GCG", " E ", 'E', Item.eyeOfEnder, 'C', Mekanism.EnergyTablet.getUnchargedItem(), 'G', "ingotOsmium" }));
|
||||
|
||||
/** Tesla - by Jyzarc */
|
||||
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(Tesla), new Object[] { "WEW", " C ", " I ", 'W', Mekanism.EnrichedAlloy, 'E', Item.eyeOfEnder, 'C', Mekanism.EnergyTablet.getUnchargedItem(), 'I', new ItemStack(Mekanism.BasicBlock, 1, 8) }));
|
||||
|
||||
/** Multimeter */
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(Multimeter), new Object[] {"WWW", "ICI", 'W', Mekanism.EnrichedAlloy, 'C', Mekanism.EnergyTablet.getUnchargedItem(), 'I', "ingotSteel"}));
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(Multimeter), new Object[] { "WWW", "ICI", 'W', Mekanism.EnrichedAlloy, 'C', "battery", 'I', "ingotSteel" }));
|
||||
|
||||
/** Battery */
|
||||
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(Battery, 4), new Object[] { "RRR", "CIC", "RRR", 'R', Item.redstone, 'I', MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), 'C', "circuitBasic" }));
|
||||
|
||||
/** EM Contractor */
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(ElectromagneticContractor), new Object[] {" I ", "GCG", "WWW", 'W', "ingotSteel", 'C', Mekanism.EnergyTablet.getUnchargedItem(), 'G', "ingotOsmium", 'I', "ingotSteel"}));
|
||||
GameRegistry.addRecipe(new MekanismRecipe(new ItemStack(ElectromagneticContractor), new Object[] { " I ", "GCG", "WWW", 'W', "ingotSteel", 'C', Mekanism.EnergyTablet.getUnchargedItem(), 'G', "ingotOsmium", 'I', "ingotSteel" }));
|
||||
|
||||
/** Wires **/
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.COPPER.getWire(3), "MMM", 'M', "ingotCopper"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.TIN.getWire(3), "MMM", 'M', "ingotTin"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.IRON.getWire(3), "MMM", 'M', Item.ingotIron));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.ALUMINUM.getWire(3), "MMM", 'M', "ingotAluminum"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SILVER.getWire(), "MMM", 'M', "ingotSilver"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", 'M', "ingotSuperconductor"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", "MEM", "MMM", 'M', Item.ingotGold, 'E', Item.eyeOfEnder));
|
||||
|
||||
/** Wire Compatiblity **/
|
||||
if (Loader.isModLoaded("IC2"))
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.COPPER.getWire(), Items.getItem("copperCableItem")));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.TIN.getWire(), Items.getItem("tinCableItem")));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.IRON.getWire(), Items.getItem("ironCableItem")));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(), Items.getItem("glassFiberCableItem")));
|
||||
}
|
||||
|
||||
if (Loader.isModLoaded("Mekanism"))
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.COPPER.getWire(), "universalCable"));
|
||||
}
|
||||
|
||||
if (REPLACE_FURNACE)
|
||||
{
|
||||
/** Inject new furnace tile class */
|
||||
replaceTileEntity(TileEntityFurnace.class, TileEntityAdvancedFurnace.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static void replaceTileEntity(Class<? extends TileEntity> findTile, Class<? extends TileEntity> replaceTile)
|
||||
{
|
||||
try
|
||||
{
|
||||
Map<String, Class> nameToClassMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_a", "nameToClassMap", "a");
|
||||
Map<Class, String> classToNameMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_b", "classToNameMap", "b");
|
||||
|
||||
String findTileID = classToNameMap.get(findTile);
|
||||
|
||||
if (findTileID != null)
|
||||
{
|
||||
nameToClassMap.put(findTileID, replaceTile);
|
||||
classToNameMap.put(replaceTile, findTileID);
|
||||
classToNameMap.remove(findTile);
|
||||
Mekanism.logger.fine("Replaced TileEntity: " + findTile);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mekanism.logger.severe("Failed to replace TileEntity: " + findTile);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Mekanism.logger.severe("Failed to replace TileEntity: " + findTile);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
36
common/mekanism/induction/common/MultipartMI.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package mekanism.induction.common;
|
||||
|
||||
import mekanism.induction.common.wire.EnumWireMaterial;
|
||||
import mekanism.induction.common.wire.PartWire;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.MultipartGenerator;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
public class MultipartMI implements IPartFactory
|
||||
{
|
||||
|
||||
public MultipartMI()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart createPart(String name, boolean client)
|
||||
{
|
||||
if (name == "resonant_induction_wire")
|
||||
return new PartWire(EnumWireMaterial.COPPER.ordinal());
|
||||
return null;
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_wire" });
|
||||
MultipartGenerator.registerPassThroughInterface("universalelectricity.core.block.IConductor");
|
||||
MultipartGenerator.registerPassThroughInterface("buildcraft.api.power.IPowerReceptor");
|
||||
MultipartGenerator.registerPassThroughInterface("resonantinduction.wire.IInsulatedMaterial");
|
||||
MultipartGenerator.registerPassThroughInterface("resonantinduction.wire.multipart.IBlockableConnection");
|
||||
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.multipart.javatraits.TEnergySink");
|
||||
}
|
||||
|
||||
}
|
137
common/mekanism/induction/common/block/BlockWire.java
Normal file
|
@ -0,0 +1,137 @@
|
|||
package mekanism.induction.common.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import mekanism.induction.common.tileentity.TileEntityWire;
|
||||
import mekanism.induction.common.wire.EnumWireMaterial;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.prefab.block.BlockConductor;
|
||||
|
||||
/**
|
||||
* A copper wire block that can change its collision bounds based on the connection.
|
||||
*
|
||||
* @author Calclavia, Aidancbrady
|
||||
*/
|
||||
public class BlockWire extends BlockConductor
|
||||
{
|
||||
public BlockWire(int id)
|
||||
{
|
||||
super(MekanismInduction.CONFIGURATION.getBlock("wire", id).getInt(id), Material.cloth);
|
||||
this.setUnlocalizedName(MekanismInduction.PREFIX + "wire");
|
||||
this.setStepSound(soundClothFootstep);
|
||||
this.setResistance(0.2F);
|
||||
this.setHardness(0.1f);
|
||||
this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f);
|
||||
this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
Block.setBurnProperties(this.blockID, 30, 60);
|
||||
this.setTextureName(MekanismInduction.PREFIX + "wire");
|
||||
this.setCreativeTab(Mekanism.tabMekanism);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
TileEntity t = world.getBlockTileEntity(x, y, z);
|
||||
TileEntityWire tileEntity = (TileEntityWire) t;
|
||||
|
||||
if (entityPlayer.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if (entityPlayer.getCurrentEquippedItem().itemID == Item.dyePowder.itemID)
|
||||
{
|
||||
tileEntity.setDye(entityPlayer.getCurrentEquippedItem().getItemDamage());
|
||||
return true;
|
||||
}
|
||||
else if (entityPlayer.getCurrentEquippedItem().itemID == Block.cloth.blockID && !tileEntity.isInsulated)
|
||||
{
|
||||
tileEntity.setInsulated();
|
||||
tileEntity.setDye(BlockColored.getDyeFromBlock(entityPlayer.getCurrentEquippedItem().getItemDamage()));
|
||||
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the
|
||||
* shared face of two adjacent blocks and also whether the player can attach torches, redstone
|
||||
* wire, etc to this block.
|
||||
*/
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs,
|
||||
* buttons, stairs, etc)
|
||||
*/
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
return new TileEntityWire();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < EnumWireMaterial.values().length; i++)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
|
||||
{
|
||||
TileEntity t = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
/**
|
||||
* Drop wool insulation if the wire is insulated.
|
||||
*/
|
||||
if (t instanceof TileEntityWire)
|
||||
{
|
||||
TileEntityWire tileEntity = (TileEntityWire) t;
|
||||
|
||||
if (tileEntity.isInsulated)
|
||||
{
|
||||
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(tileEntity.dyeID)));
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, par5, par6);
|
||||
}
|
||||
}
|
62
common/mekanism/induction/common/item/ItemBlockWire.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package mekanism.induction.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.induction.common.wire.EnumWireMaterial;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBlockWire extends ItemBlock
|
||||
{
|
||||
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
|
||||
|
||||
public ItemBlockWire(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return this.getUnlocalizedName() + "." + EnumWireMaterial.values()[itemStack.getItemDamage()].name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Resistance: " + ElectricityDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].resistance, ElectricUnit.RESISTANCE));
|
||||
par3List.add("Max Amperage: " + ElectricityDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].maxAmps, ElectricUnit.AMPERE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
for (int i = 0; i < EnumWireMaterial.values().length; i++)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon(this.getUnlocalizedName(new ItemStack(this.itemID, 1, i)).replaceAll("tile.", ""));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int meta)
|
||||
{
|
||||
return this.icons[meta];
|
||||
}
|
||||
}
|
206
common/mekanism/induction/common/tileentity/TileEntityWire.java
Normal file
|
@ -0,0 +1,206 @@
|
|||
package mekanism.induction.common.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.common.ITileNetwork;
|
||||
import mekanism.induction.common.wire.EnumWireMaterial;
|
||||
import mekanism.induction.common.wire.IInsulatedMaterial;
|
||||
import mekanism.induction.common.wire.IInsulation;
|
||||
import mekanism.induction.common.wire.IWireMaterial;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.compatibility.Compatibility;
|
||||
import universalelectricity.compatibility.TileEntityUniversalConductor;
|
||||
import universalelectricity.core.block.INetworkProvider;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityWire extends TileEntityUniversalConductor implements ITileNetwork, IInsulatedMaterial
|
||||
{
|
||||
public static final int DEFAULT_COLOR = 16;
|
||||
public int dyeID = DEFAULT_COLOR;
|
||||
public boolean isInsulated = false;
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
if (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 connectPos = new Vector3(this).modifyPositionFromSide(direction);
|
||||
TileEntity connectTile = connectPos.getTileEntity(this.worldObj);
|
||||
if (connectTile instanceof IWireMaterial)
|
||||
{
|
||||
IWireMaterial wireTile = (IWireMaterial) connectTile;
|
||||
|
||||
if (wireTile.getMaterial() != this.getMaterial())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isInsulated() && connectTile instanceof IInsulation)
|
||||
{
|
||||
IInsulation insulatedTile = (IInsulation) connectTile;
|
||||
|
||||
if ((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != this.getInsulationColor() && this.getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.adjacentConnections = null;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (this.canConnect(side.getOpposite()))
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), side);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (/* tileEntity.getClass().isInstance(this) && */tileEntity instanceof INetworkProvider)
|
||||
{
|
||||
this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.getNetwork().refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getResistance()
|
||||
{
|
||||
return getMaterial().resistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCurrentCapacity()
|
||||
{
|
||||
return getMaterial().maxAmps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWireMaterial getMaterial()
|
||||
{
|
||||
return EnumWireMaterial.values()[this.getTypeID()];
|
||||
}
|
||||
|
||||
public int getTypeID()
|
||||
{
|
||||
return this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dyeID
|
||||
*/
|
||||
public void setDye(int dyeID)
|
||||
{
|
||||
this.dyeID = dyeID;
|
||||
this.refresh();
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
public void setInsulated()
|
||||
{
|
||||
this.isInsulated = true;
|
||||
this.refresh();
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
data.add(isInsulated);
|
||||
data.add(dyeID);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.isInsulated = input.readBoolean();
|
||||
this.dyeID = input.readInt();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.dyeID = nbt.getInteger("dyeID");
|
||||
this.isInsulated = nbt.getBoolean("isInsulated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("dyeID", this.dyeID);
|
||||
nbt.setBoolean("isInsulated", this.isInsulated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider)
|
||||
{
|
||||
this.buildcraftBuffer = Compatibility.BC3_RATIO * 25 * this.getMaterial().maxAmps;
|
||||
this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2);
|
||||
super.doWork(workProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsulated()
|
||||
{
|
||||
return isInsulated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsulated(boolean insulated)
|
||||
{
|
||||
if (insulated && !isInsulated())
|
||||
setInsulated();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInsulationColor()
|
||||
{
|
||||
return dyeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsulationColor(int dyeID)
|
||||
{
|
||||
setDye(dyeID);
|
||||
}
|
||||
}
|
69
common/mekanism/induction/common/wire/EnumWireMaterial.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
/**
|
||||
* An enumerator for different wire materials. The metadata of the wire determines the type of the
|
||||
* wire.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
|
||||
public enum EnumWireMaterial
|
||||
{
|
||||
COPPER(12.5f, 3, 2, new Vector3(184, 115, 51)), TIN(13, 2, 0.5f, new Vector3(132, 132, 130)),
|
||||
IRON(0.1f, 2, 4, new Vector3(97, 102, 105)),
|
||||
ALUMINUM(0.025f, 6, 0.15f, new Vector3(215, 205, 181)),
|
||||
SILVER(0.005f, 1, 2, new Vector3(192, 192, 192)),
|
||||
SUPERCONDUCTOR(0, 8, Float.MAX_VALUE, new Vector3(212, 175, 55));
|
||||
|
||||
public final float resistance;
|
||||
public final float damage;
|
||||
public final float maxAmps;
|
||||
public final Vector3 color;
|
||||
private ItemStack wire;
|
||||
|
||||
EnumWireMaterial(float resistance, float electrocutionDamage, float maxAmps, Vector3 color)
|
||||
{
|
||||
this.resistance = resistance;
|
||||
this.damage = electrocutionDamage;
|
||||
this.maxAmps = maxAmps;
|
||||
this.color = color.scale(1D / 255D);
|
||||
}
|
||||
|
||||
public ItemStack getWire()
|
||||
{
|
||||
return this.getWire(1);
|
||||
}
|
||||
|
||||
public ItemStack getWire(int amount)
|
||||
{
|
||||
ItemStack returnStack = this.wire.copy();
|
||||
returnStack.stackSize = amount;
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public void setWire(ItemStack item)
|
||||
{
|
||||
if (this.wire == null)
|
||||
{
|
||||
this.wire = item;
|
||||
OreDictionary.registerOre(this.name().toLowerCase() + "Wire", this.wire);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWire(Item item)
|
||||
{
|
||||
this.setWire(new ItemStack(item, 1, this.ordinal()));
|
||||
}
|
||||
|
||||
public void setWire(Block block)
|
||||
{
|
||||
this.setWire(new ItemStack(block, 1, this.ordinal()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IBlockableConnection
|
||||
{
|
||||
public boolean isBlockedOnSide(ForgeDirection side);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
public interface IInsulatedMaterial extends IInsulation, IWireMaterial
|
||||
{
|
||||
|
||||
}
|
12
common/mekanism/induction/common/wire/IInsulation.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
public interface IInsulation
|
||||
{
|
||||
public boolean isInsulated();
|
||||
|
||||
public void setInsulated(boolean insulated);
|
||||
|
||||
public int getInsulationColor();
|
||||
|
||||
public void setInsulationColor(int dyeID);
|
||||
}
|
6
common/mekanism/induction/common/wire/IWireMaterial.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
public interface IWireMaterial
|
||||
{
|
||||
public EnumWireMaterial getMaterial();
|
||||
}
|
103
common/mekanism/induction/common/wire/ItemPartWire.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.induction.client.render.RenderPartWire;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.multipart.JItemMultiPart;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemPartWire extends JItemMultiPart
|
||||
{
|
||||
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
|
||||
|
||||
public ItemPartWire(int id)
|
||||
{
|
||||
super(Mekanism.configuration.get(Configuration.CATEGORY_ITEM, "wireMultipart", id).getInt(id));
|
||||
this.setUnlocalizedName(MekanismInduction.PREFIX + "wire");
|
||||
this.setCreativeTab(Mekanism.tabMekanism);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart newPart(ItemStack arg0, EntityPlayer arg1, World arg2, BlockCoord arg3, int arg4, Vector3 arg5)
|
||||
{
|
||||
return new PartWire(this.getDamage(arg0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return super.getUnlocalizedName().replace("item", "tile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return this.getUnlocalizedName() + "." + EnumWireMaterial.values()[itemStack.getItemDamage()].name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Resistance: " + ElectricityDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].resistance, ElectricUnit.RESISTANCE));
|
||||
par3List.add("Max Amperage: " + ElectricityDisplay.getDisplay(EnumWireMaterial.values()[itemstack.getItemDamage()].maxAmps, ElectricUnit.AMPERE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
for (int i = 0; i < EnumWireMaterial.values().length; i++)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon(this.getUnlocalizedName(new ItemStack(this.itemID, 1, i)).replaceAll("tile.", ""));
|
||||
}
|
||||
|
||||
RenderPartWire.registerIcons(iconRegister);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int meta)
|
||||
{
|
||||
return this.icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
|
||||
{
|
||||
for (EnumWireMaterial mat : EnumWireMaterial.values())
|
||||
{
|
||||
listToAddTo.add(new ItemStack(itemID, 1, mat.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
39
common/mekanism/induction/common/wire/PartAdvanced.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.handler.MultipartProxy;
|
||||
|
||||
public abstract class PartAdvanced extends TMultiPart
|
||||
{
|
||||
protected long ticks = 0;
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (this.ticks == 0)
|
||||
{
|
||||
this.initiate();
|
||||
}
|
||||
|
||||
if (this.ticks >= Long.MAX_VALUE)
|
||||
{
|
||||
this.ticks = 1;
|
||||
}
|
||||
|
||||
this.ticks++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
world().notifyBlocksOfNeighborChange(x(), y(), z(), ((Block) MultipartProxy.block()).blockID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on the TileEntity's first tick.
|
||||
*/
|
||||
public void initiate()
|
||||
{
|
||||
}
|
||||
}
|
243
common/mekanism/induction/common/wire/PartConductor.java
Normal file
|
@ -0,0 +1,243 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.block.IConnector;
|
||||
import universalelectricity.core.block.INetworkProvider;
|
||||
import universalelectricity.core.electricity.NetworkLoader;
|
||||
import universalelectricity.core.grid.IElectricityNetwork;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
|
||||
public abstract class PartConductor extends PartAdvanced implements IConductor
|
||||
{
|
||||
private IElectricityNetwork network;
|
||||
|
||||
public TileEntity[] adjacentConnections = null;
|
||||
public byte currentWireConnections = 0x00;
|
||||
public byte currentAcceptorConnections = 0x00;
|
||||
|
||||
public byte getAllCurrentConnections()
|
||||
{
|
||||
return (byte) (currentWireConnections | currentAcceptorConnections);
|
||||
}
|
||||
|
||||
public static boolean connectionMapContainsSide(byte connections, ForgeDirection side)
|
||||
{
|
||||
byte tester = (byte) (1 << side.ordinal());
|
||||
return ((connections & tester) > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(TileMultipart t)
|
||||
{
|
||||
if (tile() != null && network != null)
|
||||
{
|
||||
this.getNetwork().getConductors().remove(tile());
|
||||
super.bind(t);
|
||||
this.getNetwork().getConductors().add((IConductor) tile());
|
||||
}
|
||||
else
|
||||
{
|
||||
super.bind(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRemove()
|
||||
{
|
||||
if (!this.world().isRemote && this.tile() instanceof IConductor)
|
||||
{
|
||||
this.getNetwork().split((IConductor) this.tile());
|
||||
}
|
||||
|
||||
super.preRemove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesTick()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElectricityNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null && this.tile() instanceof IConductor)
|
||||
{
|
||||
this.setNetwork(NetworkLoader.getNewNetwork((IConductor) this.tile()));
|
||||
}
|
||||
|
||||
return this.network;
|
||||
}
|
||||
|
||||
public boolean canConnectBothSides(TileEntity tile, ForgeDirection side)
|
||||
{
|
||||
boolean notPrevented = !connectionPrevented(tile, side);
|
||||
|
||||
if (tile instanceof IConnector)
|
||||
{
|
||||
notPrevented &= ((IConnector) tile).canConnect(side.getOpposite());
|
||||
}
|
||||
return notPrevented;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(IElectricityNetwork network)
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if there are ways of preventing a connection
|
||||
*
|
||||
* @param tile The TileEntity on the given side
|
||||
* @param side The side we're checking
|
||||
* @return Whether we're preventing connections on given side or to given tileEntity
|
||||
*/
|
||||
public boolean connectionPrevented(TileEntity tile, ForgeDirection side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public byte getPossibleWireConnections()
|
||||
{
|
||||
byte connections = 0x00;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.world(), new Vector3(tile()), side);
|
||||
if (tileEntity instanceof INetworkProvider && this.canConnectBothSides(tileEntity, side))
|
||||
connections |= 1 << side.ordinal();
|
||||
}
|
||||
return connections;
|
||||
}
|
||||
|
||||
public byte getPossibleAcceptorConnections()
|
||||
{
|
||||
byte connections = 0x00;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.world(), new Vector3(tile()), side);
|
||||
if (this.isValidAcceptor(tileEntity) && this.canConnectBothSides(tileEntity, side))
|
||||
connections |= 1 << side.ordinal();
|
||||
}
|
||||
return connections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if there are different kinds of acceptor possible
|
||||
*/
|
||||
public boolean isValidAcceptor(TileEntity tile)
|
||||
{
|
||||
return tile instanceof IConnector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh()
|
||||
{
|
||||
if (!this.world().isRemote)
|
||||
{
|
||||
this.adjacentConnections = null;
|
||||
byte possibleWireConnections = getPossibleWireConnections();
|
||||
byte possibleAcceptorConnections = getPossibleAcceptorConnections();
|
||||
|
||||
if (possibleWireConnections != currentWireConnections)
|
||||
{
|
||||
byte or = (byte) (possibleWireConnections | currentWireConnections);
|
||||
if (or != possibleWireConnections) // Connections have been removed
|
||||
{
|
||||
this.getNetwork().split((IConductor) tile());
|
||||
this.setNetwork(null);
|
||||
}
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (connectionMapContainsSide(possibleWireConnections, side))
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(this.world(), new Vector3(tile()), side);
|
||||
|
||||
if (tileEntity instanceof INetworkProvider)
|
||||
{
|
||||
this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.currentWireConnections = possibleWireConnections;
|
||||
}
|
||||
|
||||
this.currentAcceptorConnections = possibleAcceptorConnections;
|
||||
|
||||
this.getNetwork().refresh();
|
||||
this.sendDescUpdate();
|
||||
}
|
||||
|
||||
this.tile().markRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should include connections that are in the current connection maps even if those connections
|
||||
* aren't allowed any more. This is so that networks split correctly.
|
||||
*/
|
||||
@Override
|
||||
public TileEntity[] getAdjacentConnections()
|
||||
{
|
||||
if (this.adjacentConnections == null)
|
||||
{
|
||||
this.adjacentConnections = new TileEntity[6];
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.world(), new Vector3(tile()), side);
|
||||
|
||||
if (isCurrentlyConnected(side))
|
||||
{
|
||||
adjacentConnections[i] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.adjacentConnections;
|
||||
}
|
||||
|
||||
public boolean isCurrentlyConnected(ForgeDirection side)
|
||||
{
|
||||
return connectionMapContainsSide(this.getAllCurrentConnections(), side);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shouldn't need to be overridden. Override connectionPrevented instead
|
||||
*/
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
Vector3 connectPos = new Vector3(tile()).modifyPositionFromSide(direction);
|
||||
TileEntity connectTile = connectPos.getTileEntity(this.world());
|
||||
return !connectionPrevented(connectTile, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
super.onAdded();
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkLoad()
|
||||
{
|
||||
super.onChunkLoad();
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
super.onNeighborChanged();
|
||||
this.refresh();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import universalelectricity.compatibility.Compatibility;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
public abstract class PartUniversalConductor extends PartConductor implements IEnergySink, IPowerReceptor
|
||||
{
|
||||
|
||||
protected boolean isAddedToEnergyNet;
|
||||
public PowerHandler powerHandler;
|
||||
public float buildcraftBuffer = Compatibility.BC3_RATIO * 50;
|
||||
|
||||
public PartUniversalConductor()
|
||||
{
|
||||
this.powerHandler = new PowerHandler(this, Type.PIPE);
|
||||
this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2);
|
||||
this.powerHandler.configurePowerPerdition(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidAcceptor(TileEntity tile)
|
||||
{
|
||||
if (Compatibility.isIndustrialCraft2Loaded() && tile instanceof IEnergyTile)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (Compatibility.isBuildcraftLoaded() && tile instanceof IPowerReceptor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.isValidAcceptor(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldJoin()
|
||||
{
|
||||
super.onWorldJoin();
|
||||
if (!this.world().isRemote)
|
||||
{
|
||||
if (!this.isAddedToEnergyNet)
|
||||
{
|
||||
this.initIC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
super.onAdded();
|
||||
if (!this.world().isRemote)
|
||||
{
|
||||
if (!this.isAddedToEnergyNet)
|
||||
{
|
||||
this.initIC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkLoad()
|
||||
{
|
||||
super.onChunkLoad();
|
||||
if (!this.world().isRemote)
|
||||
{
|
||||
if (!this.isAddedToEnergyNet)
|
||||
{
|
||||
this.initIC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldSeparate()
|
||||
{
|
||||
this.unloadTileIC2();
|
||||
super.onWorldSeparate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
this.unloadTileIC2();
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRemove()
|
||||
{
|
||||
this.unloadTileIC2();
|
||||
super.preRemove();
|
||||
}
|
||||
|
||||
protected void initIC()
|
||||
{
|
||||
if (Compatibility.isIndustrialCraft2Loaded())
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) tile()));
|
||||
}
|
||||
|
||||
this.isAddedToEnergyNet = true;
|
||||
}
|
||||
|
||||
private void unloadTileIC2()
|
||||
{
|
||||
if (this.isAddedToEnergyNet && this.world() != null)
|
||||
{
|
||||
if (Compatibility.isIndustrialCraft2Loaded())
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) tile()));
|
||||
}
|
||||
|
||||
this.isAddedToEnergyNet = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
if (this.getNetwork() == null)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return this.getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_IC2_RATIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection directionFrom, double amount)
|
||||
{
|
||||
TileEntity tile = VectorHelper.getTileEntityFromSide(this.world(), new Vector3(tile()), directionFrom);
|
||||
ElectricityPack pack = ElectricityPack.getFromWatts((float) (amount * Compatibility.IC2_RATIO), 120);
|
||||
return this.getNetwork().produce(pack, tile(), tile) * Compatibility.TO_IC2_RATIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* BuildCraft functions
|
||||
*/
|
||||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||
{
|
||||
return this.powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider)
|
||||
{
|
||||
Set<TileEntity> ignoreTiles = new HashSet<TileEntity>();
|
||||
ignoreTiles.add(tile());
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = new Vector3(tile()).modifyPositionFromSide(direction).getTileEntity(this.world());
|
||||
ignoreTiles.add(tile);
|
||||
}
|
||||
|
||||
ElectricityPack pack = ElectricityPack.getFromWatts(workProvider.useEnergy(0, this.getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_BC_RATIO, true) * Compatibility.BC3_RATIO, 120);
|
||||
this.getNetwork().produce(pack, ignoreTiles.toArray(new TileEntity[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return world();
|
||||
}
|
||||
}
|
455
common/mekanism/induction/common/wire/PartWire.java
Normal file
|
@ -0,0 +1,455 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.induction.client.render.RenderPartWire;
|
||||
import mekanism.induction.common.MekanismInduction;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemShears;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.compatibility.Compatibility;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.lib.lighting.LazyLightMatrix;
|
||||
import codechicken.lib.raytracer.IndexedCuboid6;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import codechicken.lib.render.IconTransformation;
|
||||
import codechicken.lib.render.RenderUtils;
|
||||
import codechicken.lib.vec.Cuboid6;
|
||||
import codechicken.lib.vec.Translation;
|
||||
import codechicken.microblock.IHollowConnect;
|
||||
import codechicken.multipart.IconHitEffects;
|
||||
import codechicken.multipart.JIconHitEffects;
|
||||
import codechicken.multipart.JNormalOcclusion;
|
||||
import codechicken.multipart.NormalOcclusionTest;
|
||||
import codechicken.multipart.PartMap;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TSlottedPart;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartWire extends PartUniversalConductor implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects, IInsulatedMaterial, IBlockableConnection
|
||||
{
|
||||
public static final int DEFAULT_COLOR = 16;
|
||||
public int dyeID = DEFAULT_COLOR;
|
||||
public boolean isInsulated = false;
|
||||
|
||||
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];
|
||||
public static IndexedCuboid6[] insulatedSides = new IndexedCuboid6[7];
|
||||
public EnumWireMaterial material = EnumWireMaterial.COPPER;
|
||||
|
||||
/** Client Side Connection Check */
|
||||
private ForgeDirection testingSide;
|
||||
|
||||
static
|
||||
{
|
||||
sides[0] = new IndexedCuboid6(0, new Cuboid6(0.36, 0.000, 0.36, 0.64, 0.36, 0.64));
|
||||
sides[1] = new IndexedCuboid6(1, new Cuboid6(0.36, 0.64, 0.36, 0.64, 1.000, 0.64));
|
||||
sides[2] = new IndexedCuboid6(2, new Cuboid6(0.36, 0.36, 0.000, 0.64, 0.64, 0.36));
|
||||
sides[3] = new IndexedCuboid6(3, new Cuboid6(0.36, 0.36, 0.64, 0.64, 0.64, 1.000));
|
||||
sides[4] = new IndexedCuboid6(4, new Cuboid6(0.000, 0.36, 0.36, 0.36, 0.64, 0.64));
|
||||
sides[5] = new IndexedCuboid6(5, new Cuboid6(0.64, 0.36, 0.36, 1.000, 0.64, 0.64));
|
||||
sides[6] = new IndexedCuboid6(6, new Cuboid6(0.36, 0.36, 0.36, 0.64, 0.64, 0.64));
|
||||
insulatedSides[0] = new IndexedCuboid6(0, new Cuboid6(0.3, 0.0, 0.3, 0.7, 0.3, 0.7));
|
||||
insulatedSides[1] = new IndexedCuboid6(1, new Cuboid6(0.3, 0.7, 0.3, 0.7, 1.0, 0.7));
|
||||
insulatedSides[2] = new IndexedCuboid6(2, new Cuboid6(0.3, 0.3, 0.0, 0.7, 0.7, 0.3));
|
||||
insulatedSides[3] = new IndexedCuboid6(3, new Cuboid6(0.3, 0.3, 0.7, 0.7, 0.7, 1.0));
|
||||
insulatedSides[4] = new IndexedCuboid6(4, new Cuboid6(0.0, 0.3, 0.3, 0.3, 0.7, 0.7));
|
||||
insulatedSides[5] = new IndexedCuboid6(5, new Cuboid6(0.7, 0.3, 0.3, 1.0, 0.7, 0.7));
|
||||
insulatedSides[6] = new IndexedCuboid6(6, new Cuboid6(0.3, 0.3, 0.3, 0.7, 0.7, 0.7));
|
||||
}
|
||||
|
||||
public PartWire(int typeID)
|
||||
{
|
||||
this(EnumWireMaterial.values()[typeID]);
|
||||
}
|
||||
|
||||
public PartWire(EnumWireMaterial type)
|
||||
{
|
||||
super();
|
||||
this.material = type;
|
||||
}
|
||||
|
||||
public PartWire()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
if (this.world().isBlockIndirectlyGettingPowered(this.x(), this.y(), this.z()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.canConnect(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean connectionPrevented(TileEntity tile, ForgeDirection side)
|
||||
{
|
||||
if (tile instanceof IWireMaterial)
|
||||
{
|
||||
IWireMaterial wireTile = (IWireMaterial) tile;
|
||||
|
||||
if (wireTile.getMaterial() != this.getMaterial())
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.isInsulated() && tile instanceof IInsulation)
|
||||
{
|
||||
IInsulation insulatedTile = (IInsulation) tile;
|
||||
|
||||
if ((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != this.getInsulationColor() && this.getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR))
|
||||
return true;
|
||||
}
|
||||
|
||||
return (this.isBlockedOnSide(side) || tile instanceof IBlockableConnection && ((IBlockableConnection) tile).isBlockedOnSide(side.getOpposite()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPossibleWireConnections()
|
||||
{
|
||||
if (this.world().isBlockIndirectlyGettingPowered(this.x(), this.y(), this.z()))
|
||||
{
|
||||
return 0x00;
|
||||
}
|
||||
return super.getPossibleWireConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getPossibleAcceptorConnections()
|
||||
{
|
||||
if (this.world().isBlockIndirectlyGettingPowered(this.x(), this.y(), this.z()))
|
||||
{
|
||||
return 0x00;
|
||||
}
|
||||
return super.getPossibleAcceptorConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getResistance()
|
||||
{
|
||||
return getMaterial().resistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCurrentCapacity()
|
||||
{
|
||||
return getMaterial().maxAmps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumWireMaterial getMaterial()
|
||||
{
|
||||
return material;
|
||||
}
|
||||
|
||||
public int getTypeID()
|
||||
{
|
||||
return material.ordinal();
|
||||
}
|
||||
|
||||
public void setDye(int dyeID)
|
||||
{
|
||||
this.dyeID = dyeID;
|
||||
this.refresh();
|
||||
this.world().markBlockForUpdate(this.x(), this.y(), this.z());
|
||||
}
|
||||
|
||||
public void setMaterialFromID(int id)
|
||||
{
|
||||
this.material = EnumWireMaterial.values()[id];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider)
|
||||
{
|
||||
this.buildcraftBuffer = Compatibility.BC3_RATIO * 25 * Math.min(this.getMaterial().maxAmps, 100);
|
||||
this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2);
|
||||
super.doWork(workProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "resonant_induction_wire";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean occlusionTest(TMultiPart other)
|
||||
{
|
||||
return NormalOcclusionTest.apply(this, other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IndexedCuboid6> getSubParts()
|
||||
{
|
||||
Set<IndexedCuboid6> subParts = new HashSet<IndexedCuboid6>();
|
||||
IndexedCuboid6[] currentSides = this.isInsulated() ? insulatedSides : sides;
|
||||
if (tile() != null)
|
||||
{
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
int ord = side.ordinal();
|
||||
if (connectionMapContainsSide(getAllCurrentConnections(), side) || side == this.testingSide)
|
||||
subParts.add(currentSides[ord]);
|
||||
}
|
||||
}
|
||||
subParts.add(currentSides[6]);
|
||||
return subParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getCollisionBoxes()
|
||||
{
|
||||
Set<Cuboid6> collisionBoxes = new HashSet<Cuboid6>();
|
||||
collisionBoxes.addAll((Collection<? extends Cuboid6>) getSubParts());
|
||||
return collisionBoxes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ItemStack> getDrops()
|
||||
{
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
drops.add(pickItem(null));
|
||||
if (isInsulated)
|
||||
drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID)));
|
||||
return drops;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrength(MovingObjectPosition hit, EntityPlayer player)
|
||||
{
|
||||
return 10F;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(codechicken.lib.vec.Vector3 pos, LazyLightMatrix olm, int pass)
|
||||
{
|
||||
if (pass == 0)
|
||||
RenderPartWire.INSTANCE.renderStatic(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass)
|
||||
{
|
||||
if (MekanismInduction.SHINY_SILVER && this.getMaterial() == EnumWireMaterial.SILVER)
|
||||
RenderPartWire.INSTANCE.renderShine(this, pos.x, pos.y, pos.z, frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBreaking(RenderBlocks renderBlocks)
|
||||
{
|
||||
CCRenderState.reset();
|
||||
RenderUtils.renderBlock(sides[6], 0, new Translation(x(), y(), z()), new IconTransformation(renderBlocks.overrideBlockTexture), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
this.setMaterialFromID(packet.readInt());
|
||||
this.dyeID = packet.readInt();
|
||||
this.isInsulated = packet.readBoolean();
|
||||
this.currentWireConnections = packet.readByte();
|
||||
this.currentAcceptorConnections = packet.readByte();
|
||||
if (tile() != null)
|
||||
tile().markRender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
packet.writeInt(this.getTypeID());
|
||||
packet.writeInt(this.dyeID);
|
||||
packet.writeBoolean(this.isInsulated);
|
||||
packet.writeByte(this.currentWireConnections);
|
||||
packet.writeByte(this.currentAcceptorConnections);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound nbt)
|
||||
{
|
||||
super.save(nbt);
|
||||
nbt.setInteger("typeID", this.getTypeID());
|
||||
nbt.setInteger("dyeID", this.dyeID);
|
||||
nbt.setBoolean("isInsulated", this.isInsulated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound nbt)
|
||||
{
|
||||
super.load(nbt);
|
||||
this.setMaterialFromID(nbt.getInteger("typeID"));
|
||||
this.dyeID = nbt.getInteger("dyeID");
|
||||
this.isInsulated = nbt.getBoolean("isInsulated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack pickItem(MovingObjectPosition hit)
|
||||
{
|
||||
return EnumWireMaterial.values()[this.getTypeID()].getWire();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
if (item.itemID == Item.dyePowder.itemID && isInsulated())
|
||||
{
|
||||
setDye(item.getItemDamage());
|
||||
return true;
|
||||
}
|
||||
else if (item.itemID == Block.cloth.blockID)
|
||||
{
|
||||
if (isInsulated() && !world().isRemote)
|
||||
{
|
||||
this.tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID))));
|
||||
}
|
||||
this.setInsulated(BlockColored.getDyeFromBlock(item.getItemDamage()));
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
return true;
|
||||
}
|
||||
else if ((item.itemID == Item.shears.itemID || item.getItem() instanceof ItemShears) && this.isInsulated())
|
||||
{
|
||||
if (!this.world().isRemote)
|
||||
{
|
||||
this.tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID))));
|
||||
}
|
||||
|
||||
this.setInsulated(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getOcclusionBoxes()
|
||||
{
|
||||
return getCollisionBoxes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotMask()
|
||||
{
|
||||
return PartMap.CENTER.mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHollowSize()
|
||||
{
|
||||
return this.isInsulated ? 8 : 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsulated()
|
||||
{
|
||||
return isInsulated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInsulationColor()
|
||||
{
|
||||
return isInsulated ? dyeID : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsulationColor(int dyeID)
|
||||
{
|
||||
this.dyeID = dyeID;
|
||||
this.refresh();
|
||||
this.world().markBlockForUpdate(this.x(), this.y(), this.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsulated(boolean insulated)
|
||||
{
|
||||
this.isInsulated = insulated;
|
||||
this.dyeID = DEFAULT_COLOR;
|
||||
this.refresh();
|
||||
this.world().markBlockForUpdate(this.x(), this.y(), this.z());
|
||||
this.tile().notifyPartChange(this);
|
||||
}
|
||||
|
||||
public void setInsulated(int dyeColour)
|
||||
{
|
||||
this.isInsulated = true;
|
||||
this.dyeID = dyeColour;
|
||||
this.refresh();
|
||||
this.world().markBlockForUpdate(this.x(), this.y(), this.z());
|
||||
this.tile().notifyPartChange(this);
|
||||
}
|
||||
|
||||
public void setInsulated()
|
||||
{
|
||||
setInsulated(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cuboid6 getBounds()
|
||||
{
|
||||
return new Cuboid6(0.375, 0.375, 0.375, 0.625, 0.625, 0.625);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBreakingIcon(Object subPart, int side)
|
||||
{
|
||||
return RenderPartWire.breakIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBrokenIcon(int side)
|
||||
{
|
||||
return RenderPartWire.breakIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer)
|
||||
{
|
||||
IconHitEffects.addHitEffects(this, hit, effectRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDestroyEffects(EffectRenderer effectRenderer)
|
||||
{
|
||||
IconHitEffects.addDestroyEffects(this, effectRenderer, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockedOnSide(ForgeDirection side)
|
||||
{
|
||||
TMultiPart blocker = tile().partMap(side.ordinal());
|
||||
this.testingSide = side;
|
||||
boolean expandable = NormalOcclusionTest.apply(this, blocker);
|
||||
this.testingSide = null;
|
||||
return !expandable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPartChanged(TMultiPart part)
|
||||
{
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
}
|
92
common/mekanism/induction/common/wire/TEnergySink.java
Normal file
|
@ -0,0 +1,92 @@
|
|||
package mekanism.induction.common.wire;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
|
||||
public class TEnergySink extends TileMultipart implements IEnergySink
|
||||
{
|
||||
public Set<IEnergySink> ic2Sinks = new HashSet<IEnergySink>();
|
||||
|
||||
@Override
|
||||
public void copyFrom(TileMultipart that)
|
||||
{
|
||||
super.copyFrom(that);
|
||||
if (that instanceof TEnergySink)
|
||||
ic2Sinks = ((TEnergySink) that).ic2Sinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindPart(TMultiPart part)
|
||||
{
|
||||
super.bindPart(part);
|
||||
if (part instanceof IEnergySink)
|
||||
ic2Sinks.add((IEnergySink) part);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partRemoved(TMultiPart part, int p)
|
||||
{
|
||||
super.partRemoved(part, p);
|
||||
if (part instanceof IEnergySink)
|
||||
ic2Sinks.remove(part);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearParts()
|
||||
{
|
||||
super.clearParts();
|
||||
ic2Sinks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
for (IEnergySink sink : this.ic2Sinks)
|
||||
{
|
||||
if (sink.acceptsEnergyFrom(emitter, direction))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
double demanded = 0;
|
||||
|
||||
for (IEnergySink sink : this.ic2Sinks)
|
||||
{
|
||||
demanded += sink.demandedEnergyUnits();
|
||||
}
|
||||
return demanded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection directionFrom, double amount)
|
||||
{
|
||||
for (IEnergySink sink : this.ic2Sinks)
|
||||
{
|
||||
amount = sink.injectEnergyUnits(directionFrom, Math.min(amount, sink.demandedEnergyUnits()));
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
int safe = 0;
|
||||
for (IEnergySink sink : this.ic2Sinks)
|
||||
{
|
||||
safe += sink.getMaxSafeInput();
|
||||
}
|
||||
return safe;
|
||||
}
|
||||
|
||||
}
|
|
@ -361,9 +361,9 @@ item.SteelShovel.name=Steel Shovel
|
|||
item.SteelHoe.name=Steel Hoe
|
||||
item.SteelSword.name=Steel Sword
|
||||
|
||||
//*********//
|
||||
//INDUCTION//
|
||||
//*********//
|
||||
//*****//
|
||||
//TOOLS//
|
||||
//*****//
|
||||
|
||||
//Blocks
|
||||
tile.Tesla.name=Tesla Coil
|
||||
|
@ -371,6 +371,13 @@ tile.Multimeter.name=Multimeter
|
|||
tile.ElectromagneticContractor.name=Electromagnetic Contractor
|
||||
tile.Battery.name=Modular Battery
|
||||
|
||||
tile.mekanism:wire.copper.name=Copper Wire
|
||||
tile.mekanism:wire.tin.name=Tin Wire
|
||||
tile.mekanism:wire.iron.name=Iron Wire
|
||||
tile.mekanism:wire.aluminum.name=Aluminum Wire
|
||||
tile.mekanism:wire.silver.name=Silver Wire
|
||||
tile.mekanism:wire.superconductor.name=Superconductor Wire
|
||||
|
||||
//Items
|
||||
item.Linker.name=Electrostatic Linker
|
||||
|
||||
|
|
BIN
resources/assets/mekanism/render/wire.png
Normal file
After Width: | Height: | Size: 933 B |
BIN
resources/assets/mekanism/textures/blocks/wire.aluminum.png
Normal file
After Width: | Height: | Size: 269 B |
BIN
resources/assets/mekanism/textures/blocks/wire.copper.png
Normal file
After Width: | Height: | Size: 224 B |
BIN
resources/assets/mekanism/textures/blocks/wire.iron.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
resources/assets/mekanism/textures/blocks/wire.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
resources/assets/mekanism/textures/blocks/wire.silver.png
Normal file
After Width: | Height: | Size: 269 B |
After Width: | Height: | Size: 225 B |
BIN
resources/assets/mekanism/textures/blocks/wire.tin.png
Normal file
After Width: | Height: | Size: 224 B |
BIN
resources/assets/mekanism/textures/items/wire.aluminum.png
Normal file
After Width: | Height: | Size: 269 B |
BIN
resources/assets/mekanism/textures/items/wire.copper.png
Normal file
After Width: | Height: | Size: 224 B |
BIN
resources/assets/mekanism/textures/items/wire.iron.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
resources/assets/mekanism/textures/items/wire.silver.png
Normal file
After Width: | Height: | Size: 269 B |
BIN
resources/assets/mekanism/textures/items/wire.superconductor.png
Normal file
After Width: | Height: | Size: 225 B |
BIN
resources/assets/mekanism/textures/items/wire.tin.png
Normal file
After Width: | Height: | Size: 224 B |