mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-19 19:59:34 +00:00
Migrate Reactor Energy Injector to Forge Direction
This commit is contained in:
1 parent
7e9f771297
commit
55c268d56f
3 files changed
+40
-36
No files matched your search
+21
-14
@@ -2,6 +2,7 @@ package com.brandon3055.draconicevolution.client.render.tile;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -21,34 +22,40 @@ public class RenderTileReactorEnergyInjector extends TileEntitySpecialRenderer {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
|
||||
renderCore((TileReactorEnergyInjector) tileEntity, partialTick);
|
||||
renderCore((TileReactorEnergyInjector) tileEntity);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void renderCore(TileReactorEnergyInjector tile, float partialTick) {
|
||||
public static void renderCore(TileReactorEnergyInjector injector) {
|
||||
GL11.glPushMatrix();
|
||||
float scale = (1F / 16F);
|
||||
|
||||
switch (tile.facingDirection) {
|
||||
case 1:
|
||||
GL11.glRotated(180, -1, 0, 0);
|
||||
int angle = 90;
|
||||
ForgeDirection axis = injector.facing;
|
||||
switch (injector.facing) {
|
||||
case UP:
|
||||
angle = 180;
|
||||
// it's intended to fall through
|
||||
case SOUTH:
|
||||
axis = ForgeDirection.WEST;
|
||||
break;
|
||||
case 2:
|
||||
GL11.glRotated(90, 1, 0, 0);
|
||||
case NORTH:
|
||||
axis = ForgeDirection.EAST;
|
||||
break;
|
||||
case 3:
|
||||
GL11.glRotated(90, -1, 0, 0);
|
||||
case WEST:
|
||||
axis = ForgeDirection.NORTH;
|
||||
break;
|
||||
case 4:
|
||||
GL11.glRotated(90, 0, 0, -1);
|
||||
case EAST:
|
||||
axis = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case 5:
|
||||
GL11.glRotated(90, 0, 0, 1);
|
||||
}
|
||||
if (injector.facing != ForgeDirection.DOWN) {
|
||||
GL11.glRotated(angle, axis.offsetX, axis.offsetY, axis.offsetZ);
|
||||
}
|
||||
|
||||
ResourceHandler.bindResource("textures/models/ModelReactorPowerInjector.png");
|
||||
modelReactorEnergyInjector.render(null, tile.modelIllumination, 0F, 0F, 0F, 0F, scale);
|
||||
modelReactorEnergyInjector.render(null, injector.modelIllumination, 0F, 0F, 0F, 0F, scale);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
+12
-14
@@ -56,23 +56,23 @@ public class ReactorEnergyInjector extends BlockDE implements ITileEntityProvide
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileReactorEnergyInjector) {
|
||||
TileReactorEnergyInjector injector = (TileReactorEnergyInjector) tile;
|
||||
switch (injector.facingDirection) {
|
||||
case 0:
|
||||
this.setBlockBounds(0F, 0.885F, 0F, 1F, 1F, 1F);
|
||||
switch (injector.facing) {
|
||||
case DOWN:
|
||||
this.setBlockBounds(0F, 0.875F, 0F, 1F, 1F, 1F);
|
||||
break;
|
||||
case 1:
|
||||
case UP:
|
||||
this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F);
|
||||
break;
|
||||
case 2:
|
||||
this.setBlockBounds(0F, 0F, 0.885F, 1F, 1F, 1F);
|
||||
case NORTH:
|
||||
this.setBlockBounds(0F, 0F, 0.875F, 1F, 1F, 1F);
|
||||
break;
|
||||
case 3:
|
||||
case SOUTH:
|
||||
this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.125F);
|
||||
break;
|
||||
case 4:
|
||||
this.setBlockBounds(0.885F, 0F, 0F, 1F, 1F, 1F);
|
||||
case WEST:
|
||||
this.setBlockBounds(0.875F, 0F, 0F, 1F, 1F, 1F);
|
||||
break;
|
||||
case 5:
|
||||
case EAST:
|
||||
this.setBlockBounds(0F, 0F, 0F, 0.125F, 1F, 1F);
|
||||
break;
|
||||
}
|
||||
@@ -96,13 +96,11 @@ public class ReactorEnergyInjector extends BlockDE implements ITileEntityProvide
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
|
||||
int facing = Utills.determineOrientation(x, y, z, entity);
|
||||
ForgeDirection facing = ForgeDirection.getOrientation(Utills.determineOrientation(x, y, z, entity));
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileReactorEnergyInjector) {
|
||||
TileReactorEnergyInjector injector = (TileReactorEnergyInjector) tile;
|
||||
injector.facingDirection = entity.isSneaking()
|
||||
? ForgeDirection.getOrientation(facing).getOpposite().ordinal()
|
||||
: ForgeDirection.getOrientation(facing).ordinal();
|
||||
injector.facing = entity.isSneaking() ? facing.getOpposite() : facing;
|
||||
injector.onPlaced();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-8
@@ -25,7 +25,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class TileReactorEnergyInjector extends TileEntity implements IReactorPart, IEnergyReceiver, IDEPeripheral {
|
||||
|
||||
public float modelIllumination = 1F;
|
||||
public int facingDirection = ForgeDirection.UP.ordinal();
|
||||
public ForgeDirection facing = ForgeDirection.UP;
|
||||
public TileLocation masterLocation = new TileLocation();
|
||||
public boolean isValid = false;
|
||||
|
||||
@@ -62,7 +62,6 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
}
|
||||
|
||||
public void onPlaced() {
|
||||
ForgeDirection facing = ForgeDirection.getOrientation(facingDirection);
|
||||
for (int distance = 1; distance <= TileReactorCore.MAX_SLAVE_RANGE; distance++) {
|
||||
int targetX = xCoord + facing.offsetX * distance;
|
||||
int targetY = yCoord + facing.offsetY * distance;
|
||||
@@ -108,7 +107,7 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
|
||||
@Override
|
||||
public ForgeDirection getFacing() {
|
||||
return ForgeDirection.getOrientation(facingDirection);
|
||||
return facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,7 +133,7 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
masterLocation.writeToNBT(compound, "Master");
|
||||
compound.setInteger("Facing", facingDirection);
|
||||
compound.setInteger("Facing", facing.ordinal());
|
||||
compound.setBoolean("IsValid", isValid);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound);
|
||||
}
|
||||
@@ -143,7 +142,7 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
NBTTagCompound compound = pkt.func_148857_g();
|
||||
masterLocation.readFromNBT(compound, "Master");
|
||||
facingDirection = compound.getInteger("Facing");
|
||||
facing = ForgeDirection.getOrientation(compound.getInteger("Facing"));
|
||||
isValid = compound.getBoolean("IsValid");
|
||||
super.onDataPacket(net, pkt);
|
||||
}
|
||||
@@ -152,7 +151,7 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
super.writeToNBT(compound);
|
||||
masterLocation.writeToNBT(compound, "Master");
|
||||
compound.setInteger("Facing", facingDirection);
|
||||
compound.setInteger("Facing", facing.ordinal());
|
||||
compound.setBoolean("IsValid", isValid);
|
||||
compound.setInteger("RedstoneMode", redstoneMode);
|
||||
}
|
||||
@@ -161,7 +160,7 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
masterLocation.readFromNBT(compound, "Master");
|
||||
facingDirection = compound.getInteger("Facing");
|
||||
facing = ForgeDirection.getOrientation(compound.getInteger("Facing"));
|
||||
isValid = compound.getBoolean("IsValid");
|
||||
redstoneMode = compound.getInteger("RedstoneMode");
|
||||
}
|
||||
@@ -195,7 +194,7 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return from == ForgeDirection.getOrientation(facingDirection).getOpposite();
|
||||
return from == facing.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user