diff --git a/block/AEBaseBlock.java b/block/AEBaseBlock.java index cca56d426..9d7e4746e 100644 --- a/block/AEBaseBlock.java +++ b/block/AEBaseBlock.java @@ -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() ); + } + } + } diff --git a/block/networking/BlockController.java b/block/networking/BlockController.java index 90152f656..ce34bfd77 100644 --- a/block/networking/BlockController.java +++ b/block/networking/BlockController.java @@ -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 diff --git a/client/ClientHelper.java b/client/ClientHelper.java index e3c10dd4d..7eb035281 100644 --- a/client/ClientHelper.java +++ b/client/ClientHelper.java @@ -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; diff --git a/client/gui/AEBaseGui.java b/client/gui/AEBaseGui.java index 66d83b3df..04832566a 100644 --- a/client/gui/AEBaseGui.java +++ b/client/gui/AEBaseGui.java @@ -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) diff --git a/client/gui/implementations/GuiChest.java b/client/gui/implementations/GuiChest.java index c360b6864..fb7bd9d3c 100644 --- a/client/gui/implementations/GuiChest.java +++ b/client/gui/implementations/GuiChest.java @@ -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 ); } diff --git a/client/gui/implementations/GuiCondenser.java b/client/gui/implementations/GuiCondenser.java index 87e8f102a..6ec39a991 100644 --- a/client/gui/implementations/GuiCondenser.java +++ b/client/gui/implementations/GuiCondenser.java @@ -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 ); diff --git a/client/gui/implementations/GuiDrive.java b/client/gui/implementations/GuiDrive.java index 9d0a29353..cf1d49200 100644 --- a/client/gui/implementations/GuiDrive.java +++ b/client/gui/implementations/GuiDrive.java @@ -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 ); } diff --git a/client/gui/implementations/GuiFormationPlane.java b/client/gui/implementations/GuiFormationPlane.java index f7f0dbd37..e8f6fbcae 100644 --- a/client/gui/implementations/GuiFormationPlane.java +++ b/client/gui/implementations/GuiFormationPlane.java @@ -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 ) diff --git a/client/gui/implementations/GuiGrinder.java b/client/gui/implementations/GuiGrinder.java index 5e3faeb98..e7c0b0fd4 100644 --- a/client/gui/implementations/GuiGrinder.java +++ b/client/gui/implementations/GuiGrinder.java @@ -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 ); } diff --git a/client/gui/implementations/GuiIOPort.java b/client/gui/implementations/GuiIOPort.java index 5be80bdea..29d92b15d 100644 --- a/client/gui/implementations/GuiIOPort.java +++ b/client/gui/implementations/GuiIOPort.java @@ -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 ) diff --git a/client/gui/implementations/GuiInscriber.java b/client/gui/implementations/GuiInscriber.java index 5cf5f2721..0d6ea4eeb 100644 --- a/client/gui/implementations/GuiInscriber.java +++ b/client/gui/implementations/GuiInscriber.java @@ -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 ); } diff --git a/client/gui/implementations/GuiInterface.java b/client/gui/implementations/GuiInterface.java index a77949df8..a25067839 100644 --- a/client/gui/implementations/GuiInterface.java +++ b/client/gui/implementations/GuiInterface.java @@ -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 ); diff --git a/client/gui/implementations/GuiMEMonitorable.java b/client/gui/implementations/GuiMEMonitorable.java index 9ceb67f02..fdf5c1ac7 100644 --- a/client/gui/implementations/GuiMEMonitorable.java +++ b/client/gui/implementations/GuiMEMonitorable.java @@ -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 ); } diff --git a/client/gui/implementations/GuiNetworkTool.java b/client/gui/implementations/GuiNetworkTool.java index 3bf3025fe..c919a3d79 100644 --- a/client/gui/implementations/GuiNetworkTool.java +++ b/client/gui/implementations/GuiNetworkTool.java @@ -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 ); } diff --git a/client/gui/implementations/GuiQNB.java b/client/gui/implementations/GuiQNB.java index bd90dda30..51ed51184 100644 --- a/client/gui/implementations/GuiQNB.java +++ b/client/gui/implementations/GuiQNB.java @@ -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 ); } diff --git a/client/gui/implementations/GuiQuartzKnife.java b/client/gui/implementations/GuiQuartzKnife.java index e758568da..3809010aa 100644 --- a/client/gui/implementations/GuiQuartzKnife.java +++ b/client/gui/implementations/GuiQuartzKnife.java @@ -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 ); } diff --git a/client/gui/implementations/GuiSkyChest.java b/client/gui/implementations/GuiSkyChest.java index 9587170ab..8e0e9836f 100644 --- a/client/gui/implementations/GuiSkyChest.java +++ b/client/gui/implementations/GuiSkyChest.java @@ -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 ); } diff --git a/client/gui/implementations/GuiSpatialIOPort.java b/client/gui/implementations/GuiSpatialIOPort.java index 5dcbf6363..f66deb75e 100644 --- a/client/gui/implementations/GuiSpatialIOPort.java +++ b/client/gui/implementations/GuiSpatialIOPort.java @@ -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 ); } diff --git a/client/gui/implementations/GuiStorageBus.java b/client/gui/implementations/GuiStorageBus.java index ee50eb843..894e3b366 100644 --- a/client/gui/implementations/GuiStorageBus.java +++ b/client/gui/implementations/GuiStorageBus.java @@ -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 ) diff --git a/client/gui/implementations/GuiUpgradeable.java b/client/gui/implementations/GuiUpgradeable.java index 6963f6dfe..4c8429d12 100644 --- a/client/gui/implementations/GuiUpgradeable.java +++ b/client/gui/implementations/GuiUpgradeable.java @@ -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 ) diff --git a/client/gui/implementations/GuiVibrationChamber.java b/client/gui/implementations/GuiVibrationChamber.java index 4c75340dc..f645b0ce1 100644 --- a/client/gui/implementations/GuiVibrationChamber.java +++ b/client/gui/implementations/GuiVibrationChamber.java @@ -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; diff --git a/client/gui/implementations/GuiWireless.java b/client/gui/implementations/GuiWireless.java index fabbf9567..23a10fe79 100644 --- a/client/gui/implementations/GuiWireless.java +++ b/client/gui/implementations/GuiWireless.java @@ -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 ); } diff --git a/client/render/BusRenderer.java b/client/render/BusRenderer.java index 7b365ddf6..63a21117e 100644 --- a/client/render/BusRenderer.java +++ b/client/render/BusRenderer.java @@ -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 ) { diff --git a/client/render/blocks/RendererCableBus.java b/client/render/blocks/RendererCableBus.java index 27bdaeaf6..3fe3b50f7 100644 --- a/client/render/blocks/RendererCableBus.java +++ b/client/render/blocks/RendererCableBus.java @@ -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 ); } } diff --git a/container/AEBaseContainer.java b/container/AEBaseContainer.java index 90c599559..b2513422a 100644 --- a/container/AEBaseContainer.java +++ b/container/AEBaseContainer.java @@ -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++) diff --git a/core/AEConfig.java b/core/AEConfig.java index 6dbfa7294..19cfd6a91 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -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 ); diff --git a/core/FacadeConfig.java b/core/FacadeConfig.java index 7b5c943ba..e1fa9c0a4 100644 --- a/core/FacadeConfig.java +++ b/core/FacadeConfig.java @@ -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; diff --git a/core/sync/packets/PacketValueConfig.java b/core/sync/packets/PacketValueConfig.java index 270142a2b..bebf8d1c9 100644 --- a/core/sync/packets/PacketValueConfig.java +++ b/core/sync/packets/PacketValueConfig.java @@ -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(); diff --git a/helpers/ICustomNameObject.java b/helpers/ICustomNameObject.java new file mode 100644 index 000000000..e4a951149 --- /dev/null +++ b/helpers/ICustomNameObject.java @@ -0,0 +1,10 @@ +package appeng.helpers; + +public interface ICustomNameObject +{ + + String getCustomName(); + + boolean hasCustomName(); + +} diff --git a/hooks/MeteoriteWorldGen.java b/hooks/MeteoriteWorldGen.java index 4c2c2472e..9282e64a1 100644 --- a/hooks/MeteoriteWorldGen.java +++ b/hooks/MeteoriteWorldGen.java @@ -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++) diff --git a/hooks/QuartzWorldGen.java b/hooks/QuartzWorldGen.java index b27d73414..93e08fbef 100644 --- a/hooks/QuartzWorldGen.java +++ b/hooks/QuartzWorldGen.java @@ -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 ); diff --git a/items/parts/ItemFacade.java b/items/parts/ItemFacade.java index 7608fbc86..517ac71dd 100644 --- a/items/parts/ItemFacade.java +++ b/items/parts/ItemFacade.java @@ -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 tmpList = new ArrayList(); + b.getSubBlocks( item, b.getCreativeTabToDisplayOn(), tmpList ); + for (ItemStack l : tmpList) { - Item item = Item.getItemFromBlock( b ); + if ( l.hasTagCompound() ) + continue; - List 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.. } } diff --git a/me/cache/EnergyGridCache.java b/me/cache/EnergyGridCache.java index f46bf792b..3d2d72887 100644 --- a/me/cache/EnergyGridCache.java +++ b/me/cache/EnergyGridCache.java @@ -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 ); } diff --git a/parts/AEBasePart.java b/parts/AEBasePart.java index 2bd291c6b..1f5ced26e 100644 --- a/parts/AEBasePart.java +++ b/parts/AEBasePart.java @@ -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(); + } + } \ No newline at end of file diff --git a/parts/CableBusContainer.java b/parts/CableBusContainer.java index 20f362d0e..bb2f7678a 100644 --- a/parts/CableBusContainer.java +++ b/parts/CableBusContainer.java @@ -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() ); diff --git a/parts/PartPlacement.java b/parts/PartPlacement.java index 25994c525..c7756858f 100644 --- a/parts/PartPlacement.java +++ b/parts/PartPlacement.java @@ -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 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 ) { diff --git a/parts/automation/PartAnnihilationPlane.java b/parts/automation/PartAnnihilationPlane.java index 80f249489..eb79269b0 100644 --- a/parts/automation/PartAnnihilationPlane.java +++ b/parts/automation/PartAnnihilationPlane.java @@ -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 ); diff --git a/tile/AEBaseInvTile.java b/tile/AEBaseInvTile.java index 13f60881e..84a019182 100644 --- a/tile/AEBaseInvTile.java +++ b/tile/AEBaseInvTile.java @@ -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(); + } + } diff --git a/tile/AEBaseTile.java b/tile/AEBaseTile.java index 420791898..af7a71234 100644 --- a/tile/AEBaseTile.java +++ b/tile/AEBaseTile.java @@ -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> handlers = new EnumMap>( 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; + } + }