net.minecraftforge.common.util.Constants Java Examples

The following examples show how to use net.minecraftforge.common.util.Constants. 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: PlacementProperties.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void setPropertyValue(UUID uuid, ItemType itemType, String key, Integer valueType, int value)
{
    NBTTagCompound tag = this.getOrCreatePropertyTag(uuid, itemType);

    switch (valueType)
    {
        case Constants.NBT.TAG_BYTE:
            tag.setByte(key, (byte) value);
            break;

        case Constants.NBT.TAG_SHORT:
            tag.setShort(key, (short) value);
            break;

        case Constants.NBT.TAG_INT:
            tag.setInteger(key, value);
            break;

        default:
    }

    this.dirty = true;
}
 
Example #2
Source File: ItemRuler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void toggleAlwaysRenderSelectedLocation(ItemStack rulerStack)
{
    ItemStack moduleStack = this.getSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC);

    if (moduleStack.isEmpty() == false)
    {
        int selected = this.getLocationSelection(rulerStack);
        NBTTagList tagList = NBTUtils.getTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, Constants.NBT.TAG_COMPOUND, true);
        NBTTagCompound tag = tagList.getCompoundTagAt(selected);

        NBTUtils.toggleBoolean(tag, TAG_RENDER_WITH_ALL);

        if (selected >= tagList.tagCount())
        {
            tagList = NBTUtils.insertToTagList(tagList, tag, selected);
        }
        else
        {
            tagList.set(selected, tag);
        }

        NBTUtils.setTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, tagList);

        this.setSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC, moduleStack);
    }
}
 
Example #3
Source File: ItemEnderBucket.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public int getCapacityCached(ItemStack stack, EntityPlayer player)
{
    if (LinkMode.fromStack(stack) == LinkMode.ENABLED)
    {
        ItemStack moduleStack = this.getSelectedModuleStack(stack, ModuleType.TYPE_LINKCRYSTAL);

        if (moduleStack.isEmpty() == false)
        {
            NBTTagCompound moduleNbt = moduleStack.getTagCompound();

            if (moduleNbt != null && moduleNbt.hasKey("CapacityCached", Constants.NBT.TAG_INT))
            {
                return moduleNbt.getInteger("CapacityCached");
            }
        }

        return 0; // without this the client side code would try to read the tank info, and then crash
    }

    return this.getCapacity(stack, player);
}
 
Example #4
Source File: AbstractRecipeLogic.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void deserializeNBT(NBTTagCompound compound) {
    this.workingEnabled = compound.getBoolean("WorkEnabled");
    this.progressTime = compound.getInteger("Progress");
    if(compound.hasKey("AllowOverclocking")) {
        this.allowOverclocking = compound.getBoolean("AllowOverclocking");
    }
    this.isActive = false;
    if (progressTime > 0) {
        this.isActive = true;
        this.maxProgressTime = compound.getInteger("MaxProgress");
        this.recipeEUt = compound.getInteger("RecipeEUt");
        NBTTagList itemOutputsList = compound.getTagList("ItemOutputs", Constants.NBT.TAG_COMPOUND);
        this.itemOutputs = NonNullList.create();
        for (int i = 0; i < itemOutputsList.tagCount(); i++) {
            this.itemOutputs.add(new ItemStack(itemOutputsList.getCompoundTagAt(i)));
        }
        NBTTagList fluidOutputsList = compound.getTagList("FluidOutputs", Constants.NBT.TAG_COMPOUND);
        this.fluidOutputs = new ArrayList<>();
        for (int i = 0; i < fluidOutputsList.tagCount(); i++) {
            this.fluidOutputs.add(FluidStack.loadFluidStackFromNBT(fluidOutputsList.getCompoundTagAt(i)));
        }
    }
}
 
Example #5
Source File: RenderBlockTileEntity.java    From MiningGadgets with MIT License 6 votes vote down vote up
@Override
public CompoundNBT write(CompoundNBT tag) {
    if (renderBlock!= null)
        tag.put("renderBlock", NBTUtil.writeBlockState(renderBlock));
    tag.putInt("originalDurability", originalDurability);
    tag.putInt("priorDurability", priorDurability);
    tag.putInt("durability", durability);
    tag.putInt("ticksSinceMine", ticksSinceMine);
    if (!playerUUID.equals(null))
        tag.putUniqueId("playerUUID", playerUUID);
    tag.put("upgrades", UpgradeTools.setUpgradesNBT(gadgetUpgrades).getList("upgrades", Constants.NBT.TAG_COMPOUND));
    tag.putByte("breakType", (byte) breakType.ordinal());
    tag.put("gadgetFilters", MiningProperties.serializeItemStackList(getGadgetFilters()));
    tag.putBoolean("gadgetIsWhitelist", isGadgetIsWhitelist());
    tag.putBoolean("blockAllowed", blockAllowed);
    return super.write(tag);
}
 
