All terminals can now have their texture rotated based on placement ( and some with the wrench )
This commit is contained in:
parent
3a10671bd6
commit
642a7f162f
4 changed files with 100 additions and 38 deletions
|
@ -20,14 +20,17 @@ public class PartInterfaceTerminal extends PartMonitor
|
|||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
if ( !super.onPartActivate( player, pos ) )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_INTERFACE_TERMINAL );
|
||||
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_INTERFACE_TERMINAL );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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" );
|
||||
|
|
|
@ -32,7 +32,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
|||
AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 );
|
||||
|
||||
public PartTerminal(Class clz, ItemStack is) {
|
||||
super( clz, is,true );
|
||||
super( clz, is, true );
|
||||
|
||||
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
|
@ -42,8 +42,8 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
|||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
{
|
||||
super.getDrops(drops, wrenched);
|
||||
|
||||
super.getDrops( drops, wrenched );
|
||||
|
||||
for (ItemStack is : viewCell)
|
||||
if ( is != null )
|
||||
drops.add( is );
|
||||
|
@ -66,7 +66,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
|||
}
|
||||
|
||||
public PartTerminal(ItemStack is) {
|
||||
super( PartTerminal.class, is,true );
|
||||
super( PartTerminal.class, is, true );
|
||||
frontBright = CableBusTextures.PartTerminal_Bright;
|
||||
frontColored = CableBusTextures.PartTerminal_Colored;
|
||||
frontDark = CableBusTextures.PartTerminal_Dark;
|
||||
|
@ -85,16 +85,18 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
|
|||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
if ( !super.onPartActivate( player, pos ) )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, getHost().getTile(), side, getGui() );
|
||||
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, getHost().getTile(), side, getGui() );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue