use of buildcraft.core.StackAtPosition in project BuildCraft by BuildCraft.
the class RenderBuildingItems method doRenderItem.
private void doRenderItem(BuildingItem i, float light) {
if (i == null) {
return;
}
i.displayUpdate();
for (StackAtPosition s : i.getStacks()) {
if (s.display) {
if (s.stack != null) {
IBakedModel model = renderItem.getItemModelMesher().getItemModel(s.stack);
if (model != null) {
float renderScale = 0.7f;
GL11.glPushMatrix();
GL11.glTranslatef((float) s.pos.xCoord, (float) s.pos.yCoord, (float) s.pos.zCoord);
GL11.glTranslatef(0, 0.25F, 0);
GL11.glScalef(renderScale, renderScale, renderScale);
renderItem.renderItem(s.stack, model);
GL11.glPopMatrix();
} else {
BCLog.logger.warn("Model was null for " + s.stack);
}
} else {
BCLog.logger.warn("ItemStack was null for " + s + ", " + i);
}
}
}
}
use of buildcraft.core.StackAtPosition in project BuildCraft by BuildCraft.
the class BuildingItem method readData.
@Override
public void readData(ByteBuf stream) {
origin = NetworkUtils.readVec3d(stream);
destination = NetworkUtils.readVec3d(stream);
lifetime = stream.readFloat();
stacksToDisplay.clear();
int size = stream.readUnsignedShort();
for (int i = 0; i < size; i++) {
StackAtPosition e = new StackAtPosition();
e.readData(stream);
stacksToDisplay.add(e);
}
}
use of buildcraft.core.StackAtPosition in project BuildCraft by BuildCraft.
the class BuildingItem method writeData.
@Override
public void writeData(ByteBuf stream) {
NetworkUtils.writeVec3d(stream, origin);
NetworkUtils.writeVec3d(stream, destination);
stream.writeFloat(lifetime);
stream.writeShort(stacksToDisplay.size());
for (StackAtPosition s : stacksToDisplay) {
s.writeData(stream);
}
}
use of buildcraft.core.StackAtPosition in project BuildCraft by BuildCraft.
the class BuildingItem method readFromNBT.
public void readFromNBT(NBTTagCompound nbt) throws MappingNotFoundException {
origin = NBTUtilBC.readVec3d(nbt, "origin");
destination = NBTUtilBC.readVec3d(nbt, "destination");
lifetime = nbt.getFloat("lifetime");
NBTTagList items = nbt.getTagList("items", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount(); ++i) {
StackAtPosition sPos = new StackAtPosition();
sPos.stack = ItemStack.loadItemStackFromNBT(items.getCompoundTagAt(i));
stacksToDisplay.add(sPos);
}
MappingRegistry registry = new MappingRegistry();
registry.read(nbt.getCompoundTag("registry"));
if (nbt.getByte("slotKind") == 0) {
slotToBuild = new BuildingSlotBlock();
} else {
slotToBuild = new BuildingSlotEntity();
}
slotToBuild.readFromNBT(nbt.getCompoundTag("slotToBuild"), registry);
}
use of buildcraft.core.StackAtPosition in project BuildCraft by BuildCraft.
the class BuildingItem method writeToNBT.
public void writeToNBT(NBTTagCompound nbt) {
nbt.setTag("origin", NBTUtilBC.writeVec3d(origin));
nbt.setTag("destination", NBTUtilBC.writeVec3d(destination));
nbt.setFloat("lifetime", lifetime);
NBTTagList items = new NBTTagList();
for (StackAtPosition s : stacksToDisplay) {
NBTTagCompound cpt = new NBTTagCompound();
s.stack.writeToNBT(cpt);
items.appendTag(cpt);
}
nbt.setTag("items", items);
MappingRegistry registry = new MappingRegistry();
NBTTagCompound slotNBT = new NBTTagCompound();
NBTTagCompound registryNBT = new NBTTagCompound();
slotToBuild.writeToNBT(slotNBT, registry);
registry.write(registryNBT);
nbt.setTag("registry", registryNBT);
if (slotToBuild instanceof BuildingSlotBlock) {
nbt.setByte("slotKind", (byte) 0);
} else {
nbt.setByte("slotKind", (byte) 1);
}
nbt.setTag("slotToBuild", slotNBT);
}
Aggregations