All terminals can now have their texture rotated based on placement ( and some with the wrench )

This commit is contained in:
AlgorithmX2 2014-07-19 16:01:24 -05:00
parent 3a10671bd6
commit 642a7f162f
4 changed files with 100 additions and 38 deletions

View file

@ -19,6 +19,8 @@ public class PartInterfaceTerminal extends PartMonitor
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
{
if ( !super.onPartActivate( player, pos ) )
{
if ( !player.isSneaking() )
{
@ -29,6 +31,7 @@ public class PartInterfaceTerminal extends PartMonitor
return true;
}
}
return false;
}

View file

@ -6,8 +6,12 @@ import java.io.IOException;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.implementations.parts.IPartMonitor;
@ -34,12 +38,76 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
boolean notLightSource = !this.getClass().equals( PartMonitor.class );
final int POWERED_FLAG = 1;
final int BOOTING_FLAG = 2;
final int CHANNEL_FLAG = 4;
final int POWERED_FLAG = 4;
final int BOOTING_FLAG = 8;
final int CHANNEL_FLAG = 16;
byte spin = 0; // 0-3
int clientFlags = 0; // sent as byte.
@Override
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
{
super.onPlacement( player, held, side );
byte rotation = (byte) (MathHelper.floor_double( (double) ((player.rotationYaw * 4F) / 360F) + 2.5D ) & 3);
if ( side == ForgeDirection.UP )
spin = rotation;
else if ( side == ForgeDirection.DOWN )
spin = rotation;
}
@Override
public void writeToNBT(NBTTagCompound data)
{
super.writeToNBT( data );
data.setByte( "spin", (byte) spin );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
super.readFromNBT( data );
spin = data.getByte( "spin" );
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
{
TileEntity te = getTile();
if ( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.xCoord, te.yCoord, te.zCoord ) )
{
if ( Platform.isServer() )
{
if ( spin > 3 )
spin = 0;
switch (spin)
{
case 0:
spin = 1;
break;
case 1:
spin = 3;
break;
case 2:
spin = 0;
break;
case 3:
spin = 2;
break;
}
this.host.markForUpdate();
this.saveChanges();
}
return true;
}
else
return super.onPartActivate( player, pos );
}
@MENetworkEventSubscribe
public void bootingRender(MENetworkBootingStatusChange c)
{
@ -63,7 +131,8 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
public void writeToStream(ByteBuf data) throws IOException
{
super.writeToStream( data );
clientFlags = 0;
clientFlags = spin & 3;
;
try
{
@ -90,6 +159,7 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
super.readFromStream( data );
int oldFlags = clientFlags;
clientFlags = data.readByte();
spin = (byte) (clientFlags & 3);
if ( clientFlags == oldFlags )
return false;
return true;
@ -179,6 +249,8 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
Tessellator.instance.setBrightness( l << 20 | l << 4 );
}
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.spin;
Tessellator.instance.setColorOpaque_I( getColor().whiteVariant );
rh.renderFace( x, y, z, frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
@ -188,6 +260,8 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann
Tessellator.instance.setColorOpaque_I( getColor().blackVariant );
rh.renderFace( x, y, z, frontColored.getIcon(), ForgeDirection.SOUTH, renderer );
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
if ( notLightSource )
{
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),

View file

@ -14,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
@ -45,29 +44,14 @@ import cpw.mods.fml.relauncher.SideOnly;
public class PartStorageMonitor extends PartMonitor implements IPartStorageMonitor, IStackWatcherHost
{
byte spin;
IAEItemStack configuredItem;
boolean isLocked;
@Override
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
{
super.onPlacement( player, held, side );
byte rotation = (byte) (MathHelper.floor_double( (double) ((player.rotationYaw * 4F) / 360F) + 2.5D ) & 3);
if ( side == ForgeDirection.UP )
spin = rotation;
else if ( side == ForgeDirection.DOWN )
spin = rotation;
}
@Override
public void writeToNBT(NBTTagCompound data)
{
super.writeToNBT( data );
data.setByte( "spin", spin );
data.setBoolean( "isLocked", isLocked );
NBTTagCompound myItem = new NBTTagCompound();
@ -82,7 +66,6 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
{
super.readFromNBT( data );
spin = data.getByte( "spin" );
isLocked = data.getBoolean( "isLocked" );
NBTTagCompound myItem = data.getCompoundTag( "configuredItem" );

View file

@ -84,6 +84,8 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
{
if ( !super.onPartActivate( player, pos ) )
{
if ( !player.isSneaking() )
{
@ -94,7 +96,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
return true;
}
}
return false;
}