Search in sources :

Example 76 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Engine by VoltzEngine-Project.

the class EffectLayer method trigger.

public void trigger(World world, double x, double y, double z, double mx, double my, double mz, boolean endPoint, NBTTagCompound nbt) {
    VisualEffectProvider provider = VisualEffectRegistry.main.get(effectKey);
    if (provider != null) {
        NBTTagCompound usedNBT;
        if (nbt != null && !nbt.hasNoTags()) {
            usedNBT = (NBTTagCompound) nbt.copy();
            //Merges base NBT with server nbt
            if (this.getNbt() != null) {
                for (Object o : getNbt().func_150296_c()) {
                    if (o instanceof String) {
                        String key = (String) o;
                        NBTBase tag = getNbt().getTag(key);
                        if (tag != null) {
                            usedNBT.setTag(key, tag);
                        }
                    }
                }
            }
        } else if (this.getNbt() != null) {
            usedNBT = nbt;
        } else {
            usedNBT = new NBTTagCompound();
        }
        Pos renderOffset = this.renderOffset;
        if (renderOffset != Pos.zero && (usedNBT.hasKey("yaw") || usedNBT.hasKey("pitch"))) {
            float yaw = usedNBT.getFloat("yaw");
            float pitch = usedNBT.getFloat("pitch");
            angle.set(yaw, pitch, 0);
            renderOffset = (Pos) angle.transform(renderOffset);
        }
        provider.displayEffect(world, x + renderOffset.x(), y + renderOffset.y(), z + renderOffset.z(), mx, my, mz, endPoint, usedNBT);
    } else {
        Engine.logger().error("Failed to find a visual effect provider for key '" + effectKey + "'");
    }
}
Also used : VisualEffectProvider(com.builtbroken.mc.client.effects.VisualEffectProvider) NBTBase(net.minecraft.nbt.NBTBase) Pos(com.builtbroken.mc.imp.transform.vector.Pos) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 77 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Engine by VoltzEngine-Project.

the class ChunkDataShort method load.

@Override
public void load(NBTTagCompound nbt) {
    clear();
    NBTTagList list = nbt.getTagList("sections", 10);
    for (int i = 0; i < list.tagCount(); i++) {
        NBTTagCompound tag = list.getCompoundTagAt(i);
        int section = tag.getInteger("section_id");
        sections[section] = new ChunkSectionShort();
        sections[section].load(nbt);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 78 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project Engine by VoltzEngine-Project.

the class PacketSpawnParticle method handleClientSide.

@Override
public void handleClientSide(EntityPlayer player) {
    if (player.worldObj.provider.dimensionId == dim) {
        try {
            if (name.startsWith("JSON_")) {
                String key = name.substring(5, name.length()).toLowerCase();
                IEffectData data = ClientDataHandler.INSTANCE.getEffect(key);
                if (data != null) {
                    data.trigger(player.getEntityWorld(), x, y, z, vx, vy, vz, endPoint, otherData != null ? otherData : new NBTTagCompound());
                } else if (Engine.runningAsDev) {
                    Engine.logger().error("Failed to find a effect data for key '" + name + "'");
                }
            } else if (name.startsWith("VEP_")) {
                String key = name.substring(4, name.length());
                VisualEffectProvider provider = VisualEffectRegistry.main.get(key);
                if (provider != null) {
                    provider.displayEffect(player.getEntityWorld(), x, y, z, vx, vy, vz, endPoint, otherData != null ? otherData : new NBTTagCompound());
                } else if (Engine.runningAsDev) {
                    Engine.logger().error("Failed to find a visual effect provider for name '" + name + "'");
                }
            } else {
                player.worldObj.spawnParticle(name, x, y, z, vx, vy, vz);
            }
        } catch (Exception e) {
            Engine.logger().error("Failed handling particle spawn packet with [name=" + name + ", dim=" + dim + ",pos=" + x + ", " + y + ", " + z + ", Vel=" + vx + ", " + vy + ", " + vz + "]", e);
        }
    }
}
Also used : IEffectData(com.builtbroken.mc.client.json.imp.IEffectData) VisualEffectProvider(com.builtbroken.mc.client.effects.VisualEffectProvider) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 79 with NBTTagCompound

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

the class GraveStoneTileEntity method writeToNBT.

public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    super.writeToNBT(compound);
    NBTTagList nbttaglist = new NBTTagList();
    for (int i = 0; i < this.graveContents.length; ++i) {
        if (this.graveContents[i] != null) {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            nbttagcompound1.setByte("Slot", (byte) i);
            this.graveContents[i].writeToNBT(nbttagcompound1);
            nbttaglist.appendTag(nbttagcompound1);
        }
    }
    compound.setTag("Items", nbttaglist);
    if (this.hasCustomName()) {
        compound.setString("CustomName", this.customName);
    }
    return compound;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 80 with NBTTagCompound

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

the class PrizeBox method getPrizeStack.

public static Optional<org.spongepowered.api.item.inventory.ItemStack> getPrizeStack(ItemStack stack) {
    if (stack.getTagCompound() == null) {
        stack.setTagCompound(new NBTTagCompound());
    }
    NBTTagCompound tag = stack.getTagCompound().getCompoundTag("skree_held_prize_data");
    if (tag != null) {
        ItemStack returned = new ItemStack(Blocks.AIR);
        returned.readFromNBT(tag);
        return Optional.of(tf(returned));
    }
    return Optional.empty();
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) ItemStackFactory.newItemStack(com.skelril.nitro.item.ItemStackFactory.newItemStack)

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