use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class TEReagentConduit method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setInteger("hasChanged", hasChanged);
NBTTagList tagList = new NBTTagList();
for (int i = 0; i < destinationList.size(); i++) {
NBTTagCompound savedTag = new NBTTagCompound();
tagList.appendTag(destinationList.get(i).writeToNBT(savedTag));
}
tag.setTag("destinationList", tagList);
// TODO
NBTTagList reagentTagList = new NBTTagList();
for (Entry<Reagent, List<Int3>> entry : reagentTargetList.entrySet()) {
NBTTagCompound savedTag = new NBTTagCompound();
savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey()));
NBTTagList coordinateTagList = new NBTTagList();
for (Int3 coord : entry.getValue()) {
NBTTagCompound coordinateTag = new NBTTagCompound();
coord.writeToNBT(coordinateTag);
coordinateTagList.appendTag(coordinateTag);
}
savedTag.setTag("coordinateList", coordinateTagList);
reagentTagList.appendTag(savedTag);
}
tag.setTag("reagentTargetList", reagentTagList);
NBTTagList tankDesignationList = new NBTTagList();
for (Entry<Reagent, Integer> entry : this.reagentTankDesignationList.entrySet()) {
NBTTagCompound savedTag = new NBTTagCompound();
savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey()));
savedTag.setInteger("integer", entry.getValue());
tankDesignationList.appendTag(savedTag);
}
tag.setTag("tankDesignationList", tankDesignationList);
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class TEReagentConduit method addReagentDestinationViaOffset.
public boolean addReagentDestinationViaOffset(Reagent reagent, int xOffset, int yOffset, int zOffset) {
int totalConnections = 0;
for (Entry<Reagent, List<Int3>> entry : this.reagentTargetList.entrySet()) {
if (entry.getValue() != null) {
totalConnections += entry.getValue().size();
}
}
if (totalConnections >= this.maxConnextions) {
// Send message that it cannot be done? Maybe add a Player instance
return false;
}
if (xOffset == 0 && yOffset == 0 && zOffset == 0) {
return false;
}
Int3 newCoord = new Int3(xOffset, yOffset, zOffset);
if (this.reagentTargetList.containsKey(reagent)) {
List<Int3> coordList = this.reagentTargetList.get(reagent);
if (coordList == null) {
List<Int3> newCoordList = new LinkedList();
newCoordList.add(newCoord);
this.reagentTargetList.put(reagent, newCoordList);
} else {
coordList.add(newCoord);
}
return true;
} else {
List<Int3> newCoordList = new LinkedList();
newCoordList.add(newCoord);
this.reagentTargetList.put(reagent, newCoordList);
return true;
}
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class BuildingSchematic method getGriddedPositions.
public List<Int3> getGriddedPositions(ForgeDirection dir) {
List<Int3> positionList = new ArrayList();
for (BlockSet blockSet : blockList) {
for (Int3 pos : blockSet.getPositions()) {
int xOff = pos.xCoord;
int zOff = pos.zCoord;
switch(dir) {
case SOUTH:
xOff *= -1;
zOff *= -1;
break;
case WEST:
int temp = zOff;
zOff = xOff * -1;
xOff = temp;
break;
case EAST:
int temp2 = zOff * -1;
zOff = xOff;
xOff = temp2;
break;
default:
}
Int3 nextPos = new Int3(xOff, 0, zOff);
if (!positionList.contains(nextPos)) {
positionList.add(nextPos);
}
}
}
return positionList;
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class ItemAttunedCrystal method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (world.isRemote) {
return itemStack;
}
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
if (movingobjectposition == null) {
if (player.isSneaking()) {
this.setHasSavedCoordinates(itemStack, false);
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.clearing"));
}
return itemStack;
} else {
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
int x = movingobjectposition.blockX;
int y = movingobjectposition.blockY;
int z = movingobjectposition.blockZ;
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof IReagentHandler)) {
return itemStack;
}
IReagentHandler relay = (IReagentHandler) tile;
if (player.isSneaking()) {
ReagentContainerInfo[] infos = relay.getContainerInfo(ForgeDirection.UNKNOWN);
if (infos != null) {
List<Reagent> reagentList = new LinkedList();
for (ReagentContainerInfo info : infos) {
if (info != null) {
ReagentStack reagentStack = info.reagent;
if (reagentStack != null) {
Reagent reagent = reagentStack.reagent;
if (reagent != null) {
reagentList.add(reagent);
}
}
}
}
Reagent pastReagent = this.getReagent(itemStack);
if (reagentList.size() <= 0) {
return itemStack;
}
int reagentLocation;
reagentLocation = reagentList.indexOf(pastReagent);
if (reagentLocation == -1 || reagentLocation + 1 >= reagentList.size()) {
this.setReagentWithNotification(itemStack, reagentList.get(0), player);
} else {
this.setReagentWithNotification(itemStack, reagentList.get(reagentLocation + 1), player);
}
}
} else {
if (this.getHasSavedCoordinates(itemStack)) {
Int3 coords = this.getCoordinates(itemStack);
int dimension = this.getDimension(itemStack);
if (coords == null) {
return itemStack;
}
if (dimension != world.provider.dimensionId || Math.abs(coords.xCoord - x) > maxDistance || Math.abs(coords.yCoord - y) > maxDistance || Math.abs(coords.zCoord - z) > maxDistance) {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.toofar"));
return itemStack;
}
TileEntity pastTile = world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
if (!(pastTile instanceof TEReagentConduit)) {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.cannotfind"));
return itemStack;
}
Reagent reagent = this.getReagent(itemStack);
if (reagent == null) {
return itemStack;
}
TEReagentConduit pastRelay = (TEReagentConduit) pastTile;
if (player.isSneaking()) {
pastRelay.removeReagentDestinationViaActual(reagent, x, y, z);
} else {
if (pastRelay.addReagentDestinationViaActual(reagent, x, y, z)) {
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.attunedcrystal.linked") + " " + reagent.name));
} else {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.noconnections"));
}
}
world.markBlockForUpdate(coords.xCoord, coords.yCoord, coords.zCoord);
} else {
int dimension = world.provider.dimensionId;
this.setDimension(itemStack, dimension);
this.setCoordinates(itemStack, new Int3(x, y, z));
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.linking"));
}
}
}
}
return itemStack;
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class ItemRitualDiviner method voidStoredLocation.
public void voidStoredLocation(ItemStack stack) {
NBTTagCompound tag = stack.getTagCompound();
if (tag == null || !tag.hasKey("location")) {
// tag = new NBTTagCompound();
// stack.setTagCompound(tag);
this.setStoredLocation(stack, new Int3(0, 0, 0));
return;
}
NBTTagCompound locTag = (NBTTagCompound) tag.getTag("location");
if (locTag != null) {
locTag.setBoolean("isStored", false);
}
}
Aggregations