Fixed #246 - Transformer connections
This commit is contained in:
parent
c1ce38ffbb
commit
b0e77b7a40
5 changed files with 71 additions and 22 deletions
|
@ -1,12 +1,21 @@
|
|||
package resonantinduction.electrical.charger;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.render.RenderItemOverlayTile;
|
||||
import universalelectricity.api.CompatibilityModule;
|
||||
import universalelectricity.api.energy.UnitDisplay;
|
||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
||||
/**
|
||||
* Renderer for electric item charger
|
||||
|
@ -15,6 +24,22 @@ import calclavia.lib.render.RenderUtility;
|
|||
*/
|
||||
public class RenderCharger extends RenderItemOverlayTile
|
||||
{
|
||||
public static final RenderCharger INSTANCE = new RenderCharger();
|
||||
|
||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "charger.tcn");
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "charger.png");
|
||||
/*
|
||||
public void render(PartCharger part, double x, double y, double z)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
|
||||
RenderUtility.rotateFaceBlockToSide(part.placementSide);
|
||||
RenderUtility.rotateBlockBasedOnDirection(part.getFacing());
|
||||
|
||||
RenderUtility.bind(TEXTURE);
|
||||
MODEL.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f)
|
||||
|
|
|
@ -104,7 +104,7 @@ public class PartTransformer extends PartFace implements JNormalOcclusion, TFace
|
|||
@Override
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return obj instanceof IEnergyInterface && direction.ordinal() == Rotation.rotateSide(placementSide.ordinal(), facing) || direction.ordinal() == Rotation.rotateSide(placementSide.ordinal(), Rotation.rotateSide(facing, 2));
|
||||
return obj instanceof IEnergyInterface && (direction == getAbsoluteFacing() || direction == getAbsoluteFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,14 +178,11 @@ public class PartTransformer extends PartFace implements JNormalOcclusion, TFace
|
|||
|
||||
WrenchUtility.damageWrench(player, player.inventory.getCurrentItem(), x(), y(), z());
|
||||
|
||||
facing = (byte) ((facing + 1) % 3);
|
||||
facing = (byte) ((facing + 1) % 4);
|
||||
|
||||
sendDescUpdate();
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
tile().notifyNeighborChange(dir.ordinal());
|
||||
}
|
||||
tile().notifyPartChange(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -48,6 +48,7 @@ public class RenderTransformer implements ISimpleItemRenderer
|
|||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
|
||||
RenderUtility.rotateFaceBlockToSide(part.placementSide);
|
||||
RenderUtility.rotateBlockBasedOnDirection(part.getFacing());
|
||||
GL11.glRotatef(90, 0, 1, 0);
|
||||
GL11.glScalef(0.5f, 0.5f, 0.5f);
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_COIL);
|
||||
|
||||
|
|
|
@ -123,8 +123,35 @@ public abstract class PartFace extends JCuboidPart implements JNormalOcclusion,
|
|||
nbt.setByte("facing", facing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relative direction of this block relative to the face it is on.
|
||||
*/
|
||||
public ForgeDirection getFacing()
|
||||
{
|
||||
return ForgeDirection.getOrientation(this.facing + 2);
|
||||
}
|
||||
|
||||
public ForgeDirection getAbsoluteFacing()
|
||||
{
|
||||
int s = 0;
|
||||
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
s = 2;
|
||||
break;
|
||||
case 1:
|
||||
s = 0;
|
||||
break;
|
||||
case 2:
|
||||
s = 1;
|
||||
break;
|
||||
case 3:
|
||||
s = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
int absDir = Rotation.rotateSide(placementSide.ordinal(), s);
|
||||
return ForgeDirection.getOrientation(absDir);
|
||||
}
|
||||
}
|
|
@ -29,8 +29,8 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
{
|
||||
private static final ForgeDirection[] forge_sides = { ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST };
|
||||
|
||||
private final RenderBlocks renderBlocks;
|
||||
private final RenderItem renderItem;
|
||||
private static RenderBlocks renderBlocks;
|
||||
private static RenderItem renderItem;
|
||||
|
||||
public RenderItemOverlayTile()
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
renderTopOverlay(tileEntity, inventory, dir, 3, 3, x, y, z);
|
||||
}
|
||||
|
||||
public void renderTopOverlay(TileEntity tileEntity, ItemStack[] inventory, ForgeDirection dir, int matrixX, int matrixZ, double x, double y, double z)
|
||||
public static void renderTopOverlay(TileEntity tileEntity, ItemStack[] inventory, ForgeDirection dir, int matrixX, int matrixZ, double x, double y, double z)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
|
@ -72,7 +72,7 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
GL11.glTranslated(translation.x, translation.y, translation.z);
|
||||
GL11.glScalef(0.7f, 0.7f, 0.7f);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
this.renderItem(tileEntity.worldObj, ForgeDirection.UP, inventory[i], new Vector3(0, 0, 0), 0, 1);
|
||||
renderItem(tileEntity.worldObj, ForgeDirection.UP, inventory[i], new Vector3(0, 0, 0), 0, 1);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (isLooking)
|
||||
|
@ -89,12 +89,12 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
|
||||
}
|
||||
|
||||
public void renderItemOnSides(TileEntity tile, ItemStack itemStack, double x, double y, double z)
|
||||
public static void renderItemOnSides(TileEntity tile, ItemStack itemStack, double x, double y, double z)
|
||||
{
|
||||
renderItemOnSides(tile, itemStack, x, y, z, "No Output");
|
||||
}
|
||||
|
||||
public void renderItemOnSides(TileEntity tile, ItemStack itemStack, double x, double y, double z, String renderText)
|
||||
public static void renderItemOnSides(TileEntity tile, ItemStack itemStack, double x, double y, double z, String renderText)
|
||||
{
|
||||
/** Render the Output */
|
||||
String amount = "";
|
||||
|
@ -111,13 +111,13 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
{
|
||||
continue;
|
||||
}
|
||||
this.renderItemOnSide(tile, itemStack, direction, x, y, z, renderText, amount);
|
||||
renderItemOnSide(tile, itemStack, direction, x, y, z, renderText, amount);
|
||||
RenderUtility.renderText(renderText, direction, 0.02f, x, y - 0.35f, z);
|
||||
RenderUtility.renderText(amount, direction, 0.02f, x, y - 0.15f, z);
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderItemSingleSide(TileEntity tile, double x, double y, double z, ItemStack itemStack, ForgeDirection direction, String renderText)
|
||||
protected static void renderItemSingleSide(TileEntity tile, double x, double y, double z, ItemStack itemStack, ForgeDirection direction, String renderText)
|
||||
{
|
||||
if (!tile.worldObj.isBlockSolidOnSide(tile.xCoord + direction.offsetX, tile.yCoord, tile.zCoord + direction.offsetZ, direction.getOpposite()))
|
||||
{
|
||||
|
@ -129,17 +129,16 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
amount = Integer.toString(itemStack.stackSize);
|
||||
}
|
||||
|
||||
this.renderItemOnSide(tile, itemStack, direction, x, y, z, renderText, amount);
|
||||
renderItemOnSide(tile, itemStack, direction, x, y, z, renderText, amount);
|
||||
RenderUtility.renderText(renderText, direction, 0.02f, x, y - 0.35f, z);
|
||||
RenderUtility.renderText(amount, direction, 0.02f, x, y - 0.15f, z);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderItemOnSide(TileEntity tile, ItemStack itemStack, ForgeDirection direction, double x, double y, double z, String renderText, String amount)
|
||||
protected static void renderItemOnSide(TileEntity tile, ItemStack itemStack, ForgeDirection direction, double x, double y, double z, String renderText, String amount)
|
||||
{
|
||||
|
||||
this.setupLight(tile, direction.offsetX, direction.offsetZ);
|
||||
setupLight(tile, direction.offsetX, direction.offsetZ);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
|
||||
if (itemStack != null)
|
||||
|
@ -173,9 +172,9 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
|
||||
GL11.glDisable(2896);
|
||||
|
||||
if (!ForgeHooksClient.renderInventoryItem(this.renderBlocks, renderEngine, itemStack, true, 0.0F, 0.0F, 0.0F))
|
||||
if (!ForgeHooksClient.renderInventoryItem(renderBlocks, renderEngine, itemStack, true, 0.0F, 0.0F, 0.0F))
|
||||
{
|
||||
renderItem.renderItemIntoGUI(this.getFontRenderer(), renderEngine, itemStack, 0, 0);
|
||||
renderItem.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, renderEngine, itemStack, 0, 0);
|
||||
}
|
||||
|
||||
GL11.glEnable(2896);
|
||||
|
@ -183,7 +182,7 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
}
|
||||
}
|
||||
|
||||
private void setupLight(TileEntity tileEntity, int xDifference, int zDifference)
|
||||
private static void setupLight(TileEntity tileEntity, int xDifference, int zDifference)
|
||||
{
|
||||
World world = tileEntity.worldObj;
|
||||
|
||||
|
@ -199,7 +198,7 @@ public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
|||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale);
|
||||
}
|
||||
|
||||
private void renderItem(World world, ForgeDirection dir, ItemStack itemStack, Vector3 position, float rotationYaw, int angle)
|
||||
private static void renderItem(World world, ForgeDirection dir, ItemStack itemStack, Vector3 position, float rotationYaw, int angle)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue