From 929efa55971c5bbb6dc7a41734aa574f303f9bbd Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 4 Mar 2014 21:12:23 -0600 Subject: [PATCH] Added 4 View Cell Slots. Multiple View Cells now sum together to allow more customization. View Cells are now protected by Build Security. Meteorite Compass now renders correctly in other peoples hands. --- .../gui/implementations/GuiMEMonitorable.java | 16 +++- client/me/ItemRepo.java | 95 ++++++++++--------- client/render/BaseBlockRender.java | 2 +- client/render/ItemRenderer.java | 2 +- client/render/WorldRender.java | 4 +- client/render/blocks/RenderBlockCharger.java | 2 +- client/render/blocks/RenderBlockCrank.java | 6 +- .../render/blocks/RenderBlockEnergyCube.java | 4 +- client/render/blocks/RenderBlockSkyChest.java | 2 +- .../render/blocks/RenderBlockSkyCompass.java | 10 +- client/render/blocks/RenderBlockWireless.java | 2 +- client/render/blocks/RenderDrive.java | 4 +- client/render/blocks/RenderMEChest.java | 4 +- client/render/blocks/RenderNull.java | 2 +- client/render/blocks/RenderQNB.java | 4 +- client/render/blocks/RenderQuartzGlass.java | 6 +- client/render/blocks/RenderQuartzOre.java | 6 +- client/render/blocks/RenderQuartzTorch.java | 2 +- client/render/blocks/RenderSpatialPylon.java | 6 +- client/render/blocks/RenderTinyTNT.java | 4 +- client/render/blocks/RendererCableBus.java | 2 +- client/render/blocks/RendererSecurity.java | 4 +- container/AEBaseContainer.java | 22 ++--- .../ContainerMEMonitorable.java | 45 ++++++++- container/slot/SlotRestrictedInput.java | 12 +++ core/sync/packets/PacketCompassRequest.java | 2 +- hooks/MeteoriteWorldGen.java | 2 +- parts/reporting/PartTerminal.java | 2 +- services/CompassService.java | 4 +- util/prioitylist/MergedPriorityList.java | 52 ++++++++++ 30 files changed, 228 insertions(+), 102 deletions(-) create mode 100644 util/prioitylist/MergedPriorityList.java diff --git a/client/gui/implementations/GuiMEMonitorable.java b/client/gui/implementations/GuiMEMonitorable.java index 09893aff..9ceb67f0 100644 --- a/client/gui/implementations/GuiMEMonitorable.java +++ b/client/gui/implementations/GuiMEMonitorable.java @@ -64,7 +64,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi GuiImgButton searchBoxSettings; boolean viewCell; - ItemStack currentViewCell; + ItemStack myCurrentViewCells[] = new ItemStack[5]; ContainerMEMonitorable mecontainer; public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te) { @@ -277,11 +277,19 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi if ( viewCell ) { - if ( currentViewCell != mecontainer.cellView.getStack() ) + boolean update = false; + + for (int i = 0; i < 5; i++) { - currentViewCell = mecontainer.cellView.getStack(); - repo.setViewCell( currentViewCell ); + if ( myCurrentViewCells[i] != mecontainer.cellView[i].getStack() ) + { + update = true; + myCurrentViewCells[i] = mecontainer.cellView[i].getStack(); + } } + + if ( update ) + repo.setViewCell( myCurrentViewCells ); } if ( searchField != null ) diff --git a/client/me/ItemRepo.java b/client/me/ItemRepo.java index 98ab48cc..4fd5970e 100644 --- a/client/me/ItemRepo.java +++ b/client/me/ItemRepo.java @@ -24,6 +24,7 @@ import appeng.util.Platform; import appeng.util.item.AEItemStack; import appeng.util.prioitylist.FuzzyPriorityList; import appeng.util.prioitylist.IPartitionList; +import appeng.util.prioitylist.MergedPriorityList; import appeng.util.prioitylist.PrecisePriorityList; public class ItemRepo @@ -80,65 +81,73 @@ public class ItemRepo list.add( is ); } - boolean hasInverter = false; - boolean hasFuzzy = false; IPartitionList myPartitionList; - public void setViewCell(ItemStack currentViewCell) + public void setViewCell(ItemStack[] list) { - if ( currentViewCell == null || !(currentViewCell.getItem() instanceof ItemViewCell) ) - myPartitionList = null; - else + myPartitionList = null; + MergedPriorityList myMergedList = new MergedPriorityList(); + + for (ItemStack currentViewCell : list) { - IItemList priorityList = AEApi.instance().storage().createItemList(); + if ( currentViewCell == null ) + continue; - ItemViewCell vc = (ItemViewCell) currentViewCell.getItem(); - IInventory upgrades = vc.getUpgradesInventory( currentViewCell ); - IInventory config = vc.getConfigInventory( currentViewCell ); - FuzzyMode fzMode = vc.getFuzzyMode( currentViewCell ); - - hasInverter = false; - hasFuzzy = false; - - for (int x = 0; x < upgrades.getSizeInventory(); x++) + if ( (currentViewCell.getItem() instanceof ItemViewCell) ) { - ItemStack is = upgrades.getStackInSlot( x ); - if ( is != null && is.getItem() instanceof IUpgradeModule ) + boolean hasInverter = false; + boolean hasFuzzy = false; + IItemList priorityList = AEApi.instance().storage().createItemList(); + + ItemViewCell vc = (ItemViewCell) currentViewCell.getItem(); + IInventory upgrades = vc.getUpgradesInventory( currentViewCell ); + IInventory config = vc.getConfigInventory( currentViewCell ); + FuzzyMode fzMode = vc.getFuzzyMode( currentViewCell ); + + hasInverter = false; + hasFuzzy = false; + + for (int x = 0; x < upgrades.getSizeInventory(); x++) { - Upgrades u = ((IUpgradeModule) is.getItem()).getType( is ); - if ( u != null ) + ItemStack is = upgrades.getStackInSlot( x ); + if ( is != null && is.getItem() instanceof IUpgradeModule ) { - switch (u) + Upgrades u = ((IUpgradeModule) is.getItem()).getType( is ); + if ( u != null ) { - case FUZZY: - hasFuzzy = true; - break; - case INVERTER: - hasInverter = true; - break; - default: + switch (u) + { + case FUZZY: + hasFuzzy = true; + break; + case INVERTER: + hasInverter = true; + break; + default: + } } } } - } - for (int x = 0; x < config.getSizeInventory(); x++) - { - ItemStack is = config.getStackInSlot( x ); - if ( is != null ) - priorityList.add( AEItemStack.create( is ) ); - } + for (int x = 0; x < config.getSizeInventory(); x++) + { + ItemStack is = config.getStackInSlot( x ); + if ( is != null ) + priorityList.add( AEItemStack.create( is ) ); + } - // myWhitelist = hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST; + if ( !priorityList.isEmpty() ) + { + if ( hasFuzzy ) + myMergedList.addNewList( new FuzzyPriorityList( priorityList, fzMode ), !hasInverter ); + else + myMergedList.addNewList( new PrecisePriorityList( priorityList ), !hasInverter ); - if ( !priorityList.isEmpty() ) - { - if ( hasFuzzy ) - myPartitionList = new FuzzyPriorityList( priorityList, fzMode ); - else - myPartitionList = new PrecisePriorityList( priorityList ); + myPartitionList = myMergedList; + } } } + updateView(); } @@ -175,7 +184,7 @@ public class ItemRepo { if ( myPartitionList != null ) { - if ( hasInverter == myPartitionList.isListed( is ) ) + if ( !myPartitionList.isListed( is ) ) continue; } diff --git a/client/render/BaseBlockRender.java b/client/render/BaseBlockRender.java index d28aa301..b068301a 100644 --- a/client/render/BaseBlockRender.java +++ b/client/render/BaseBlockRender.java @@ -357,7 +357,7 @@ public class BaseBlockRender } } - public void renderInventory(AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] data) { Tessellator tess = Tessellator.instance; diff --git a/client/render/ItemRenderer.java b/client/render/ItemRenderer.java index 0e8fafb5..3a612941 100644 --- a/client/render/ItemRenderer.java +++ b/client/render/ItemRenderer.java @@ -38,7 +38,7 @@ public class ItemRenderer implements IItemRenderer if ( type == ItemRenderType.INVENTORY ) GL11.glTranslatef( 0.0f, -0.1f, 0.0f ); - WorldRender.instance.renderItemBlock( item, type ); + WorldRender.instance.renderItemBlock( item, type, data ); GL11.glPopAttrib(); GL11.glPopMatrix(); diff --git a/client/render/WorldRender.java b/client/render/WorldRender.java index 78ff6bd0..0c90efd3 100644 --- a/client/render/WorldRender.java +++ b/client/render/WorldRender.java @@ -58,7 +58,7 @@ public class WorldRender implements ISimpleBlockRenderingHandler return renderID; } - public void renderItemBlock(ItemStack item, ItemRenderType type) + public void renderItemBlock(ItemStack item, ItemRenderType type, Object[] data) { Block blk = Block.getBlockFromItem( item.getItem() ); if ( blk instanceof AEBaseBlock ) @@ -67,7 +67,7 @@ public class WorldRender implements ISimpleBlockRenderingHandler renderer.setRenderBoundsFromBlock( block ); renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; - getRender( block ).renderInventory( block, item, renderer, type ); + getRender( block ).renderInventory( block, item, renderer, type, data ); renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; } else diff --git a/client/render/blocks/RenderBlockCharger.java b/client/render/blocks/RenderBlockCharger.java index ae9a84dd..d576511c 100644 --- a/client/render/blocks/RenderBlockCharger.java +++ b/client/render/blocks/RenderBlockCharger.java @@ -32,7 +32,7 @@ public class RenderBlockCharger extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { Tessellator tess = Tessellator.instance; diff --git a/client/render/blocks/RenderBlockCrank.java b/client/render/blocks/RenderBlockCrank.java index cdad2fcd..2519513f 100644 --- a/client/render/blocks/RenderBlockCrank.java +++ b/client/render/blocks/RenderBlockCrank.java @@ -25,15 +25,15 @@ public class RenderBlockCrank extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { renderer.renderAllFaces = true; renderer.setRenderBounds( 0.5D - 0.05, 0.5D - 0.5, 0.5D - 0.05, 0.5D + 0.05, 0.5D + 0.3, 0.5D + 0.05 ); - super.renderInventory( blk, is, renderer, type ); + super.renderInventory( blk, is, renderer, type, obj ); renderer.setRenderBounds( 0.70D - 0.15, 0.75D - 0.05, 0.5D - 0.05, 0.70D + 0.28, 0.75D + 0.05, 0.5D + 0.05 ); - super.renderInventory( blk, is, renderer, type ); + super.renderInventory( blk, is, renderer, type, obj ); renderer.renderAllFaces = false; } diff --git a/client/render/blocks/RenderBlockEnergyCube.java b/client/render/blocks/RenderBlockEnergyCube.java index c701ce2e..16203fa0 100644 --- a/client/render/blocks/RenderBlockEnergyCube.java +++ b/client/render/blocks/RenderBlockEnergyCube.java @@ -16,7 +16,7 @@ public class RenderBlockEnergyCube extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { IAEItemPowerStorage myItem = (IAEItemPowerStorage) is.getItem(); double internalCurrentPower = myItem.getAECurrentPower( is ); @@ -30,7 +30,7 @@ public class RenderBlockEnergyCube extends BaseBlockRender meta = 0; renderer.setOverrideBlockTexture( blk.getIcon( 0, meta ) ); - super.renderInventory( blk, is, renderer, type ); + super.renderInventory( blk, is, renderer, type, obj ); renderer.setOverrideBlockTexture( null ); } diff --git a/client/render/blocks/RenderBlockSkyChest.java b/client/render/blocks/RenderBlockSkyChest.java index e84890fe..5758acf5 100644 --- a/client/render/blocks/RenderBlockSkyChest.java +++ b/client/render/blocks/RenderBlockSkyChest.java @@ -26,7 +26,7 @@ public class RenderBlockSkyChest extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */); GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F ); diff --git a/client/render/blocks/RenderBlockSkyCompass.java b/client/render/blocks/RenderBlockSkyCompass.java index d826a580..3e2a2f2a 100644 --- a/client/render/blocks/RenderBlockSkyCompass.java +++ b/client/render/blocks/RenderBlockSkyCompass.java @@ -31,7 +31,7 @@ public class RenderBlockSkyCompass extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */); GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F ); @@ -62,10 +62,16 @@ public class RenderBlockSkyCompass extends BaseBlockRender } long now = System.currentTimeMillis(); - if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.INVENTORY ) + if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.INVENTORY || type == ItemRenderType.EQUIPPED ) { EntityPlayer p = Minecraft.getMinecraft().thePlayer; + if ( type == ItemRenderType.EQUIPPED ) + { + p = (EntityPlayer) obj[1]; + p.rotationYaw = p.renderYawOffset; + } + int x = (int) p.posX; int y = (int) p.posY; int z = (int) p.posZ; diff --git a/client/render/blocks/RenderBlockWireless.java b/client/render/blocks/RenderBlockWireless.java index 0d5f0abc..69be2935 100644 --- a/client/render/blocks/RenderBlockWireless.java +++ b/client/render/blocks/RenderBlockWireless.java @@ -27,7 +27,7 @@ public class RenderBlockWireless extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { this.blk = blk; cenx = 0; diff --git a/client/render/blocks/RenderDrive.java b/client/render/blocks/RenderDrive.java index 241fd524..317a4e61 100644 --- a/client/render/blocks/RenderDrive.java +++ b/client/render/blocks/RenderDrive.java @@ -23,13 +23,13 @@ public class RenderDrive extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { renderer.overrideBlockTexture = ExtraTextures.getMissing(); this.renderInvBlock( EnumSet.of( ForgeDirection.SOUTH ), block, is, Tessellator.instance, 0x000000, renderer ); renderer.overrideBlockTexture = null; - super.renderInventory( block, is, renderer, type ); + super.renderInventory( block, is, renderer, type, obj ); } @Override diff --git a/client/render/blocks/RenderMEChest.java b/client/render/blocks/RenderMEChest.java index ea5af430..91cf3d72 100644 --- a/client/render/blocks/RenderMEChest.java +++ b/client/render/blocks/RenderMEChest.java @@ -27,7 +27,7 @@ public class RenderMEChest extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { renderer.overrideBlockTexture = ExtraTextures.getMissing(); this.renderInvBlock( EnumSet.of( ForgeDirection.SOUTH ), block, is, Tessellator.instance, 0x000000, renderer ); @@ -36,7 +36,7 @@ public class RenderMEChest extends BaseBlockRender this.renderInvBlock( EnumSet.of( ForgeDirection.UP ), block, is, Tessellator.instance, 0xffffff, renderer ); renderer.overrideBlockTexture = null; - super.renderInventory( block, is, renderer, type ); + super.renderInventory( block, is, renderer, type, obj ); } @Override diff --git a/client/render/blocks/RenderNull.java b/client/render/blocks/RenderNull.java index 20678024..7cf8cdad 100644 --- a/client/render/blocks/RenderNull.java +++ b/client/render/blocks/RenderNull.java @@ -15,7 +15,7 @@ public class RenderNull extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { } diff --git a/client/render/blocks/RenderQNB.java b/client/render/blocks/RenderQNB.java index 5a5a2c13..c8e0baa8 100644 --- a/client/render/blocks/RenderQNB.java +++ b/client/render/blocks/RenderQNB.java @@ -72,13 +72,13 @@ public class RenderQNB extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] obj) { float px = 2.0f / 16.0f; float maxpx = 14.0f / 16.0f; renderer.setRenderBounds( px, px, px, maxpx, maxpx, maxpx ); - super.renderInventory( block, item, renderer, type ); + super.renderInventory( block, item, renderer, type, obj ); } @Override diff --git a/client/render/blocks/RenderQuartzGlass.java b/client/render/blocks/RenderQuartzGlass.java index 651cac6f..5450cb9c 100644 --- a/client/render/blocks/RenderQuartzGlass.java +++ b/client/render/blocks/RenderQuartzGlass.java @@ -114,12 +114,12 @@ public class RenderQuartzGlass extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { renderer.overrideBlockTexture = ExtraTextures.GlassFrame.getIcon(); - super.renderInventory( block, is, renderer, type ); + super.renderInventory( block, is, renderer, type, obj ); renderer.overrideBlockTexture = null; - super.renderInventory( block, is, renderer, type ); + super.renderInventory( block, is, renderer, type, obj ); } @Override diff --git a/client/render/blocks/RenderQuartzOre.java b/client/render/blocks/RenderQuartzOre.java index 6af76552..d382f96a 100644 --- a/client/render/blocks/RenderQuartzOre.java +++ b/client/render/blocks/RenderQuartzOre.java @@ -17,11 +17,11 @@ public class RenderQuartzOre extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { - super.renderInventory( blk, is, renderer, type ); + super.renderInventory( blk, is, renderer, type, obj ); blk.getRendererInstance().setTemporaryRenderIcon( ExtraTextures.OreQuartzStone.getIcon() ); - super.renderInventory( blk, is, renderer, type ); + super.renderInventory( blk, is, renderer, type, obj ); blk.getRendererInstance().setTemporaryRenderIcon( null ); } diff --git a/client/render/blocks/RenderQuartzTorch.java b/client/render/blocks/RenderQuartzTorch.java index 06dc65b4..d0956bc3 100644 --- a/client/render/blocks/RenderQuartzTorch.java +++ b/client/render/blocks/RenderQuartzTorch.java @@ -22,7 +22,7 @@ public class RenderQuartzTorch extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { Tessellator tess = Tessellator.instance; diff --git a/client/render/blocks/RenderSpatialPylon.java b/client/render/blocks/RenderSpatialPylon.java index 3eedf6d0..033f0b92 100644 --- a/client/render/blocks/RenderSpatialPylon.java +++ b/client/render/blocks/RenderSpatialPylon.java @@ -21,12 +21,12 @@ public class RenderSpatialPylon extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { renderer.overrideBlockTexture = ExtraTextures.BlockSpatialPylon_dim.getIcon(); - super.renderInventory( block, is, renderer, type ); + super.renderInventory( block, is, renderer, type, obj ); renderer.overrideBlockTexture = null; - super.renderInventory( block, is, renderer, type ); + super.renderInventory( block, is, renderer, type, obj ); } @Override diff --git a/client/render/blocks/RenderTinyTNT.java b/client/render/blocks/RenderTinyTNT.java index 9cabc9d2..ee7d3b6d 100644 --- a/client/render/blocks/RenderTinyTNT.java +++ b/client/render/blocks/RenderTinyTNT.java @@ -15,10 +15,10 @@ public class RenderTinyTNT extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { renderer.setRenderBounds( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f ); - super.renderInventory( block, is, renderer, type ); + super.renderInventory( block, is, renderer, type, obj ); } @Override diff --git a/client/render/blocks/RendererCableBus.java b/client/render/blocks/RendererCableBus.java index e722beee..27bdaeaf 100644 --- a/client/render/blocks/RendererCableBus.java +++ b/client/render/blocks/RendererCableBus.java @@ -19,7 +19,7 @@ public class RendererCableBus extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock blk, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { // nothin. } diff --git a/client/render/blocks/RendererSecurity.java b/client/render/blocks/RendererSecurity.java index 1fe3f339..cdacfd70 100644 --- a/client/render/blocks/RendererSecurity.java +++ b/client/render/blocks/RendererSecurity.java @@ -22,7 +22,7 @@ public class RendererSecurity extends BaseBlockRender } @Override - public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type) + public void renderInventory(AEBaseBlock block, ItemStack is, RenderBlocks renderer, ItemRenderType type, Object[] obj) { renderer.overrideBlockTexture = ExtraTextures.getMissing(); this.renderInvBlock( EnumSet.of( ForgeDirection.SOUTH ), block, is, Tessellator.instance, 0x000000, renderer ); @@ -31,7 +31,7 @@ public class RendererSecurity extends BaseBlockRender this.renderInvBlock( EnumSet.of( ForgeDirection.UP ), block, is, Tessellator.instance, 0xffffff, renderer ); renderer.overrideBlockTexture = null; - super.renderInventory( block, is, renderer, type ); + super.renderInventory( block, is, renderer, type, obj ); } @Override diff --git a/container/AEBaseContainer.java b/container/AEBaseContainer.java index aa624705..e41d74cc 100644 --- a/container/AEBaseContainer.java +++ b/container/AEBaseContainer.java @@ -70,6 +70,11 @@ public abstract class AEBaseContainer extends Container return; ticksSinceCheck = 0; + isContainerValid = isContainerValid && hasAccess( security, requirePower ); + } + + protected boolean hasAccess(SecurityPermissions perm, boolean requirePower) + { IActionHost host = null; if ( tileEntity instanceof IActionHost ) @@ -77,11 +82,7 @@ public abstract class AEBaseContainer extends Container if ( part instanceof IActionHost ) host = (IActionHost) part; - if ( host == null ) - { - isContainerValid = false; - } - else + if ( host != null ) { IGridNode gn = host.getActionableNode(); if ( gn != null ) @@ -93,18 +94,17 @@ public abstract class AEBaseContainer extends Container { IEnergyGrid eg = g.getCache( IEnergyGrid.class ); if ( !eg.isNetworkPowered() ) - { - isContainerValid = false; - return; - } + return false; } ISecurityGrid sg = g.getCache( ISecurityGrid.class ); - if ( !sg.hasPermission( invPlayer.player, security ) ) - isContainerValid = false; + if ( sg.hasPermission( invPlayer.player, perm ) ) + return true; } } } + + return false; } public ContainerOpenContext openContext; diff --git a/container/implementations/ContainerMEMonitorable.java b/container/implementations/ContainerMEMonitorable.java index ff102bb1..68d363ab 100644 --- a/container/implementations/ContainerMEMonitorable.java +++ b/container/implementations/ContainerMEMonitorable.java @@ -10,6 +10,7 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; +import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; import appeng.api.config.SortDir; import appeng.api.config.SortOrder; @@ -31,7 +32,6 @@ import appeng.api.storage.data.IItemList; import appeng.api.util.IConfigManager; import appeng.api.util.IConfigureableObject; import appeng.container.AEBaseContainer; -import appeng.container.slot.AppEngSlot; import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; import appeng.core.AELog; @@ -51,7 +51,8 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa IConfigManager serverCM; IConfigManager clientCM; - public AppEngSlot cellView; + public boolean canAccessViewCells = false; + public SlotRestrictedInput cellView[] = new SlotRestrictedInput[5]; public IConfigManagerHost gui; @@ -96,8 +97,16 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa else monitor = null; + canAccessViewCells = false; if ( montiorable instanceof IViewCellStorage ) - addSlotToContainer( cellView = new SlotRestrictedInput( PlaceableItemType.VIEWCELL, ((IViewCellStorage) montiorable).getViewCellStorage(), 0, 205, 7 ) ); + { + for (int y = 0; y < 5; y++) + { + cellView[y] = new SlotRestrictedInput( PlaceableItemType.VIEWCELL, ((IViewCellStorage) montiorable).getViewCellStorage(), y, 206, y * 18 + 8 ); + cellView[y].allowEdit = canAccessViewCells; + addSlotToContainer( cellView[y] ); + } + } if ( bindInventory ) bindPlayerInventory( ip, 0, 0 ); @@ -171,6 +180,23 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa } } + boolean oldCanAccessViewCells = canAccessViewCells; + canAccessViewCells = hasAccess( SecurityPermissions.BUILD, false ); + if ( canAccessViewCells != oldCanAccessViewCells ) + { + for (int y = 0; y < 5; y++) + { + if ( cellView[y] != null ) + cellView[y].allowEdit = canAccessViewCells; + } + + for (Object c : this.crafters) + { + if ( c instanceof ICrafting ) + ((ICrafting) c).sendProgressBarUpdate( this, 99, canAccessViewCells ? 1 : 0 ); + } + } + super.detectAndSendChanges(); } } @@ -212,6 +238,19 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa } } + @Override + public void updateProgressBar(int idx, int value) + { + super.updateProgressBar( idx, value ); + + if ( idx == 99 ) + canAccessViewCells = value == 1; + + for (int y = 0; y < 5; y++) + if ( cellView[y] != null ) + cellView[y].allowEdit = canAccessViewCells; + } + @Override public void onContainerClosed(EntityPlayer player) { diff --git a/container/slot/SlotRestrictedInput.java b/container/slot/SlotRestrictedInput.java index 3847f4dc..d0ea4cb4 100644 --- a/container/slot/SlotRestrictedInput.java +++ b/container/slot/SlotRestrictedInput.java @@ -1,5 +1,6 @@ package appeng.container.slot; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -54,8 +55,15 @@ public class SlotRestrictedInput extends AppEngSlot } public PlaceableItemType which; + public boolean allowEdit = true; public int stackLimit = -1; + @Override + public boolean canTakeStack(EntityPlayer par1EntityPlayer) + { + return allowEdit; + } + public Slot setStackLimit(int i) { stackLimit = i; @@ -98,6 +106,10 @@ public class SlotRestrictedInput extends AppEngSlot return false; IAppEngApi api = AEApi.instance(); + + if ( !allowEdit ) + return false; + switch (which) { case VALID_ENCODED_PATTERN_W_OUPUT: diff --git a/core/sync/packets/PacketCompassRequest.java b/core/sync/packets/PacketCompassRequest.java index 9314b354..4d467511 100644 --- a/core/sync/packets/PacketCompassRequest.java +++ b/core/sync/packets/PacketCompassRequest.java @@ -42,7 +42,7 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba talkBackTo = player; DimensionalCoord loc = new DimensionalCoord( player.worldObj, this.cx << 4, this.cdy << 5, this.cz << 4 ); - WorldSettings.getInstance().getCompass().getCompassDirection( loc, 128, this ); + WorldSettings.getInstance().getCompass().getCompassDirection( loc, 174, this ); } // api diff --git a/hooks/MeteoriteWorldGen.java b/hooks/MeteoriteWorldGen.java index 1a13bccf..fb5f99c0 100644 --- a/hooks/MeteoriteWorldGen.java +++ b/hooks/MeteoriteWorldGen.java @@ -43,7 +43,7 @@ final public class MeteoriteWorldGen implements IWorldGenerator int z = r.nextInt( 16 ) + (chunkZ << 4); myGen obj = new myGen(); - WorldSettings.getInstance().getCompass().getCompassDirection( new DimensionalCoord( w, x, 128, z ), 30, obj ); + WorldSettings.getInstance().getCompass().getCompassDirection( new DimensionalCoord( w, x, 128, z ), 70, obj ); synchronized (obj) { diff --git a/parts/reporting/PartTerminal.java b/parts/reporting/PartTerminal.java index f1bd9c75..cfb70716 100644 --- a/parts/reporting/PartTerminal.java +++ b/parts/reporting/PartTerminal.java @@ -28,7 +28,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM { IConfigManager cm = new ConfigManager( this ); - AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 1 ); + AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 ); public PartTerminal(Class clz, ItemStack is) { super( clz, is ); diff --git a/services/CompassService.java b/services/CompassService.java index 2a22f08f..e7247faf 100644 --- a/services/CompassService.java +++ b/services/CompassService.java @@ -57,8 +57,8 @@ public class CompassService implements Runnable private class CMDirectionRequest extends CompassMessage { - public final DimensionalCoord coord; public final int maxRange; + public final DimensionalCoord coord; public final ICompassCallback callback; @Override @@ -190,7 +190,7 @@ public class CompassService implements Runnable } // spiral outward... - for (int offset = 1; offset < 174; offset++) + for (int offset = 1; offset < req.maxRange; offset++) { int minx = cx - offset; int minz = cz - offset; diff --git a/util/prioitylist/MergedPriorityList.java b/util/prioitylist/MergedPriorityList.java new file mode 100644 index 00000000..f6a452fd --- /dev/null +++ b/util/prioitylist/MergedPriorityList.java @@ -0,0 +1,52 @@ +package appeng.util.prioitylist; + +import java.util.ArrayList; +import java.util.List; + +import appeng.api.storage.data.IAEStack; + +public class MergedPriorityList> implements IPartitionList +{ + + final List> positive = new ArrayList(); + final List> negative = new ArrayList(); + + public void addNewList(IPartitionList list, boolean isWhitelist) + { + if ( isWhitelist ) + positive.add( list ); + else + negative.add( list ); + } + + public boolean isListed(T input) + { + for (IPartitionList l : negative) + if ( l.isListed( input ) ) + return false; + + if ( !positive.isEmpty() ) + { + for (IPartitionList l : positive) + if ( l.isListed( input ) ) + return true; + + return false; + } + + return true; + } + + @Override + public boolean isEmpty() + { + return positive.isEmpty() && negative.isEmpty(); + } + + @Override + public Iterable getItems() + { + throw new RuntimeException( "Not Implemented" ); + } + +}