Search in sources :

Example 86 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Skree by Skelril.

the class ZoneItemUtil method incrementCount.

private static void incrementCount(ItemStack stack) {
    NBTTagCompound tag = stack.getTagCompound().getCompoundTag("skree_zone_data");
    tag.setInteger("zone_player_count", tag.getInteger("zone_player_count") + 1);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 87 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Skree by Skelril.

the class ZoneItemUtil method decrementCount.

private static void decrementCount(ItemStack stack) {
    NBTTagCompound tag = stack.getTagCompound().getCompoundTag("skree_zone_data");
    tag.setInteger("zone_player_count", tag.getInteger("zone_player_count") - 1);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 88 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Railcraft by Railcraft.

the class CustomRecipesPlugin method generateRecipes.

@Override
public void generateRecipes(RecipeGenerator generator) {
    RecipeTemplate template = generator.createRecipeTemplate(slots, null, "/gui/CraftGuideRecipe.png", 1, 1, 82, 1);
    // Rotor Repair
    if (EnumMachineAlpha.TURBINE.isAvailable()) {
        ItemStack[] rotorRepair = new ItemStack[10];
        rotorRepair[0] = RailcraftItems.TURBINE_ROTOR.getStack();
        rotorRepair[0].setItemDamage(1);
        for (int i = 0; i < 9; i++) {
            rotorRepair[i + 1] = RailcraftItems.TURBINE_BLADE.getStack();
        }
        rotorRepair[5] = RailcraftItems.TURBINE_ROTOR.getStack();
        rotorRepair[5].setItemDamage(25000);
        generator.addRecipe(template, rotorRepair);
    }
    // Ticket
    if (RailcraftModuleManager.isModuleEnabled(ModuleRouting.class)) {
        ItemStack[] ticket = new ItemStack[10];
        ticket[0] = RailcraftItems.TICKET.getStack();
        ticket[1] = RailcraftItems.TICKET_GOLD.getStack();
        ticket[2] = new ItemStack(Items.PAPER);
        NBTTagCompound nbt = InvTools.getItemData(ticket[0]);
        nbt.setString("owner", "CovertJaguar");
        nbt.setString("dest", "TheFarLands/Milliways");
        ticket[0].setTagCompound(nbt);
        ticket[1].setTagCompound(nbt);
        generator.addRecipe(template, ticket);
        // Routing Table
        ItemStack[] routingTable = new ItemStack[10];
        routingTable[0] = RailcraftItems.ROUTING_TABLE.getStack();
        if (routingTable[0] != null) {
            routingTable[0].stackSize = 2;
            InvTools.addItemToolTip(routingTable[0], "Edited");
            routingTable[1] = RailcraftItems.ROUTING_TABLE.getStack();
            InvTools.addItemToolTip(routingTable[1], "Edited");
            routingTable[2] = RailcraftItems.ROUTING_TABLE.getStack();
            InvTools.addItemToolTip(routingTable[2], "Blank");
            generator.addRecipe(template, routingTable);
        }
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 89 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Railcraft by Railcraft.

the class MappingRegistry method write.

public void write(NBTTagCompound nbt) {
    NBTTagList blocksMapping = new NBTTagList();
    for (Block b : idToBlock) {
        NBTTagCompound sub = new NBTTagCompound();
        if (b != null) {
            Object obj = Block.REGISTRY.getNameForObject(b);
            if (obj == null) {
                BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName() + ") does not have a registry name! This is a bug!");
            } else {
                String name = obj.toString();
                if (name == null || name.length() == 0) {
                    BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName() + ") has an empty registry name! This is a bug!");
                } else {
                    sub.setString("name", name);
                }
            }
        } else {
            throw new IllegalArgumentException("Found a null block!");
        }
        blocksMapping.appendTag(sub);
    }
    nbt.setTag("blocksMapping", blocksMapping);
    NBTTagList itemsMapping = new NBTTagList();
    for (Item i : idToItem) {
        NBTTagCompound sub = new NBTTagCompound();
        if (i != null) {
            ResourceLocation obj = Item.REGISTRY.getNameForObject(i);
            if (obj == null) {
                BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName() + ") does not have a registry name! This is a bug!");
            } else {
                String name = obj.toString();
                if (name == null || name.length() == 0) {
                    BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName() + ") has an empty registry name! This is a bug!");
                } else {
                    sub.setString("name", name);
                }
            }
        } else {
            throw new IllegalArgumentException("Found a null item!");
        }
        itemsMapping.appendTag(sub);
    }
    nbt.setTag("itemsMapping", itemsMapping);
    NBTTagList entitiesMapping = new NBTTagList();
    for (Class<? extends Entity> e : idToEntity) {
        NBTTagCompound sub = new NBTTagCompound();
        sub.setString("name", e.getCanonicalName());
        entitiesMapping.appendTag(sub);
    }
    nbt.setTag("entitiesMapping", entitiesMapping);
// System.out.println("[W] idToItem size : " + idToItem.size());
// for (Item i : idToItem) {
// System.out.println("- " + (i != null ? i.toString() : "null"));
// }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block)

Example 90 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Railcraft by Railcraft.

the class MappingRegistry method read.

public void read(NBTTagCompound nbt) {
    NBTTagList blocksMapping = nbt.getTagList("blocksMapping", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < blocksMapping.tagCount(); ++i) {
        NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
        if (!sub.hasKey("name")) {
            // Keeping the order correct
            idToBlock.add(null);
            BCLog.logger.log(Level.WARN, "Can't load a block - corrupt blueprint!");
            continue;
        }
        String name = sub.getString("name");
        ResourceLocation location = new ResourceLocation(name);
        Block b = null;
        if (!Block.REGISTRY.containsKey(location) && name.contains(":")) {
            b = (Block) getMissingMappingFromFML(true, name, i);
            if (b != null) {
                BCLog.logger.info("Remapped " + name + " to " + Block.REGISTRY.getNameForObject(b));
            }
        }
        if (b == null && Block.REGISTRY.containsKey(location)) {
            b = (Block) Block.REGISTRY.getObject(location);
        }
        if (b != null) {
            registerBlock(b);
        } else {
            // Keeping the order correct
            idToBlock.add(null);
            BCLog.logger.log(Level.WARN, "Can't load block " + name);
        }
    }
    NBTTagList itemsMapping = nbt.getTagList("itemsMapping", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < itemsMapping.tagCount(); ++i) {
        NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
        if (!sub.hasKey("name")) {
            // Keeping the order correct
            idToItem.add(null);
            BCLog.logger.log(Level.WARN, "Can't load an item - corrupt blueprint!");
            continue;
        }
        String name = sub.getString("name");
        ResourceLocation location = new ResourceLocation(name);
        Item item = null;
        if (!Item.REGISTRY.containsKey(location) && name.contains(":")) {
            item = (Item) getMissingMappingFromFML(false, name, i);
            if (item != null) {
                BCLog.logger.info("Remapped " + name + " to " + Item.REGISTRY.getNameForObject(item));
            }
        }
        if (item == null && Item.REGISTRY.containsKey(location)) {
            item = (Item) Item.REGISTRY.getObject(location);
        }
        if (item != null) {
            registerItem(item);
        } else {
            // Keeping the order correct
            idToItem.add(null);
            BCLog.logger.log(Level.WARN, "Can't load item " + name);
        }
    }
    NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < entitiesMapping.tagCount(); ++i) {
        NBTTagCompound sub = entitiesMapping.getCompoundTagAt(i);
        String name = sub.getString("name");
        Class<? extends Entity> e = null;
        try {
            e = (Class<? extends Entity>) Class.forName(name);
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        }
        if (e != null) {
            registerEntity(e);
        } else {
            // Keeping the order correct
            idToEntity.add(null);
            BCLog.logger.log(Level.WARN, "Can't load entity " + name);
        }
    }
// System.out.println("[R] idToItem size : " + idToItem.size());
// for (Item i : idToItem) {
// System.out.println("- " + (i != null ? i.toString() : "null"));
// }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3985 NBTTagList (net.minecraft.nbt.NBTTagList)1052 ItemStack (net.minecraft.item.ItemStack)883 BlockPos (net.minecraft.util.math.BlockPos)229 TileEntity (net.minecraft.tileentity.TileEntity)173 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)148 ArrayList (java.util.ArrayList)99 Block (net.minecraft.block.Block)98 ResourceLocation (net.minecraft.util.ResourceLocation)96 IBlockState (net.minecraft.block.state.IBlockState)92 EntityPlayer (net.minecraft.entity.player.EntityPlayer)81 NBTTagString (net.minecraft.nbt.NBTTagString)79 Nonnull (javax.annotation.Nonnull)74 Map (java.util.Map)71 UUID (java.util.UUID)69 NBTBase (net.minecraft.nbt.NBTBase)66 HashMap (java.util.HashMap)64 EnumFacing (net.minecraft.util.EnumFacing)61 NotNull (org.jetbrains.annotations.NotNull)60 Item (net.minecraft.item.Item)55