Added Meteorite Spawn Distance Setting.

Added Charged Quartz Spawn Chance.
All GUI's Parts/Tiles support Custom Localization. ( Fixes #0190 )
Added Crafting Recipe for copying Press Plates.
Fixed Bug: #0189 - Particles don't turn off when set to minimal
Fixed Bug: #0176 - Weird Colorization While Mining Parts.
Fixed Bug: #0152 - TPane drops parts as items and does not insert into system.
Fixed Bug: #0140 - Spatial pylon facade renders oddly (Clear)
This commit is contained in:
AlgorithmX2 2014-03-15 01:58:21 -05:00
parent 754d2c25d9
commit d4ff8e731d
39 changed files with 269 additions and 64 deletions

View file

@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.resources.IResource;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
@ -730,4 +731,15 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
return 0;
}
@Override
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase player, ItemStack is)
{
if ( is.hasDisplayName() )
{
TileEntity te = getTileEntity( w, x, y, z );
if ( te instanceof AEBaseTile )
((AEBaseTile) w.getTileEntity( x, y, z )).setName( is.getDisplayName() );
}
}
}

View file

@ -18,6 +18,7 @@ public class BlockController extends AEBaseBlock
super( BlockController.class, Material.iron );
setfeature( EnumSet.of( AEFeature.Core ) );
setTileEntiy( TileController.class );
setHardness( 6 );
}
@Override

View file

@ -245,6 +245,8 @@ public class ClientHelper extends ServerHelper
public boolean shouldAddParticles(Random r)
{
int setting = Minecraft.getMinecraft().gameSettings.particleSetting;
if ( setting == 2 )
return false;
if ( setting == 0 )
return true;
return r.nextInt( 2 * (setting + 1) ) == 0;

View file

@ -31,6 +31,7 @@ import appeng.client.gui.widgets.ITooltip;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
import appeng.container.AEBaseContainer;
import appeng.container.slot.AppEngCraftingSlot;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.AppEngSlot.hasCalculatedValidness;
@ -458,6 +459,23 @@ public abstract class AEBaseGui extends GuiContainer
drawFG( ox, oy, x, y );
}
protected String getGuiDisplayName(String in)
{
return hasCustomInventoryName() ? getInventoryName() : in;
}
private String getInventoryName()
{
return ((AEBaseContainer) inventorySlots).customName;
}
private boolean hasCustomInventoryName()
{
if ( inventorySlots instanceof AEBaseContainer )
return ((AEBaseContainer) inventorySlots).customName != null;
return false;
}
protected Slot getSlot(int mousex, int mousey)
{
for (int j1 = 0; j1 < this.inventorySlots.inventorySlots.size(); ++j1)

View file

@ -60,7 +60,7 @@ public class GuiChest extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.Chest.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Chest.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -77,7 +77,7 @@ public class GuiCondenser extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.Condenser.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Condenser.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
mode.set( cvc.output );

View file

@ -60,7 +60,7 @@ public class GuiDrive extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.Drive.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Drive.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -39,7 +39,7 @@ public class GuiFormationPlane extends GuiUpgradeable
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.FormationPlane.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
if ( fuzzyMode != null )

View file

@ -24,7 +24,7 @@ public class GuiGrinder extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.GrindStone.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.GrindStone.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -42,7 +42,7 @@ public class GuiIOPort extends GuiUpgradeable
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.IOPort.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
if ( redstoneMode != null )

View file

@ -45,7 +45,7 @@ public class GuiInscriber extends AEBaseGui
pb.current = cvc.processingTime;
pb.FullMsg = (pb.current * 100 / pb.max) + "%";
fontRendererObj.drawString( GuiText.Inscriber.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Inscriber.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -24,7 +24,7 @@ public class GuiInterface extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.Interface.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.Config.getLocal(), 18, 6 + 11 + 7, 4210752 );
fontRendererObj.drawString( GuiText.StoredItems.getLocal(), 18, 6 + 60 + 7, 4210752 );

View file

@ -304,7 +304,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( myName.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( myName.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -24,7 +24,7 @@ public class GuiNetworkTool extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.NetworkTool.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -24,7 +24,7 @@ public class GuiQNB extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.QuantumLinkChamber.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.QuantumLinkChamber.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -68,7 +68,7 @@ public class GuiQuartzKnife extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.QuartzCuttingKnife.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -24,7 +24,7 @@ public class GuiSkyChest extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.SkyChest.getLocal(), 8, 8, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.SkyChest.getLocal() ), 8, 8, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 2, 4210752 );
}