Example #6
Source File: TileEntityBloomeryFurnace.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
public void readFromNBT (NBTTagCompound tag) {
    super.readFromNBT(tag);

    NBTTagList list = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    furnaceItemStacks = new ItemStack[getSizeInventory()];

    for (int i = 0, n = list.tagCount(); i < n; i++) {
        NBTTagCompound itemTag = list.getCompoundTagAt(i);
        byte slot = itemTag.getByte("Slot");

        if (slot >= 0 && slot < furnaceItemStacks.length)
            furnaceItemStacks[slot] = ItemStack.loadItemStackFromNBT(itemTag);
    }

    furnaceBurnTime = tag.getShort("BurnTime");
    furnaceCookTime = tag.getShort("CookTime");
    currentItemBurnTime = getItemBurnTime(furnaceItemStacks[SLOT_FUEL]);

    if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING))
        customName = tag.getString("CustomName");
}
 
Example #7
Source File: NBTUtils.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get a compound tag by the given name <b>tagName</b> from the other compound tag <b>nbt</b>.
 * If one doesn't exist, then it will be created and added if <b>create</b> is true, otherwise null is returned.
 */
@Nullable
public static NBTTagCompound getCompoundTag(@Nullable NBTTagCompound nbt, @Nonnull String tagName, boolean create)
{
    if (nbt == null)
    {
        return null;
    }

    if (create == false)
    {
        return nbt.hasKey(tagName, Constants.NBT.TAG_COMPOUND) ? nbt.getCompoundTag(tagName) : null;
    }

    // create = true

    if (nbt.hasKey(tagName, Constants.NBT.TAG_COMPOUND) == false)
    {
        nbt.setTag(tagName, new NBTTagCompound());
    }

    return nbt.getCompoundTag(tagName);
}
 
Example #8
Source File: UpgradeTools.java    From MiningGadgets with MIT License 6 votes vote down vote up
public static List<Upgrade> getActiveUpgradesFromTag(CompoundNBT tagCompound) {
    ListNBT upgrades = tagCompound.getList(KEY_UPGRADES, Constants.NBT.TAG_COMPOUND);

    List<Upgrade> functionalUpgrades = new ArrayList<>();
    if (upgrades.isEmpty())
        return functionalUpgrades;

    for (int i = 0; i < upgrades.size(); i++) {
        CompoundNBT tag = upgrades.getCompound(i);

        Upgrade type = getUpgradeByName(tag.getString(KEY_UPGRADE));
        if (type == null)
            continue;

        type.setEnabled(!tag.contains(KEY_ENABLED) || tag.getBoolean(KEY_ENABLED));
        if (type.isEnabled())
            functionalUpgrades.add(type);
    }

    return functionalUpgrades;
}
 
Example #9
Source File: PlacementProperties.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void readDataForItemTypeFromNBT(NBTTagCompound tagData, Map<ItemType, NBTTagCompound> mapTags, Map<ItemType, Integer> mapIndices)
{
    if (tagData.hasKey("ItemType", Constants.NBT.TAG_COMPOUND) && tagData.hasKey("Tag", Constants.NBT.TAG_COMPOUND))
    {
        ItemStack stack = new ItemStack(tagData.getCompoundTag("ItemType"));

        if (stack.isEmpty() == false && stack.getItem() instanceof ItemBlockPlacementProperty)
        {
            ItemBlockPlacementProperty item = (ItemBlockPlacementProperty) stack.getItem();

            if (item.hasPlacementProperty(stack))
            {
                boolean nbtSensitive = item.getPlacementProperty(stack).isNBTSensitive();
                ItemType type = new ItemType(stack, nbtSensitive);
                mapTags.put(type, tagData.getCompoundTag("Tag"));

                if (tagData.hasKey("Index", Constants.NBT.TAG_BYTE))
                {
                    mapIndices.put(type, Integer.valueOf(tagData.getByte("Index")));
                }
            }
        }
    }
}
 
Example #10
Source File: ItemRuler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public BlockPosEU getPosition(ItemStack rulerStack, int index, boolean isPos1)
{
    ItemStack moduleStack = this.getSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC);

    if (moduleStack.isEmpty() == false)
    {
        NBTTagList tagList = NBTUtils.getTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, Constants.NBT.TAG_COMPOUND, false);

        if (tagList == null)
        {
            return null;
        }

        if (index < 0)
        {
            index = this.getLocationSelection(rulerStack);
        }

        String tagName = isPos1 ? "Pos1" : "Pos2";
        NBTTagCompound tag = tagList.getCompoundTagAt(index);

        return BlockPosEU.readFromTag(tag.getCompoundTag(tagName));
    }

    return null;
}
 
Example #11
Source File: TileEntityEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void readFromNBTCustom(NBTTagCompound nbt)
{
    if (nbt.hasKey("Rotation", Constants.NBT.TAG_BYTE))
    {
        this.facing = EnumFacing.byIndex(nbt.getByte("Rotation"));
    }

    /*
    if (nbt.hasKey("Camo", Constants.NBT.TAG_COMPOUND))
    {
        this.camoState = NBTUtils.readBlockStateFromTag(nbt.getCompoundTag("Camo"));
    }
    */

    if (nbt.hasKey("Camo", Constants.NBT.TAG_INT))
    {
        this.camoState = Block.getStateById(nbt.getInteger("Camo"));
    }

    if (nbt.hasKey("CamoData", Constants.NBT.TAG_COMPOUND))
    {
        this.camoData = nbt.getCompoundTag("CamoData");
    }

    this.ownerData = OwnerData.getOwnerDataFromNBT(nbt);
}
 
Example #12
Source File: TileEntityInserter.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setPlacementProperties(World world, BlockPos pos, ItemStack stack, NBTTagCompound tag)
{
    if (tag.hasKey("inserter.stack_limit", Constants.NBT.TAG_BYTE))
    {
        this.setStackLimit(tag.getByte("inserter.stack_limit"));
    }

    if (tag.hasKey("inserter.delay", Constants.NBT.TAG_INT))
    {
        this.setUpdateDelay(tag.getInteger("inserter.delay"));
    }

    if (tag.hasKey("inserter.redstone_mode", Constants.NBT.TAG_BYTE))
    {
        this.setRedstoneModeFromInteger(tag.getByte("inserter.redstone_mode"));
    }

    this.markDirty();
}
 
Example #13
Source File: ItemRuler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean getAlwaysRenderLocation(ItemStack rulerStack, int index)
{
    ItemStack moduleStack = this.getSelectedModuleStack(rulerStack, ModuleType.TYPE_MEMORY_CARD_MISC);

    if (moduleStack.isEmpty() == false)
    {
        if (index < 0)
        {
            index = this.getLocationSelection(rulerStack);
        }

        NBTTagList tagList = NBTUtils.getTagList(moduleStack, TAG_WRAPPER, TAG_LOCATIONS, Constants.NBT.TAG_COMPOUND, false);

        if (tagList != null)
        {
            NBTTagCompound tag = tagList.getCompoundTagAt(index);
            return tag.getBoolean(TAG_RENDER_WITH_ALL);
        }
    }

    return false;
}
 
Example #14
Source File: NBTUtils.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Remove a compound tag by the name <b>tagName</b>. If <b>containerTagName</b> is not null, then
 * the tag is removed from inside a tag by that name.
 */
public static void removeCompoundTag(@Nonnull ItemStack stack, @Nullable String containerTagName, @Nonnull String tagName)
{
    NBTTagCompound nbt = getCompoundTag(stack, containerTagName, false);

    if (nbt != null && nbt.hasKey(tagName, Constants.NBT.TAG_COMPOUND))
    {
        nbt.removeTag(tagName);

        if (nbt.isEmpty())
        {
            if (containerTagName != null)
            {
                stack.getTagCompound().removeTag(containerTagName);
            }
            else
            {
                stack.setTagCompound(null);
            }
        }
    }
}
 
Example #15
Source File: BlockDrawbridge.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ItemBlock createItemBlock()
{
    ItemBlockPlacementProperty item = new ItemBlockPlacementProperty(this);
    String[] names = new String[] { "extend", "retract", "toggle" };

    item.addPlacementProperty(0, "drawbridge.delay", Constants.NBT.TAG_BYTE, 1, 255);
    item.addPlacementProperty(0, "drawbridge.length", Constants.NBT.TAG_BYTE, 1, TileEntityDrawbridge.MAX_LENGTH_NORMAL);
    item.addPlacementProperty(0, "drawbridge.redstone_mode", Constants.NBT.TAG_BYTE, 0, 2);
    item.addPlacementPropertyValueNames(0, "drawbridge.redstone_mode", names);

    item.addPlacementProperty(1, "drawbridge.delay", Constants.NBT.TAG_BYTE, 1, 255);
    item.addPlacementProperty(1, "drawbridge.length", Constants.NBT.TAG_BYTE, 1, TileEntityDrawbridge.MAX_LENGTH_ADVANCED);
    item.addPlacementProperty(1, "drawbridge.redstone_mode", Constants.NBT.TAG_BYTE, 0, 2);
    item.addPlacementPropertyValueNames(1, "drawbridge.redstone_mode", names);
    return item;
}
 
Example #16
Source File: ItemDolly.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public NBTTagCompound getNBTShareTag(ItemStack stack)
{
    NBTTagCompound tag = NBTUtils.getCompoundTag(stack, "Carrying", false);

    if (tag != null)
    {
        NBTTagCompound newTagCarrying = new NBTTagCompound();
        newTagCarrying.setString("Block", tag.getString("Block"));

        if (tag.hasKey("DisplayName", Constants.NBT.TAG_STRING))
        {
            newTagCarrying.setString("DisplayName", tag.getString("DisplayName"));
        }

        NBTTagCompound newTag = new NBTTagCompound();
        newTag.setTag("Carrying", newTagCarrying);

        return newTag;
    }

    return null;
}
 
Example #17
Source File: ItemDolly.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nullable
private String getCarriedBlockName(ItemStack stack)
{
    NBTTagCompound tag = NBTUtils.getCompoundTag(stack, "Carrying", false);

    if (tag != null)
    {
        String name;

        if (tag.hasKey("DisplayName", Constants.NBT.TAG_STRING))
        {
            name = tag.getString("DisplayName");
        }
        else
        {
            name = tag.getString("Block");
        }

        return name;
    }

    return null;
}
 
Example #18
Source File: TicketMap.java    From MyTown2 with The Unlicense 6 votes vote down vote up
public void chunkUnload(TownBlock block) {
    ForgeChunkManager.Ticket ticket = get(block.getDim());
    ForgeChunkManager.unforceChunk(ticket, block.toChunkCoords());

    NBTTagList list = ticket.getModData().getTagList("chunkCoords", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < list.tagCount(); i++) {
        NBTTagCompound chunkNBT = list.getCompoundTagAt(i);
        int x = chunkNBT.getInteger("x");
        int z = chunkNBT.getInteger("z");

        if (x == block.getX() && z == block.getZ()) {
            list.removeTag(i);
            break;
        }
    }
}
 
Example #19
Source File: SafariNetMetaProvider.java    From OpenPeripheral-Integration with MIT License 6 votes vote down vote up
@Override
public Object getMeta(Item target, ItemStack stack) {
	Map<String, Object> result = Maps.newHashMap();

	String type = safariNets.get(target.getUnlocalizedName());
	result.put("type", Objects.firstNonNull(type, "unknown"));

	NBTTagCompound tag = stack.getTagCompound();
	if (tag != null) {
		if (tag.getBoolean("hide")) {
			result.put("captured", "?");
		} else if (tag.hasKey("id", Constants.NBT.TAG_STRING)) {
			result.put("captured", tag.getString("id"));
		}
	}

	return result;
}
 
Example #20
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
@SuppressWarnings("unchecked")
public void onWorldTick(TickEvent.ServerTickEvent event) {
	if (event.phase != TickEvent.Phase.END || event.side != Side.SERVER)
		return;

	if (EtFuturum.enablePlayerSkinOverlay)
		if (playerLoggedInCooldown != null)
			if (--playerLoggedInCooldown <= 0) {
				for (World world : MinecraftServer.getServer().worldServers)
					for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) {
						NBTTagCompound nbt = player.getEntityData();
						if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) {
							boolean isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY);
							EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex));
						}
					}
				playerLoggedInCooldown = null;
			}
}
 
Example #21
Source File: BlockPosEU.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static BlockPosEU readFromTag(NBTTagCompound tag)
{
    if (tag == null ||
        tag.hasKey("posX", Constants.NBT.TAG_INT) == false ||
        tag.hasKey("posY", Constants.NBT.TAG_INT) == false ||
        tag.hasKey("posZ", Constants.NBT.TAG_INT) == false ||
        tag.hasKey("dim", Constants.NBT.TAG_INT) == false ||
        tag.hasKey("face", Constants.NBT.TAG_BYTE) == false)
    {
        return null;
    }

    int x = tag.getInteger("posX");
    int y = tag.getInteger("posY");
    int z = tag.getInteger("posZ");
    int dim = tag.getInteger("dim");
    int face = tag.getByte("face");

    return new BlockPosEU(x, y, z, dim, EnumFacing.byIndex(face));
}
 
Example #22
Source File: TileEntityNewBrewingStand.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	NBTTagList nbttaglist = nbt.getTagList("Items", 10);
	inventory = new ItemStack[getSizeInventory()];

	for (int i = 0; i < nbttaglist.tagCount(); i++) {
		NBTTagCompound nbt1 = nbttaglist.getCompoundTagAt(i);
		byte b0 = nbt1.getByte("Slot");

		if (b0 >= 0 && b0 < inventory.length)
			inventory[b0] = ItemStack.loadItemStackFromNBT(nbt1);
	}

	brewTime = nbt.getShort("BrewTime");

	if (nbt.hasKey("Fuel", Constants.NBT.TAG_SHORT)) {
		fuel = nbt.getShort("Fuel");
		if (fuel > 0)
			currentFuel = 30;
	} else {
		fuel = nbt.getInteger("Fuel");
		currentFuel = nbt.getInteger("CurrentFuel");
	}
}
 
Example #23
Source File: ItemLivingManipulator.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nullable
private String getEntityName(ItemStack containerStack, int index, boolean useDisplayNameFormatting)
{
    ItemStack moduleStack = this.getSelectedModuleStack(containerStack, ModuleType.TYPE_MEMORY_CARD_MISC);

    if (moduleStack.isEmpty())
    {
        return null;
    }

    NBTTagList tagList = NBTUtils.getTagList(moduleStack, WRAPPER_TAG_NAME, "Entities", Constants.NBT.TAG_COMPOUND, false);

    if (tagList != null && tagList.tagCount() > index)
    {
        return this.getNameForEntityFromTag(tagList.getCompoundTagAt(index), useDisplayNameFormatting);
    }

    return null;
}
 
Example #24
Source File: TileEntityDrawbridge.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setPlacementProperties(World world, BlockPos pos, ItemStack stack, NBTTagCompound tag)
{
    if (tag.hasKey("drawbridge.delay", Constants.NBT.TAG_BYTE))
    {
        this.setDelayFromByte(tag.getByte("drawbridge.delay"));
    }

    if (tag.hasKey("drawbridge.length", Constants.NBT.TAG_BYTE))
    {
        this.setMaxLength(tag.getByte("drawbridge.length"));
    }

    if (tag.hasKey("drawbridge.redstone_mode", Constants.NBT.TAG_BYTE))
    {
        this.setRedstoneMode(tag.getByte("drawbridge.redstone_mode"));
    }

    this.markDirty();
}
 
Example #25
Source File: MCNetworkState.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
public static MCNetworkState fromNBT(RailNetworkManager railNetworkManager, NBTTagCompound tag){
    NBTTagList trainList = tag.getTagList("trains", Constants.NBT.TAG_COMPOUND);
    List<MCTrain> trains = new ArrayList<>();

    for(int i = 0; i < trainList.tagCount(); i++) {
        trains.add(MCTrain.fromNBT(railNetworkManager, trainList.getCompoundTagAt(i)));
    }

    Map<MCPos, EnumForceMode> forcedSignalMap = new HashMap<>();
    NBTTagList forcedSignals = tag.getTagList("forcedSignals", Constants.NBT.TAG_COMPOUND);
    for(int i = 0; i < forcedSignals.tagCount(); i++) {
        NBTTagCompound t = forcedSignals.getCompoundTagAt(i);
        forcedSignalMap.put(new MCPos(t), EnumForceMode.values()[t.getByte("f")]);
    }

    MCNetworkState state = new MCNetworkState(railNetworkManager);
    state.signalForces = forcedSignalMap;
    state.setTrains(trains);
    return state;
}
 
Example #26
Source File: TileEntityPortalPanel.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void handleUpdateTag(NBTTagCompound tag)
{
    this.activeTargetId = tag.getByte("s");
    this.displayName = tag.getString("n");

    for (int i = 0; i < 9; i++)
    {
        this.colors[i] = this.getColorFromDyeMeta(tag.getByte("mt" + i));
    }

    for (int i = 0; i < 8; i++)
    {
        if (tag.hasKey("n" + i, Constants.NBT.TAG_STRING))
        {
            this.targetDisplayNames[i] = tag.getString("n" + i);
        }
    }

    super.handleUpdateTag(tag);
}
 
Example #27
Source File: SchematicEntity.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
	super.readSchematicFromNBT(nbt, registry);

	entityNBT = nbt.getCompoundTag("entity");

	NBTTagList rq = nbt.getTagList("rq",
			Constants.NBT.TAG_COMPOUND);

	ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();

	for (int i = 0; i < rq.tagCount(); ++i) {
		try {
			NBTTagCompound sub = rq.getCompoundTagAt(i);

			if (sub.getInteger("id") >= 0) {
				// Maps the id in the blueprint to the id in the world
				sub.setInteger("id", Item.itemRegistry
						.getIDForObject(registry.getItemForId(sub
								.getInteger("id"))));

				rqs.add(ItemStack.loadItemStackFromNBT(sub));
			} else {
				// TODO: requirement can't be retreived, this blueprint is
				// only useable in creative
			}
		} catch (Throwable t) {
			t.printStackTrace();
			// TODO: requirement can't be retreived, this blueprint is
			// only useable in creative
		}
	}

	storedRequirements = rqs.toArray(new ItemStack[rqs.size()]);
}
 
Example #28
Source File: EntityEndermanFighter.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readEntityFromNBT(NBTTagCompound nbt)
{
    super.readEntityFromNBT(nbt);

    if (nbt.hasKey("ATUUIDM", Constants.NBT.TAG_LONG) && nbt.hasKey("ATUUIDL", Constants.NBT.TAG_LONG))
    {
        this.assignedTargetUUID = new UUID(nbt.getLong("ATUUIDM"), nbt.getLong("ATUUIDL"));
    }

    if (nbt.hasKey("RTUUIDM", Constants.NBT.TAG_LONG) && nbt.hasKey("RTUUIDL", Constants.NBT.TAG_LONG))
    {
        this.revengeTargetUUID = new UUID(nbt.getLong("RTUUIDM"), nbt.getLong("RTUUIDL"));
    }
}
 
Example #29
Source File: TargetData.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public NBTTagCompound readTargetTagFromNBT(NBTTagCompound nbt)
{
    if (nbtHasTargetTag(nbt) == false)
    {
        return null;
    }

    NBTTagCompound tag = nbt.getCompoundTag("Target");
    this.pos = new BlockPos(tag.getInteger("posX"), tag.getInteger("posY"), tag.getInteger("posZ"));
    this.dimension = tag.getInteger("Dim");
    this.dimensionName = tag.getString("DimName");
    this.blockName = tag.getString("BlockName");
    this.blockMeta = tag.getByte("BlockMeta");
    this.itemMeta = tag.getByte("ItemMeta");
    this.blockFace = tag.getByte("BlockFace");
    this.facing = EnumFacing.byIndex(this.blockFace);

    this.dPosX = tag.hasKey("dPosX", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosX") : this.pos.getX() + 0.5d;
    this.dPosY = tag.hasKey("dPosY", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosY") : this.pos.getY();
    this.dPosZ = tag.hasKey("dPosZ", Constants.NBT.TAG_DOUBLE) ? tag.getDouble("dPosZ") : this.pos.getZ() + 0.5d;

    if (tag.hasKey("Yaw", Constants.NBT.TAG_FLOAT) && tag.hasKey("Pitch", Constants.NBT.TAG_FLOAT))
    {
        this.hasRotation = true;
        this.yaw = tag.getFloat("Yaw");
        this.pitch = tag.getFloat("Pitch");
    }

    return tag;
}
 
Example #30
Source File: BlockInserter.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ItemBlock createItemBlock()
{
    ItemBlockPlacementProperty item = new ItemBlockPlacementProperty(this);

    item.addPlacementProperty(OreDictionary.WILDCARD_VALUE, "inserter.delay",         Constants.NBT.TAG_INT, 0, 72000);
    item.addPlacementProperty(OreDictionary.WILDCARD_VALUE, "inserter.redstone_mode", Constants.NBT.TAG_BYTE, 0, 2);
    item.addPlacementProperty(OreDictionary.WILDCARD_VALUE, "inserter.stack_limit",   Constants.NBT.TAG_BYTE, 1, 64);

    String[] names = new String[] { "ignored", "low", "high" };
    item.addPlacementPropertyValueNames(OreDictionary.WILDCARD_VALUE, "inserter.redstone_mode", names);

    return item;
}