Fix Block Cable Painting Support.
This commit is contained in:
parent
f636dad621
commit
37b18d77f4
6 changed files with 46 additions and 10 deletions
|
@ -57,10 +57,15 @@ public class BlockCableBus extends AEBaseBlock
|
|||
|
||||
@Override
|
||||
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
|
||||
{
|
||||
return recolourBlock( world, x, y, z, side, colour, null );
|
||||
}
|
||||
|
||||
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour, EntityPlayer who)
|
||||
{
|
||||
try
|
||||
{
|
||||
return cb( world, x, y, z ).recolourBlock( side, colour );
|
||||
return cb( world, x, y, z ).recolourBlock( side, colour, who );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
|
2
me/cache/SecurityCache.java
vendored
2
me/cache/SecurityCache.java
vendored
|
@ -56,7 +56,7 @@ public class SecurityCache implements IGridCache, ISecurityGrid
|
|||
@Override
|
||||
public boolean hasPermission(EntityPlayer player, SecurityPermissions perm)
|
||||
{
|
||||
return hasPermission( WorldSettings.getInstance().getPlayerID( player.getCommandSenderName() ), perm );
|
||||
return hasPermission( player == null ? -1 : WorldSettings.getInstance().getPlayerID( player.getCommandSenderName() ), perm );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -782,7 +782,8 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
|||
return light;
|
||||
}
|
||||
|
||||
public boolean recolourBlock(ForgeDirection side, int colour)
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, int colour, EntityPlayer who)
|
||||
{
|
||||
IPart cable = getPart( ForgeDirection.UNKNOWN );
|
||||
if ( cable != null )
|
||||
|
@ -791,7 +792,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
|||
|
||||
AEColor colors[] = AEColor.values();
|
||||
if ( colors.length > colour )
|
||||
return pc.changeColor( colors[colour] );
|
||||
return pc.changeColor( colors[colour], who );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public interface ICableBusContainer
|
|||
|
||||
SelectedPart selectPart(Vec3 v3);
|
||||
|
||||
boolean recolourBlock(ForgeDirection side, int colour);
|
||||
boolean recolourBlock(ForgeDirection side, int colour, EntityPlayer who);
|
||||
|
||||
boolean isLadder(EntityLivingBase entity);
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class NullCableBusContainer implements ICableBusContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(ForgeDirection side, int colour)
|
||||
public boolean recolourBlock(ForgeDirection side, int colour, EntityPlayer who)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.EnumSet;
|
|||
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
@ -15,6 +16,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.parts.IPartCable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
|
@ -879,13 +881,41 @@ public class PartCable extends AEBasePart implements IPartCable
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean changeColor(AEColor newColor)
|
||||
public boolean changeColor(AEColor newColor, EntityPlayer who)
|
||||
{
|
||||
if ( getCableColor() != newColor )
|
||||
{
|
||||
is.setItemDamage( newColor.ordinal() );
|
||||
markForUpdate();
|
||||
return true;
|
||||
ItemStack newPart = null;
|
||||
|
||||
if ( getCableConnectionType() == AECableType.GLASS )
|
||||
newPart = AEApi.instance().parts().partCableGlass.stack( newColor, 1 );
|
||||
else if ( getCableConnectionType() == AECableType.COVERED )
|
||||
newPart = AEApi.instance().parts().partCableCovered.stack( newColor, 1 );
|
||||
else if ( getCableConnectionType() == AECableType.SMART )
|
||||
newPart = AEApi.instance().parts().partCableSmart.stack( newColor, 1 );
|
||||
else if ( getCableConnectionType() == AECableType.DENSE )
|
||||
newPart = AEApi.instance().parts().partCableDense.stack( newColor, 1 );
|
||||
|
||||
boolean hasPermission = true;
|
||||
|
||||
try
|
||||
{
|
||||
hasPermission = proxy.getSecurity().hasPermission( who, SecurityPermissions.BUILD );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
if ( newPart != null && hasPermission )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
getHost().removePart( ForgeDirection.UNKNOWN, false );
|
||||
getHost().addPart( newPart, ForgeDirection.UNKNOWN, who );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue