use of net.minecraft.nbt.NBTTagCompound in project Realistic-Terrain-Generation by Team-RTG.
the class MaterializerRecipes method getMaterializationResult.
public List<ItemStack> getMaterializationResult(ItemStack stack) {
ItemStack[] inventory = null;
if (stack.getTagCompound() == null)
stack.setTagCompound(new NBTTagCompound());
if (stack.getTagCompound().hasKey("ItemInventory")) {
NBTTagList items = stack.getTagCompound().getTagList("ItemInventory", 10);
inventory = new ItemStack[items.tagCount()];
for (int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound item = items.getCompoundTagAt(i);
byte slot = item.getByte("Slot");
inventory[slot] = ItemStack.loadItemStackFromNBT(item);
}
}
if (inventory == null)
return null;
for (ItemStack item : inventory) if (!APIUtils.isCrystal(item))
return null;
List<ItemStack> displayList = Lists.newArrayList();
Iterator<Materialization> iterator = materializationList.iterator();
Materialization entry;
do {
if (!iterator.hasNext())
return displayList;
entry = iterator.next();
if (arrayContainsOtherArray(inventory, entry.input))
displayList.add(entry.output);
} while (!arrayContainsOtherArray(inventory, entry.input));
return displayList;
}
use of net.minecraft.nbt.NBTTagCompound in project Realistic-Terrain-Generation by Team-RTG.
the class NecronomiconCreationRitual method completeRitualClient.
@Override
protected void completeRitualClient(World world, BlockPos pos, EntityPlayer player) {
TileEntity altar = world.getTileEntity(pos);
NBTTagCompound compound = new NBTTagCompound();
NBTTagCompound newItem = new NBTTagCompound();
altar.writeToNBT(compound);
NBTTagCompound nbtItem = compound.getCompoundTag("Item");
if (ItemStack.loadItemStackFromNBT(nbtItem) == null || !ItemStack.loadItemStackFromNBT(nbtItem).isItemEqual(item)) {
item.writeToNBT(newItem);
compound.setTag("Item", newItem);
}
altar.readFromNBT(compound);
}
use of net.minecraft.nbt.NBTTagCompound in project Realistic-Terrain-Generation by Team-RTG.
the class NecronomiconEnchantmentRitual method completeRitualClient.
@Override
protected void completeRitualClient(World world, BlockPos pos, EntityPlayer player) {
TileEntity altar = world.getTileEntity(pos);
NBTTagCompound compound = new NBTTagCompound();
altar.writeToNBT(compound);
NBTTagCompound nbtItem = compound.getCompoundTag("Item");
if (canEnchant(ItemStack.loadItemStackFromNBT(nbtItem))) {
ItemStack item = ItemStack.loadItemStackFromNBT(nbtItem);
item.addEnchantment(enchantment.enchantmentobj, enchantment.enchantmentLevel);
item.writeToNBT(nbtItem);
compound.setTag("Item", nbtItem);
}
altar.readFromNBT(compound);
}
use of net.minecraft.nbt.NBTTagCompound in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ItemSystemLinker method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
NBTTagCompound stackCompound = stack.getTagCompound();
if (stackCompound == null) {
stackCompound = new NBTTagCompound();
stack.setTagCompound(stackCompound);
}
if (block instanceof BlockHovercraftController) {
if (!worldIn.isRemote) {
NBTUtils.writeBlockPosToNBT("controllerPos", pos, stackCompound);
playerIn.addChatMessage(new TextComponentString("ControllerPos set <" + pos.getX() + ":" + pos.getY() + ":" + pos.getZ() + ">"));
} else {
return EnumActionResult.SUCCESS;
}
}
if (block instanceof BlockEtherCompressor) {
if (!worldIn.isRemote) {
BlockPos controllerPos = NBTUtils.readBlockPosFromNBT("controllerPos", stackCompound);
if (controllerPos.equals(BlockPos.ORIGIN)) {
playerIn.addChatMessage(new TextComponentString("No selected Controller"));
} else {
PhysicsWrapperEntity controllerWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, controllerPos);
PhysicsWrapperEntity engineWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
if (controllerWrapper != engineWrapper) {
playerIn.addChatMessage(new TextComponentString("Controller and Engine are on seperate ships"));
return EnumActionResult.SUCCESS;
}
TileEntity worldTile = worldIn.getTileEntity(pos);
if (worldTile instanceof TileEntityEtherCompressor) {
TileEntityEtherCompressor tileEntity = (TileEntityEtherCompressor) worldTile;
BlockPos gravControllerPos = tileEntity.controllerPos;
if (gravControllerPos.equals(BlockPos.ORIGIN)) {
playerIn.addChatMessage(new TextComponentString("Set Controller To " + controllerPos.toString()));
} else {
playerIn.addChatMessage(new TextComponentString("Replaced controller position from: " + gravControllerPos.toString() + " to: " + controllerPos.toString()));
}
tileEntity.setController(controllerPos);
}
}
} else {
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
use of net.minecraft.nbt.NBTTagCompound in project Engine by VoltzEngine-Project.
the class VEProviderShockWave method spawnEffect.
public static void spawnEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ, float red, float green, float blue, float scale, float distance) {
PacketSpawnParticle packet = new PacketSpawnParticle("VEP_shockwave", world.provider.dimensionId, x, y, z, motionX, motionY, motionZ);
packet.otherData = new NBTTagCompound();
packet.otherData.setFloat("red", red);
packet.otherData.setFloat("green", green);
packet.otherData.setFloat("blue", blue);
packet.otherData.setFloat("scale", scale);
packet.otherData.setFloat("distance", distance);
Engine.instance.packetHandler.sendToAllAround(packet, world, x, y, z, 100);
}
Aggregations