use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class SignalBlock method saveNBT.
@Override
protected void saveNBT(NBTTagCompound data) {
super.saveNBT(data);
// MiscTools.writeUUID(data, "uuid", uuid);
NBTTagList tagList = new NBTTagList();
for (Map.Entry<WorldCoordinate, WorldCoordinate> cache : trackCache.entrySet()) {
NBTTagCompound entry = new NBTTagCompound();
if (cache.getKey() != null && cache.getValue() != null) {
cache.getKey().writeToNBT(entry, "key");
cache.getValue().writeToNBT(entry, "value");
tagList.appendTag(entry);
}
}
data.setTag("trackCache", tagList);
// if (RailcraftConfig.printSignalDebug()) {
// Deque<WorldCoordinate> test = new LinkedList<WorldCoordinate>();
// NBTTagList list = data.getTagList("pairings", 10);
// for (byte entry = 0; entry < list.tagCount(); entry++) {
// NBTTagCompound tag = list.getCompoundTagAt(entry);
// int[] c = tag.getIntArray("coords");
// test.add(new WorldCoordinate(c[0], c[1], c[2], c[3]));
// }
// boolean isConsistent = test.containsAll(getPairs());
// printDebug("Signal Block saved NBT. [{0}, {1}, {2}] [verified: {3}] [changedAspect: {4}] [data: {5}]", tile.xCoord, tile.yCoord, tile.zCoord, isConsistent, changedAspect, test);
printDebug("Signal Block saved NBT. [{0}, {1}, {2}] [changedAspect: {3}] [data: {4}]", tile.xCoord, tile.yCoord, tile.zCoord, changedAspect, pairings);
// savedData.put(uuid, new LinkedList<WorldCoordinate>(pairings));
// }
}
use of mods.railcraft.api.core.WorldCoordinate in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class SignalBlock method loadNBT.
@Override
protected void loadNBT(NBTTagCompound data) {
super.loadNBT(data);
// uuid = MiscTools.readUUID(data, "uuid");
if (data.hasKey("trackCache")) {
NBTTagList tagList = data.getTagList("trackCache", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbt = tagList.getCompoundTagAt(i);
WorldCoordinate key = WorldCoordinate.readFromNBT(nbt, "key");
WorldCoordinate value = WorldCoordinate.readFromNBT(nbt, "value");
trackCache.put(key, value);
}
}
// if (RailcraftConfig.printSignalDebug()) {
// String isConsistent = "unknown";
// Deque<WorldCoordinate> lastSave = savedData.get(uuid);
// if (lastSave != null) {
// if (pairings.containsAll(lastSave))
// isConsistent = "true";
// else
// isConsistent = "false";
// }
printDebug("Signal Block loaded NBT. [{0}, {1}, {2}] [data: {3}]", tile.xCoord, tile.yCoord, tile.zCoord, pairings);
// }
}
use of mods.railcraft.api.core.WorldCoordinate in project Railcraft by Railcraft.
the class ItemPairingTool method getPairData.
@Nullable
public WorldCoordinate getPairData(ItemStack stack) {
WorldCoordinate pos = null;
NBTTagCompound pairData = InvTools.getItemDataRailcraft(stack, PAIR_DATA_TAG);
if (pairData != null)
pos = WorldCoordinate.readFromNBT(pairData, COORD_TAG);
return pos;
}
use of mods.railcraft.api.core.WorldCoordinate in project Railcraft by Railcraft.
the class BlockWorldspikePoint method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (heldItem != null && heldItem.getItem() instanceof IToolCrowbar) {
IToolCrowbar crowbar = (IToolCrowbar) heldItem.getItem();
if (crowbar.canWhack(player, hand, heldItem, pos)) {
WorldCoordinate ourCoord = new WorldCoordinate(world.provider.getDimension(), pos);
WorldCoordinate target = TileWorldspike.getTarget(player);
if (target == null)
TileWorldspike.setTarget(ourCoord, player, getUnlocalizedName());
else if (world.provider.getDimension() != target.getDim())
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.fail.dimension", getUnlocalizedName());
else if (ourCoord.equals(target)) {
TileWorldspike.removeTarget(player);
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.cancel", getUnlocalizedName());
} else {
if (TileWorldspike.isTargetLoaded(player, target, getUnlocalizedName())) {
TileEntity tile = WorldPlugin.getBlockTile(world, target.getPos());
if (tile instanceof TileWorldspike)
((TileWorldspike) tile).setPoint(player, ourCoord);
else if (tile != null)
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.fail.invalid", getUnlocalizedName());
}
}
crowbar.onWhack(player, hand, heldItem, pos);
return true;
}
}
return false;
}
use of mods.railcraft.api.core.WorldCoordinate in project Railcraft by Railcraft.
the class TileWorldspike method blockActivated.
@Override
public boolean blockActivated(EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (heldItem != null && heldItem.getItem() instanceof IToolCrowbar) {
IToolCrowbar crowbar = (IToolCrowbar) heldItem.getItem();
if (crowbar.canWhack(player, hand, heldItem, getPos())) {
if (Game.isHost(worldObj)) {
WorldCoordinate ourCoord = new WorldCoordinate(this);
WorldCoordinate target = pointPairingMap.get(player);
if (target == null)
setTarget(ourCoord, player, getLocalizationTag());
else if (worldObj.provider.getDimension() != target.getDim())
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.fail.dimension", getLocalizationTag());
else if (Objects.equals(ourCoord, target)) {
removeTarget(player);
ChatPlugin.sendLocalizedChatFromServer(player, "gui.railcraft.worldspike.pair.cancel", getLocalizationTag());
} else
setPoint(player, target);
crowbar.onWhack(player, hand, heldItem, getPos());
}
return true;
}
}
return super.blockActivated(player, hand, heldItem, side, hitX, hitY, hitZ);
}
Aggregations