Java Code Examples for net.minecraft.nbt.CompoundNBT#contains()
The following examples show how to use
net.minecraft.nbt.CompoundNBT#contains() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NBTStructureLoader.java From BoundingBoxOutlineReloaded with MIT License | 6 votes |
void loadStructures(int chunkX, int chunkZ) { if (saveHandler == null) return; if (!loadedChunks.add(String.format("%s,%s", chunkX, chunkZ))) return; CompoundNBT structureStarts = loadStructureStarts(chunkX, chunkZ); if (structureStarts == null || structureStarts.size() == 0) return; Map<String, StructureStart> structureStartMap = new HashMap<>(); for (String key : structureStarts.keySet()) { CompoundNBT compound = structureStarts.getCompound(key); if (compound.contains("BB")) { structureStartMap.put(key, new SimpleStructureStart(compound)); } } EventBus.publish(new StructuresLoaded(structureStartMap, dimensionId)); }
Example 2
Source File: CmdPeek.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Override public void onCommand(String command, String[] args) throws Exception { ItemStack item = mc.player.inventory.getCurrentItem(); if (!(item.getItem() instanceof BlockItem)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } if (!(((BlockItem) item.getItem()).getBlock() instanceof ContainerBlock)) { BleachLogger.errorMessage("Must be holding a containter to peek."); return; } NonNullList<ItemStack> items = NonNullList.withSize(27, new ItemStack(Items.AIR)); CompoundNBT nbt = item.getTag(); if (nbt != null && nbt.contains("BlockEntityTag")) { CompoundNBT itemnbt = nbt.getCompound("BlockEntityTag"); if (itemnbt.contains("Items")) ItemStackHelper.loadAllItems(itemnbt, items); } Inventory inv = new Inventory(items.toArray(new ItemStack[27])); BleachQueue.queue.add(() -> { mc.displayGuiScreen(new ShulkerBoxScreen( new ShulkerBoxContainer(420, mc.player.inventory, inv), mc.player.inventory, item.getDisplayName())); }); }
Example 3
Source File: NBTStructureLoader.java From BoundingBoxOutlineReloaded with MIT License | 5 votes |
SimpleStructureStart(CompoundNBT compound) { super(null, 0, 0, null, new MutableBoundingBox(compound.getIntArray("BB")), 0, 0); ListNBT children = compound.getList("Children", 10); for (int index = 0; index < children.size(); ++index) { CompoundNBT child = children.getCompound(index); if (child.contains("BB")) this.components.add(new SimpleStructurePiece(child)); } }
Example 4
Source File: NBTStructureLoader.java From BoundingBoxOutlineReloaded with MIT License | 5 votes |
private CompoundNBT loadStructureStarts(int chunkX, int chunkZ) { try { CompoundNBT compound = this.chunkLoader.readChunk(chunkX, chunkZ); if (compound == null) return null; int dataVersion = compound.contains("DataVersion", 99) ? compound.getInt("DataVersion") : -1; if (dataVersion < 1493) { if (compound.getCompound("Level").getBoolean("hasLegacyStructureData")) { compound = getLegacyStructureDataUtil().func_212181_a(compound); } } return compound.getCompound("Level").getCompound("Structures").getCompound("Starts"); } catch (IOException ignored) { } return null; }
Example 5
Source File: Frequency.java From EnderStorage with MIT License | 5 votes |
public static Frequency readFromStack(ItemStack stack) { if (stack.hasTag()) { CompoundNBT stackTag = stack.getTag(); if (stackTag.contains("Frequency")) { return new Frequency(stackTag.getCompound("Frequency")); } } return new Frequency(); }
Example 6
Source File: Frequency.java From EnderStorage with MIT License | 5 votes |
protected Frequency read_internal(CompoundNBT tagCompound) { left = EnumColour.fromWoolMeta(tagCompound.getInt("left")); middle = EnumColour.fromWoolMeta(tagCompound.getInt("middle")); right = EnumColour.fromWoolMeta(tagCompound.getInt("right")); if (tagCompound.hasUniqueId("owner")) { owner = tagCompound.getUniqueId("owner"); } if (tagCompound.contains("owner_name")) { ownerName = ITextComponent.Serializer.fromJson(tagCompound.getString("owner_name")); } return this; }
Example 7
Source File: MiningProperties.java From MiningGadgets with MIT License | 5 votes |
public static void nextBreakType(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); if (compound.contains(BREAK_TYPE)) { int type = getBreakType(gadget).ordinal() == BreakTypes.values().length - 1 ? 0 : getBreakType(gadget).ordinal() + 1; setBreakType(gadget, BreakTypes.values()[type]); } else { setBreakType(gadget, BreakTypes.FADE); } }
Example 8
Source File: MiningProperties.java From MiningGadgets with MIT License | 5 votes |
public static short getColor(ItemStack gadget, String color) { CompoundNBT compound = gadget.getOrCreateTag(); if (color.equals(COLOR_RED) || color.contains("Inner")) { return !compound.contains(color) ? setColor(gadget, (short) 255, color) : compound.getShort(color); } else { return !compound.contains(color) ? setColor(gadget, (short) 0, color) : compound.getShort(color); } }
Example 9
Source File: Peek.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onGuiDraw(GuiScreenEvent.DrawScreenEvent.Post event) { if (!(event.getGui() instanceof ContainerScreen<?>)) return; ContainerScreen<?> screen = (ContainerScreen<?>) event.getGui(); if (screen.getSlotUnderMouse() == null) return; if (!(screen.getSlotUnderMouse().getStack().getItem() instanceof BlockItem)) return; if (!(((BlockItem) screen.getSlotUnderMouse().getStack().getItem()).getBlock() instanceof ContainerBlock)) return; NonNullList<ItemStack> items = NonNullList.withSize(27, new ItemStack(Items.AIR)); CompoundNBT nbt = screen.getSlotUnderMouse().getStack().getTag(); if (nbt != null && nbt.contains("BlockEntityTag")) { CompoundNBT itemnbt = nbt.getCompound("BlockEntityTag"); if (itemnbt.contains("Items")) ItemStackHelper.loadAllItems(itemnbt, items); } GlStateManager.translatef(0.0F, 0.0F, 500.0F); Block block = ((BlockItem) screen.getSlotUnderMouse().getStack().getItem()).getBlock(); int count = block instanceof HopperBlock || block instanceof DispenserBlock ? 18 : 0; for (ItemStack i: items) { if (count > 26) break; int x = event.getMouseX() + 8 + (17 * (count % 9)); int y = event.getMouseY() - 68 + (17 * (count / 9)); if (i.getItem() != Items.AIR) { Screen.fill(x, y, x+17, y+17, 0x90000000); Screen.fill(x, y, x+17, y+1, 0xff000000); Screen.fill(x, y+1, x+1, y+17, 0xff000000); Screen.fill(x+16, y+1, x+17, y+17, 0xff000000); Screen.fill(x+1, y+16, x+17, y+17, 0xff000000); } mc.getItemRenderer().renderItemAndEffectIntoGUI(i, x, y); mc.getItemRenderer().renderItemOverlayIntoGUI(mc.fontRenderer, i, x, y, i.getCount() > 1 ? i.getCount() + "" : ""); count++; } }
Example 10
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static int getRange(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(KEY_RANGE) ? setRange(gadget, 1) : compound.getInt(KEY_RANGE); }
Example 11
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static int getBeamRange(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(KEY_BEAM_RANGE) ? setBeamRange(gadget, MIN_RANGE) : compound.getInt(KEY_BEAM_RANGE); }
Example 12
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static int getBeamMaxRange(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(KEY_MAX_BEAM_RANGE) ? setBeamMaxRange(gadget, MIN_RANGE) : compound.getInt(KEY_MAX_BEAM_RANGE); }
Example 13
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static boolean getWhiteList(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(KEY_WHITELIST) ? setWhitelist(gadget, true) : compound.getBoolean(KEY_WHITELIST); }
Example 14
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static boolean getCanMine(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(CAN_MINE) ? setCanMine(gadget, true) : compound.getBoolean(CAN_MINE); }
Example 15
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static boolean getPrecisionMode(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(PRECISION_MODE) ? setPrecisionMode(gadget, false) : compound.getBoolean(PRECISION_MODE); }
Example 16
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static float getVolume(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(VOLUME) ? setVolume(gadget, 1.0f) : compound.getFloat(VOLUME); }
Example 17
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static int getFreezeDelay(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(FREEZE_PARTICLE_DELAY) ? setFreezeDelay(gadget, 0) : compound.getInt(FREEZE_PARTICLE_DELAY); }
Example 18
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static int getSpeed(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(KEY_SPEED) ? setSpeed(gadget, 1) : compound.getInt(KEY_SPEED); }
Example 19
Source File: MiningProperties.java From MiningGadgets with MIT License | 4 votes |
public static BreakTypes getBreakType(ItemStack gadget) { CompoundNBT compound = gadget.getOrCreateTag(); return !compound.contains(BREAK_TYPE) ? setBreakType(gadget, BreakTypes.SHRINK) : BreakTypes.values()[compound.getByte(BREAK_TYPE)]; }