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 + "'");
}
}
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);
}
}
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);
}
}
}
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;
}
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();
}
Aggregations