diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java index 4d8d9d39..baca7707 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java @@ -10,6 +10,7 @@ import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; @@ -41,6 +42,21 @@ public class BlockGratedChute extends BlockContainerImpl { this.setSoundType(SoundType.METAL); } + @Override + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (!playerIn.isSneaking()) + return false; + TileEntity tile = worldIn.getTileEntity(pos); + if (!(tile instanceof TileEntityGratedChute)) + return false; + if (!worldIn.isRemote) { + TileEntityGratedChute chute = (TileEntityGratedChute) tile; + chute.isBlacklist = !chute.isBlacklist; + chute.sendToClients(); + } + return true; + } + @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return FULL_BLOCK_AABB; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java index e2f85cd2..062eb748 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java @@ -27,10 +27,10 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable { @Override protected boolean canInsert(ItemStack stack, int slot) { - return TileEntityGratedChute.this.isItemInFrame(stack); + return TileEntityGratedChute.this.isBlacklist != TileEntityGratedChute.this.isItemInFrame(stack); } }; - + public boolean isBlacklist; private int cooldown; @Override @@ -111,7 +111,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable { private boolean isItemInFrame(ItemStack stack) { List frames = Helper.getAttachedItemFrames(this.world, this.pos); if (frames.isEmpty()) - return true; + return false; for (EntityItemFrame frame : frames) { ItemStack frameStack = frame.getDisplayedItem(); if (Helper.areItemsEqual(stack, frameStack, true)) { @@ -127,6 +127,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable { if (type != SaveType.BLOCK) { compound.setInteger("cooldown", this.cooldown); compound.setTag("items", this.items.serializeNBT()); + compound.setBoolean("blacklist", this.isBlacklist); } } @@ -136,6 +137,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable { if (type != SaveType.BLOCK) { this.cooldown = compound.getInteger("cooldown"); this.items.deserializeNBT(compound.getCompoundTag("items")); + this.isBlacklist = compound.getBoolean("blacklist"); } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 0cf725de..a29f6926 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -26,6 +26,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.Entity; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -59,6 +60,7 @@ import java.util.Map; public class ClientEvents { public static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png"); + private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME); private static final Map> SHOWING_EFFECTS = new HashMap<>(); private static ItemStack heldCache = ItemStack.EMPTY; private static ItemStack heldEye = ItemStack.EMPTY; @@ -412,7 +414,8 @@ public class ClientEvents { mc, res, 35, I18n.format("tile.naturesaura.rf_converter.name"), storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF"); } else if (tile instanceof TileEntityGratedChute) { - ItemStack stack = ((TileEntityGratedChute) tile).getItemHandler(null).getStackInSlot(0); + TileEntityGratedChute chute = (TileEntityGratedChute) tile; + ItemStack stack = chute.getItemHandler(null).getStackInSlot(0); int x = res.getScaledWidth() / 2; int y = res.getScaledHeight() / 2; @@ -422,6 +425,14 @@ public class ClientEvents { x + 5, y - 11, 0xFFFFFF, true); else Helper.renderItemInGui(stack, x + 2, y - 18, 1F); + + + Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F); + mc.getTextureManager().bindTexture(OVERLAYS); + int u = chute.isBlacklist ? 240 : 224; + GlStateManager.disableDepth(); + Gui.drawModalRectWithCustomSizedTexture(x - 18, y - 18, u, 0, 16, 16, 256, 256); + GlStateManager.enableDepth(); } } } diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/grated_chute.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/grated_chute.json index 4f880922..2e2a1ce6 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/grated_chute.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/grated_chute.json @@ -12,6 +12,10 @@ "type": "text", "text": "The $(item)Adept Hopper$() works just like a normal $(item)Hopper$(), except that it is a bit faster and that it can filter items as follows: Attaching any number of $(item)Item Frames$() to any side of it and placing items inside will cause $(thing)only those items$() to be let through. This counts both for pulling items from chests and the world and for having items inserted into it.$(p)It should additionally be noted that the $(l:using/hopper_upgrade)Hopper Enhancement$() can be combined with this to pick up only filtered items." }, + { + "type": "text", + "text": "Additionally, the $(item)Adept Hopper$()'s functionality can be $(thing)inverted$() simply by interacting with it while sneaking: This will cause not items $(italic)in$() the frames to be accepted, but all items that are $(italic)not$() in the frames. This, additionally, allows for throughput of any item, simply by not placing down any frames at all." + }, { "type": "crafting", "text": "Creating the $(item)Adept Hopper$()$(p)It should be noted that, when equipping an $(l:items/eye)Environmental Eye$(), the amount of items currently stored in the hopper can be seen.", diff --git a/src/main/resources/assets/naturesaura/textures/gui/overlays.png b/src/main/resources/assets/naturesaura/textures/gui/overlays.png index 7b497e26..0dc49b9e 100644 Binary files a/src/main/resources/assets/naturesaura/textures/gui/overlays.png and b/src/main/resources/assets/naturesaura/textures/gui/overlays.png differ