View file

@ -63,7 +63,7 @@ public class GuiSpatialIOPort extends AEBaseGui
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + formatPowerLong( csiop.reqPower, false ), 13, 78, 4210752 );
fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + (((float) csiop.eff) / 100) + "%", 13, 88, 4210752 );
fontRendererObj.drawString( GuiText.SpatialIOPort.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96, 4210752 );
}

View file

@ -41,7 +41,7 @@ public class GuiStorageBus extends GuiUpgradeable
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.StorageBus.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
if ( fuzzyMode != null )

View file

@ -120,7 +120,7 @@ public class GuiUpgradeable extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( getName().getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( getName().getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
if ( redstoneMode != null )

View file

@ -44,7 +44,7 @@ public class GuiVibrationChamber extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.VibrationChamber.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.VibrationChamber.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
int k = 25;

View file

@ -24,7 +24,7 @@ public class GuiWireless extends AEBaseGui
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRendererObj.drawString( GuiText.Wireless.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}

View file

@ -103,6 +103,7 @@ public class BusRenderer implements IItemRenderer
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
renderer.useInventoryTint = false;
renderer.overrideBlockTexture = null;
if ( item.getItem() instanceof IFacadeItem )
{

View file

@ -33,6 +33,7 @@ public class RendererCableBus extends BaseBlockRender
{
BusRenderer.instance.renderer.renderAllFaces = true;
BusRenderer.instance.renderer.blockAccess = renderer.blockAccess;
BusRenderer.instance.renderer.overrideBlockTexture = renderer.overrideBlockTexture;
((TileCableBus) t).cb.renderStatic( x, y, z );
BusRenderer.instance.renderer.renderAllFaces = false;
}
@ -45,6 +46,7 @@ public class RendererCableBus extends BaseBlockRender
{
if ( t instanceof TileCableBus )
{
BusRenderer.instance.renderer.overrideBlockTexture = null;
((TileCableBus) t).cb.renderDynamic( x, y, z );
}
}

View file

@ -42,6 +42,8 @@ import appeng.container.slot.SlotPlayerInv;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.InventoryAction;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
@ -58,6 +60,9 @@ public abstract class AEBaseContainer extends Container
final protected BaseActionSource mySrc;
public boolean isContainerValid = true;
boolean sentCustomName;
public String customName;
int ticksSinceCheck = 900;
public void verifyPermissions(SecurityPermissions security, boolean requirePower)
@ -407,6 +412,49 @@ public abstract class AEBaseContainer extends Container
detectAndSendChanges();
}
@Override
public void detectAndSendChanges()
{
sendCustomName();
super.detectAndSendChanges();
}
protected void sendCustomName()
{
if ( !sentCustomName )
{
sentCustomName = true;
if ( Platform.isServer() )
{
ICustomNameObject name = null;
if ( part instanceof ICustomNameObject )
name = (ICustomNameObject) part;
if ( tileEntity instanceof ICustomNameObject )
name = (ICustomNameObject) tileEntity;
if ( name != null )
{
if ( name.hasCustomName() )
customName = name.getCustomName();
if ( customName != null )
{
try
{
NetworkHandler.instance.sendTo( new PacketValueConfig( "CustomName", customName ), (EntityPlayerMP) invPlayer.player );
}
catch (IOException e)
{
AELog.error( e );
}
}
}
}
}
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer, int offset_x, int offset_y)
{
for (int i = 0; i < 3; i++)

View file

@ -40,7 +40,11 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
public int storageBiomeID = -1;
public int storageProviderID = -1;
public int oresPerCluster = 4;
public float spawnChargedChance = 0.92f;
public int quartzOresPerCluster = 4;
public int chargedChange = 4;
public int minMeteoriteDistance = 707;
public int minMeteoriteDistanceSq = minMeteoriteDistance * minMeteoriteDistance;
private double WirelessBaseCost = 8;
private double WirelessCostMultiplier = 1;
@ -122,6 +126,12 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
// settings.registerSetting( Settings.SORT_BY, SortOrder.NAME );
// settings.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
spawnChargedChance = (float) (1.0 - get( "worldGen", "spawnChargedChance", 1.0 - spawnChargedChance ).getDouble( 1.0 - spawnChargedChance ));
minMeteoriteDistance = get( "worldGen", "minMeteoriteDistance", minMeteoriteDistance ).getInt( minMeteoriteDistance );
quartzOresPerCluster = get( "worldGen", "quartzOresPerCluster", quartzOresPerCluster ).getInt( quartzOresPerCluster );
minMeteoriteDistanceSq = minMeteoriteDistance * minMeteoriteDistance;
WirelessBaseCost = get( "wireless", "WirelessBaseCost", WirelessBaseCost ).getDouble( WirelessBaseCost );
WirelessCostMultiplier = get( "wireless", "WirelessCostMultiplier", WirelessCostMultiplier ).getDouble( WirelessCostMultiplier );
WirelessBaseRange = get( "wireless", "WirelessBaseRange", WirelessBaseRange ).getDouble( WirelessBaseRange );

View file

@ -21,7 +21,7 @@ public class FacadeConfig extends Configuration
replacementPattern = Pattern.compile( "[^a-zA-Z0-9]" );
}
public boolean checkEnabled(Block id, boolean automatic)
public boolean checkEnabled(Block id, int metadata, boolean automatic)
{
if ( id == null )
return false;
@ -34,7 +34,7 @@ public class FacadeConfig extends Configuration
try
{
if ( f.get( Block.class ) == id )
return get( "minecraft", f.getName(), automatic ).getBoolean( automatic );
return get( "minecraft", f.getName() + (metadata == 0 ? "" : "." + metadata), automatic ).getBoolean( automatic );
}
catch (Throwable e)
{
@ -46,7 +46,7 @@ public class FacadeConfig extends Configuration
{
Matcher mod = replacementPattern.matcher( blk.modId );
Matcher name = replacementPattern.matcher( blk.name );
return get( mod.replaceAll( "" ), name.replaceAll( "" ), automatic ).getBoolean( automatic );
return get( mod.replaceAll( "" ), name.replaceAll( "" ) + (metadata == 0 ? "" : "." + metadata), automatic ).getBoolean( automatic );
}
return false;

View file

@ -14,6 +14,7 @@ import net.minecraft.inventory.Container;
import appeng.api.config.FuzzyMode;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigureableObject;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerCellWorkbench;
import appeng.container.implementations.ContainerLevelEmitter;
import appeng.container.implementations.ContainerPriority;
@ -115,7 +116,11 @@ public class PacketValueConfig extends AppEngPacket
{
Container c = player.openContainer;
if ( c instanceof IConfigureableObject )
if ( Name.equals( "CustomName" ) && c instanceof AEBaseContainer )
{
((AEBaseContainer) c).customName = Value;
}
else if ( c instanceof IConfigureableObject )
{
IConfigManager cm = ((IConfigureableObject) c).getConfigManager();

View file

@ -0,0 +1,10 @@
package appeng.helpers;
public interface ICustomNameObject
{
String getCustomName();
boolean hasCustomName();
}

View file

@ -7,6 +7,7 @@ import java.util.concurrent.Future;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import appeng.api.util.DimensionalCoord;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.WorldSettings;
import appeng.helpers.MeteoritePlacer;
@ -48,7 +49,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator
future.get();
if ( obj.distance > 1000 * 500 )
if ( obj.distance > AEConfig.instance.minMeteoriteDistanceSq )
{
int depth = 180 + r.nextInt( 20 );
for (int trys = 0; trys < 20; trys++)

View file

@ -23,8 +23,8 @@ final public class QuartzWorldGen implements IWorldGenerator
if ( normal != null && charged != null )
{
oreNormal = new WorldGenMinable( normal, 0, AEConfig.instance.oresPerCluster, Blocks.stone );
oreCharged = new WorldGenMinable( charged, 0, AEConfig.instance.oresPerCluster, Blocks.stone );
oreNormal = new WorldGenMinable( normal, 0, AEConfig.instance.quartzOresPerCluster, Blocks.stone );
oreCharged = new WorldGenMinable( charged, 0, AEConfig.instance.quartzOresPerCluster, Blocks.stone );
}
else
oreNormal = oreCharged = null;
@ -43,7 +43,7 @@ final public class QuartzWorldGen implements IWorldGenerator
for (int x = 0; x < (r.nextBoolean() ? scale * 2 : scale) / 2; ++x)
{
WorldGenMinable whichOre = r.nextFloat() > 0.92 ? oreCharged : oreNormal;
WorldGenMinable whichOre = r.nextFloat() > AEConfig.instance.spawnChargedChance ? oreCharged : oreNormal;
int a = chunkX * 16 + r.nextInt( 22 );
int b = r.nextInt( 40 * sealevel / 64 ) + r.nextInt( 22 * sealevel / 64 ) + 12 * sealevel / 64;
int c = chunkZ * 16 + r.nextInt( 22 );

View file

@ -104,36 +104,41 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem
for (Object blk : Block.blockRegistry)
{
Block b = (Block) blk;
if ( b != null
&& FacadeConfig.instance.checkEnabled( b, b.isOpaqueCube() && !b.getTickRandomly() && !(b instanceof OreQuartz)
|| b instanceof BlockGlass ) )
try
{
try
Item item = Item.getItemFromBlock( b );
List<ItemStack> tmpList = new ArrayList();
b.getSubBlocks( item, b.getCreativeTabToDisplayOn(), tmpList );
for (ItemStack l : tmpList)
{
Item item = Item.getItemFromBlock( b );
if ( l.hasTagCompound() )
continue;
List<ItemStack> tmpList = new ArrayList();
b.getSubBlocks( item, b.getCreativeTabToDisplayOn(), tmpList );
for (ItemStack l : tmpList)
int metadata = l.getItem().getMetadata( l.getItemDamage() );
boolean hasTile = b.hasTileEntity( metadata );
boolean enableGlass = b instanceof BlockGlass;
boolean disableOre = b instanceof OreQuartz;
boolean defaultValue = (b.isOpaqueCube() && !b.getTickRandomly() && !hasTile && !disableOre) || enableGlass;
if ( FacadeConfig.instance.checkEnabled( b, metadata, defaultValue ) )
{
if ( l.hasTagCompound() )
continue;
ItemStack is = new ItemStack( this );
NBTTagCompound data = new NBTTagCompound();
int[] ds = new int[2];
ds[0] = Item.getIdFromItem( l.getItem() );
ds[1] = l.getItem().getMetadata( l.getItemDamage() );
ds[1] = metadata;
data.setIntArray( "x", ds );
is.setTagCompound( data );
subTypes.add( is );
}
}
catch (Throwable t)
{
// just absorb..
}
}
catch (Throwable t)
{
// just absorb..
}
}

View file

@ -232,10 +232,9 @@ public class EnergyGridCache implements IEnergyGrid
double max = ps.getAEMaxPower();
double current = ps.getAECurrentPower();
globalMaxPower += ps.getAEMaxPower();
if ( current > 0 && ps.getPowerFlow() != AccessRestriction.WRITE )
{
globalMaxPower += ps.getAEMaxPower();
globalAvailablePower += ((IAEPowerStorage) machine).getAECurrentPower();
providers.add( ps );
}
@ -273,7 +272,10 @@ public class EnergyGridCache implements IEnergyGrid
if ( ps.isAEPublicPowerStorage() )
{
if ( ps.getPowerFlow() != AccessRestriction.WRITE )
{
globalMaxPower -= ps.getAEMaxPower();
globalAvailablePower -= ps.getAECurrentPower();
}
if ( lastProvider == machine )
lastProvider = null;
@ -281,8 +283,6 @@ public class EnergyGridCache implements IEnergyGrid
if ( lastRequestor == machine )
lastRequestor = null;
globalMaxPower -= ps.getAEMaxPower();
providers.remove( machine );
requesters.remove( machine );
}

View file

@ -38,6 +38,8 @@ import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigureableObject;
import appeng.core.AELog;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.IPriorityHost;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
@ -48,7 +50,7 @@ import appeng.util.SettingsFrom;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost
public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradeableHost, ICustomNameObject
{
protected ISimplifiedBundle renderCache = null;
@ -62,6 +64,7 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
public AEBasePart(Class c, ItemStack is) {
this.is = is;
AELog.info( System.identityHashCode( is ) + " = " + is.getDisplayName() );
proxy = new AENetworkProxy( this, "part", is, this instanceof PartCable );
proxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
}
@ -95,6 +98,12 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
@Override
public ItemStack getItemStack(PartItemStack type)
{
if ( type == PartItemStack.Network )
{
ItemStack copy = is.copy();
copy.setTagCompound( null );
return copy;
}
return is;
}
@ -472,4 +481,18 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
{
return false;
}
@Override
public String getCustomName()
{
return is.getDisplayName();
}
@Override
public boolean hasCustomName()
{
AELog.info( System.identityHashCode( is ) + " = " + is.getDisplayName() );
return is.hasDisplayName();
}
}

View file

@ -556,7 +556,6 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
if ( p != null )
{
is = p.getItemStack( PartItemStack.Network );
is.setTagCompound( null );
data.writeShort( Item.getIdFromItem( is.getItem() ) );
data.writeShort( is.getItemDamage() );

View file

@ -306,6 +306,21 @@ public class PartPlacement
if ( !world.isRemote )
{
Block block = world.getBlock( x, y, z );
LookDirection dir = Platform.getPlayerRay( player );
MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
if ( mop != null )
{
List<ItemStack> is = new LinkedList();
SelectedPart sp = host.selectPart( mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );
if ( sp.part != null )
{
if ( !player.isSneaking() && sp.part.onActivate( player, mop.hitVec ) )
return false;
}
}
ForgeDirection mySide = host.addPart( held, side, player );
if ( mySide != null )
{

View file

@ -13,6 +13,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable;
@ -255,6 +256,24 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
energy.extractAEPower( total, Actionable.MODULATE, PowerMultiplier.CONFIG );
w.setBlock( x, y, z, Platform.air, 0, 3 );
AxisAlignedBB box = AxisAlignedBB.getBoundingBox( x - 0.2, y - 0.2, z - 0.2, x + 1.2, y + 1.2, z + 1.2 );
for (Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ))
{
if ( ei instanceof EntityItem )
{
EntityItem item = (EntityItem) ei;
if ( !item.isDead )
{
IAEItemStack storedItem = AEItemStack.create( item.getEntityItem() );
storedItem = Platform.poweredInsert( energy, storage.getItemInventory(), storedItem, mySrc );
if ( storedItem != null )
Buffer.add( storedItem );
item.setDead();
}
}
}
try
{
ServerHelper.proxy.sendToAllNearExcept( null, x, y, z, 64, w, new PacketTransitionEffect( x, y, z, side, true ) );
@ -264,9 +283,9 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
AELog.error( e );
}
for (ItemStack is : out)
for (ItemStack snaggedItem : out)
{
IAEItemStack storedItem = AEItemStack.create( is );
IAEItemStack storedItem = AEItemStack.create( snaggedItem );
storedItem = Platform.poweredInsert( energy, storage.getItemInventory(), storedItem, mySrc );
if ( storedItem != null )
Buffer.add( storedItem );

View file

@ -80,18 +80,6 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor
getInternalInventory().setInventorySlotContents( i, itemstack );
}
@Override
public String getInventoryName()
{
return getClass().getSimpleName();
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public void openInventory()
{
@ -151,4 +139,23 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor
}
return getAccessibleSlotsBySide( ForgeDirection.getOrientation( side ) );
}
/**
* Returns the name of the inventory
*/
@Override
public String getInventoryName()
{
return getCustomName();
}
/**
* Returns if the inventory is named
*/
@Override
public boolean hasCustomInventoryName()
{
return hasCustomName();
}
}

View file

@ -27,6 +27,7 @@ import appeng.api.util.IConfigureableObject;
import appeng.api.util.IOrientable;
import appeng.core.AELog;
import appeng.core.features.ItemStackSrc;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.IPriorityHost;
import appeng.tile.events.AETileEventHandler;
import appeng.tile.events.TileEventType;
@ -34,7 +35,7 @@ import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject
{
private final EnumMap<TileEventType, List<AETileEventHandler>> handlers = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class );
@ -45,6 +46,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
public boolean dropItems = true;
public int renderFragment = 0;
public String customName;
public TileEntity getTile()
{
@ -120,6 +122,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
data.setString( "orientation_up", up.name() );
}
if ( customName != null )
data.setString( "customName", customName );
for (AETileEventHandler h : getHandlerListFor( TileEventType.WORLD_NBT ))
h.writeToNBT( data );
}
@ -129,6 +134,11 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
{
super.readFromNBT( data );
if ( data.hasKey( "customName" ) )
customName = data.getString( "customName" );
else
customName = null;
try
{
if ( canBeRotated() )
@ -413,4 +423,21 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
return false;
}
public void setName(String name)
{
this.customName = name;
}
@Override
public String getCustomName()
{
return hasCustomName() ? customName : getClass().getSimpleName();
}
@Override
public boolean hasCustomName()
{
return customName != null && customName.length() > 0;
}
}