Search in sources :

Example 26 with Int3

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);
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3) GridSpace(WayofTime.alchemicalWizardry.common.demonVillage.GridSpace)

Example 27 with Int3

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;
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3)

Example 28 with Int3

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);
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) Int3(WayofTime.alchemicalWizardry.api.Int3) RitualActivatedEvent(WayofTime.alchemicalWizardry.api.event.RitualActivatedEvent)

Example 29 with Int3

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;
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) LinkedList(java.util.LinkedList) ColourAndCoords(WayofTime.alchemicalWizardry.api.ColourAndCoords) LinkedList(java.util.LinkedList)

Example 30 with Int3

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();
    }
}
Also used : S35PacketUpdateTileEntity(net.minecraft.network.play.server.S35PacketUpdateTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Int3(WayofTime.alchemicalWizardry.api.Int3) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) LinkedList(java.util.LinkedList)

Aggregations

Int3 (WayofTime.alchemicalWizardry.api.Int3)34 TileEntity (net.minecraft.tileentity.TileEntity)10 LinkedList (java.util.LinkedList)7 Block (net.minecraft.block.Block)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 World (net.minecraft.world.World)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 IInventory (net.minecraft.inventory.IInventory)4 ItemStack (net.minecraft.item.ItemStack)4 GridSpace (WayofTime.alchemicalWizardry.common.demonVillage.GridSpace)3 DemonBuilding (WayofTime.alchemicalWizardry.common.demonVillage.DemonBuilding)2 DemonVillagePath (WayofTime.alchemicalWizardry.common.demonVillage.DemonVillagePath)2 Int3AndBool (WayofTime.alchemicalWizardry.common.demonVillage.DemonVillagePath.Int3AndBool)2 GridSpaceHolder (WayofTime.alchemicalWizardry.common.demonVillage.GridSpaceHolder)2 TEDemonPortal (WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal)2