From 0b94b177ab0b776b4aac78adf3696a820f0cedb7 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 25 Feb 2019 17:15:39 +0100 Subject: [PATCH] add a blacklist mode to the adept hopper --- .../naturesaura/blocks/BlockGratedChute.java | 16 ++++++++++++++++ .../blocks/tiles/TileEntityGratedChute.java | 8 +++++--- .../naturesaura/events/ClientEvents.java | 13 ++++++++++++- .../en_us/entries/devices/grated_chute.json | 4 ++++ .../naturesaura/textures/gui/overlays.png | Bin 1095 -> 1109 bytes 5 files changed, 37 insertions(+), 4 deletions(-) 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 7b497e26ae8a946625b5604b05b1ee5ea0134fe9..0dc49b9e7d2ba406d7205a87efa8e6660fc4bb04 100644 GIT binary patch delta 741 zcmVBqV!C}Q>iIr65GxghqR*f1*i;sAaB$G6 z`L$U*_|9@5pP!$1>-D-jJv~(uDr=QB69RmDIf!#muU4yWxm>CVm9@&62>?FT??v~2 zTm!!ri>_5av{jq49L^H}^Gg8m>C*K73~Kpb6Q`;F?dwHz5A2+igV-g&ymAS^ry4i^ zD*>=A1ol1eL%=syzkKj<#?9X@0R{mOY3glFzPI_~=;)|BIXT(X+1Z)eQEiQ~Ua5Zh z;NuJfpf&!e`I~VFjB97}UtC;tPft&OYDQgMT?ql+PkU!iHN)ml?P&a=T_Lcw`6CDM z_4Rdke}Av`)WgF=cXxNUsjQg*;9U$GeHa46@d?e}Ogimv1iDWsz_|p-HEpV$+NObXvrD`ArQP^4cYgn8 zfVtBAGXr4jJN#e65O^^sr?k1IZ69>yUtAeW^X87X-1eHv1d{;+Kr8I?4~5z1 z9}3I1-s1qsSekvkUU#e2YEyYE0N{s7v-_eCC@c*>tbW)ReUotmypwWEf#+O XdVH9i?W+e900000NkvXXu0mjfMk{A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