mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
add a blacklist mode to the adept hopper
This commit is contained in:
parent
6ccc6ab005
commit
0b94b177ab
5 changed files with 37 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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<EntityItemFrame> 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ResourceLocation, Tuple<ItemStack, Boolean>> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.",
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue