use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class TEDemonPortal method findEmptySpaceNearRoad.
public Int3 findEmptySpaceNearRoad(ForgeDirection dir, int amount, int closeness) {
int index = 0;
if (dir == ForgeDirection.NORTH) {
if (printDebug)
System.out.print("NORTH!");
for (int i = 0; i <= negZRadius + posZRadius; i++) {
for (int j = 0; j <= negXRadius + posXRadius; j++) {
GridSpace space = area[j][i];
if (space.isEmpty()) {
int yLevel = this.findNearestRoadYLevel(j - negXRadius, i - negZRadius, closeness);
if (yLevel == -1) {
continue;
}
index++;
if (index >= amount) {
return new Int3(j - negXRadius, yLevel, i - negZRadius);
}
}
}
}
} else if (dir == ForgeDirection.SOUTH) {
for (int i = negZRadius + posZRadius; i >= 0; i--) {
for (int j = 0; j <= negXRadius + posXRadius; j++) {
GridSpace space = area[j][i];
int yLevel = this.findNearestRoadYLevel(j - negXRadius, i - negZRadius, closeness);
if (yLevel == -1) {
continue;
}
if (space.isEmpty()) {
index++;
if (index >= amount) {
return new Int3(j - negXRadius, yLevel, i - negZRadius);
}
}
}
}
} else if (dir == ForgeDirection.EAST) {
for (int i = negXRadius + posXRadius; i >= 0; i--) {
for (int j = 0; j <= negZRadius + posZRadius; j++) {
GridSpace space = area[i][j];
int yLevel = this.findNearestRoadYLevel(i - negXRadius, j - negZRadius, closeness);
if (yLevel == -1) {
continue;
}
if (space.isEmpty()) {
index++;
if (index >= amount) {
return new Int3(i - negXRadius, yLevel, j - negZRadius);
}
}
}
}
} else if (dir == ForgeDirection.WEST) {
for (int i = 0; i <= negXRadius + posXRadius; i++) {
for (int j = 0; j <= negZRadius + posZRadius; j++) {
GridSpace space = area[i][j];
int yLevel = this.findNearestRoadYLevel(i - negXRadius, j - negZRadius, closeness);
if (yLevel == -1) {
continue;
}
if (space.isEmpty()) {
index++;
if (index >= amount) {
return new Int3(i - negXRadius, yLevel, j - negZRadius);
}
}
}
}
}
return new Int3(0, 0, 0);
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class BuildingSchematic method createGSH.
public GridSpaceHolder createGSH() {
GridSpaceHolder holder = new GridSpaceHolder();
for (BlockSet set : blockList) {
for (Int3 coords : set.getPositions()) {
int gridX = (int) ((coords.xCoord + 2 * Math.signum(coords.xCoord)) / 5);
int gridZ = (int) ((coords.zCoord + 2 * Math.signum(coords.zCoord)) / 5);
holder.setGridSpace(gridX, gridZ, new GridSpace(GridSpace.HOUSE, 0));
}
}
return holder;
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class TEMasterStone method activateRitual.
public void activateRitual(World world, int crystalLevel, ItemStack activationCrystal, EntityPlayer player, String crystalOwner) {
if (world.isRemote) {
return;
}
String testRitual = Rituals.checkValidRitual(world, xCoord, yCoord, zCoord);
if (testRitual.equals("")) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.nothinghappened"));
return;
}
// TODO
RitualActivatedEvent event = new RitualActivatedEvent(this, crystalOwner, testRitual, player, activationCrystal, crystalLevel);
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.somethingstoppedyou"));
return;
}
int eventCrystalTier = event.crystalTier;
String eventRitualKey = event.ritualKey;
String eventOwnerKey = event.ownerKey;
boolean testLevel = Rituals.canCrystalActivate(eventRitualKey, eventCrystalTier);
if (!testLevel) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.crystalvibrates"));
return;
}
int currentEssence = SoulNetworkHandler.getCurrentEssence(eventOwnerKey);
if (currentEssence < Rituals.getCostForActivation(testRitual)) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.youfeelapull"));
return;
}
if (!world.isRemote) {
if (!Rituals.startRitual(this, testRitual, player)) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.ritualresistyou"));
return;
} else {
int drain = SoulNetworkHandler.syphonFromNetwork(eventOwnerKey, Rituals.getCostForActivation(testRitual));
if (drain > 0) {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.energyflows"));
for (int i = 0; i < 12; i++) {
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
} else {
player.addChatMessage(new ChatComponentTranslation("message.masterstone.somethingstoppedyou"));
return;
}
}
}
if (!this.currentRitualString.equals("")) {
Rituals.onRitualBroken(this, this.currentRitualString, RitualBreakMethod.ACTIVATE);
}
this.setOwner(eventOwnerKey);
cooldown = Rituals.getInitialCooldown(testRitual);
var1 = 0;
currentRitualString = testRitual;
storage = Rituals.getLocalStorage(currentRitualString);
storage.setLocation(new Int3(xCoord, yCoord, zCoord));
isActive = true;
isRunning = true;
direction = Rituals.getDirectionOfRitual(world, xCoord, yCoord, zCoord, testRitual);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class TEReagentConduit method compileListForReagentTargets.
public List<ColourAndCoords> compileListForReagentTargets(Map<Reagent, List<Int3>> map) {
List<ColourAndCoords> list = new LinkedList();
for (Entry<Reagent, List<Int3>> entry : map.entrySet()) {
if (entry.getValue() != null) {
Reagent reagent = entry.getKey();
if (reagent == null) {
continue;
}
List<Int3> coords = entry.getValue();
for (Int3 coord : coords) {
if (coord == null) {
continue;
}
list.add(new ColourAndCoords(reagent.getColourRed(), reagent.getColourGreen(), reagent.getColourBlue(), reagent.getColourIntensity(), coord.xCoord, coord.yCoord, coord.zCoord));
}
}
}
return list;
}
use of WayofTime.alchemicalWizardry.api.Int3 in project BloodMagic by WayofTime.
the class TEReagentConduit method updateEntity.
@Override
public void updateEntity() {
if (!worldObj.isRemote) {
if (hasChanged > 1) {
hasChanged = 1;
} else if (hasChanged == 1) {
hasChanged = 0;
}
if (worldObj.getWorldTime() % 100 == 99) {
this.updateColourList();
}
if (affectedByRedstone && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
return;
}
int totalTransfered = 0;
for (Entry<Reagent, List<Int3>> entry : this.reagentTargetList.entrySet()) {
for (Int3 coord : entry.getValue()) {
if (totalTransfered >= this.tickRate) {
break;
}
ReagentStack maxDrainAmount = this.drain(ForgeDirection.UNKNOWN, new ReagentStack(entry.getKey(), this.tickRate - totalTransfered), false);
if (maxDrainAmount == null) {
continue;
}
int amountLeft = maxDrainAmount.amount;
if (amountLeft <= 0) {
continue;
}
int x = xCoord + coord.xCoord;
int y = yCoord + coord.yCoord;
int z = zCoord + coord.zCoord;
TileEntity tile = worldObj.getTileEntity(x, y, z);
if (tile instanceof IReagentHandler) {
int amount = Math.min(((IReagentHandler) tile).fill(ForgeDirection.UNKNOWN, maxDrainAmount, false), amountLeft);
if (amount > 0) {
amountLeft -= amount;
totalTransfered += amount;
ReagentStack stack = this.drain(ForgeDirection.UNKNOWN, new ReagentStack(entry.getKey(), amount), true);
((IReagentHandler) tile).fill(ForgeDirection.UNKNOWN, stack, true);
}
}
}
}
} else {
if (affectedByRedstone && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
return;
}
renderCount++;
if (worldObj.getWorldTime() % 100 != 0) {
return;
}
this.sendPlayerStuffs();
}
}
Aggregations