fixed item translations in inventories, fix #1565
This commit is contained in:
parent
c55f124408
commit
69825c8fc8
5 changed files with 59 additions and 5 deletions
|
@ -13,6 +13,8 @@ import java.util.LinkedList;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
/**
|
||||
* This class allow to specify specific behavior for blocks stored in
|
||||
|
@ -182,5 +184,41 @@ public class Schematic {
|
|||
|
||||
}
|
||||
|
||||
public void inventorySlotsToBlueprint (MappingRegistry registry, NBTTagCompound nbt) {
|
||||
inventorySlotsToBlueprint(registry, nbt, "Items");
|
||||
}
|
||||
|
||||
public void inventorySlotsToBlueprint (MappingRegistry registry, NBTTagCompound nbt, String nbtName) {
|
||||
if (!nbt.hasKey(nbtName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagList list = nbt.getTagList(nbtName,
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound invSlot = list.getCompoundTagAt(i);
|
||||
Item item = Item.getItemById(invSlot.getInteger ("id"));
|
||||
invSlot.setInteger("id", registry.getIdForItem(item));
|
||||
}
|
||||
}
|
||||
|
||||
public void inventorySlotsToWorld (MappingRegistry registry, NBTTagCompound nbt) {
|
||||
inventorySlotsToWorld (registry, nbt, "Items");
|
||||
}
|
||||
|
||||
public void inventorySlotsToWorld (MappingRegistry registry, NBTTagCompound nbt, String nbtName) {
|
||||
if (!nbt.hasKey(nbtName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagList list = nbt.getTagList(nbtName,
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound invSlot = list.getCompoundTagAt(i);
|
||||
Item item = registry.getItemForId(invSlot.getInteger ("id"));
|
||||
invSlot.setInteger("id", Item.getIdFromItem(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ public class SchematicEntity extends Schematic {
|
|||
|
||||
cpt.setTag("Pos",
|
||||
this.newDoubleNBTList(new double[] { pos.x, pos.y, pos.z }));
|
||||
|
||||
inventorySlotsToBlueprint(registry, cpt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,6 +66,8 @@ public class SchematicEntity extends Schematic {
|
|||
|
||||
cpt.setTag("Pos",
|
||||
this.newDoubleNBTList(new double[] { pos.x, pos.y, pos.z }));
|
||||
|
||||
inventorySlotsToWorld(registry, cpt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,16 @@ public class SchematicTile extends SchematicBlock {
|
|||
*/
|
||||
public NBTTagCompound cpt = new NBTTagCompound();
|
||||
|
||||
@Override
|
||||
public void transformToBlueprint(MappingRegistry registry, Translation transform) {
|
||||
inventorySlotsToBlueprint(registry, cpt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transformToWorld(MappingRegistry registry, Translation transform) {
|
||||
inventorySlotsToWorld(registry, cpt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the block in the world, at the location specified in the slot.
|
||||
*/
|
||||
|
|
|
@ -75,7 +75,6 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
|
|||
/ (float) blockScanner.totalBlocks()) * 100);
|
||||
|
||||
if (blockScanner.blocksLeft() == 0) {
|
||||
System.out.println ("Z_A " + writingContext.box.sizeZ());
|
||||
writingBlueprint.readEntitiesFromWorld (writingContext, this);
|
||||
|
||||
Translation transform = new Translation();
|
||||
|
|
|
@ -68,10 +68,13 @@ public class SchematicHanging extends SchematicEntity {
|
|||
@Override
|
||||
public void writeToWorld(IBuilderContext context) {
|
||||
if (baseItem == Items.item_frame) {
|
||||
NBTTagCompound tag = cpt.getCompoundTag("Item");
|
||||
tag.setInteger("id", Item.itemRegistry.getIDForObject(context
|
||||
.getMappingRegistry().getItemForId(tag.getInteger("id"))));
|
||||
cpt.setTag("Item", tag);
|
||||
if (cpt.hasKey("Item")) {
|
||||
NBTTagCompound tag = cpt.getCompoundTag("Item");
|
||||
tag.setInteger("id", Item.itemRegistry.getIDForObject(context
|
||||
.getMappingRegistry()
|
||||
.getItemForId(tag.getInteger("id"))));
|
||||
cpt.setTag("Item", tag);
|
||||
}
|
||||
}
|
||||
|
||||
super.writeToWorld(context);
|
||||
|
|
Loading…
Add table
Reference in a new issue