Search in sources :

Example 1 with TileAlchemyArray

use of WayofTime.bloodmagic.tile.TileAlchemyArray in project BloodMagic by WayofTime.

the class BlockAlchemyArray method breakBlock.

@Override
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
    TileAlchemyArray alchemyArray = (TileAlchemyArray) world.getTileEntity(blockPos);
    if (alchemyArray != null)
        alchemyArray.dropItems();
    super.breakBlock(world, blockPos, blockState);
}
Also used : TileAlchemyArray(WayofTime.bloodmagic.tile.TileAlchemyArray)

Example 2 with TileAlchemyArray

use of WayofTime.bloodmagic.tile.TileAlchemyArray in project BloodMagic by WayofTime.

the class AlchemyCircleRenderer method renderAt.

public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
    if (!(tile instanceof TileAlchemyArray)) {
        return;
    }
    TileAlchemyArray tileArray = (TileAlchemyArray) tile;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder wr = tessellator.getBuffer();
    GlStateManager.pushMatrix();
    // float rot = (float)(this.worldObj.provider.getWorldTime() % (360 /
    // this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f;
    float rot = getRotation(craftTime);
    float secondaryRot = getSecondaryRotation(craftTime);
    float size = 1.0F * getSizeModifier(craftTime);
    // Bind the texture to the circle
    Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
    GlStateManager.disableCull();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);
    GlStateManager.translate(x, y, z);
    // Specify which face this "circle" is located on
    EnumFacing sideHit = EnumFacing.UP;
    EnumFacing rotation = tileArray.getRotation();
    GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
    switch(sideHit) {
        case DOWN:
            GlStateManager.translate(0, 0, 1);
            GlStateManager.rotate(-90.0f, 1, 0, 0);
            break;
        case EAST:
            GlStateManager.rotate(-90.0f, 0, 1, 0);
            GlStateManager.translate(0, 0, -1);
            break;
        case NORTH:
            break;
        case SOUTH:
            GlStateManager.rotate(180.0f, 0, 1, 0);
            GlStateManager.translate(-1, 0, -1);
            break;
        case UP:
            GlStateManager.translate(0, 1, 0);
            GlStateManager.rotate(90.0f, 1, 0, 0);
            break;
        case WEST:
            GlStateManager.translate(0, 0, 1);
            GlStateManager.rotate(90.0f, 0, 1, 0);
            break;
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
    GlStateManager.rotate(rotation.getHorizontalAngle() + 180, 0, 0, 1);
    GlStateManager.pushMatrix();
    GlStateManager.rotate(rot, 0, 0, 1);
    GlStateManager.rotate(secondaryRot, 1, 0, 0);
    GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1);
    double var31 = 0.0D;
    double var33 = 1.0D;
    double var35 = 0;
    double var37 = 1;
    GlStateManager.color(1f, 1f, 1f, 1f);
    wr.begin(7, DefaultVertexFormats.POSITION_TEX);
    // wr.setBrightness(200);
    wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
    wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
    wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
    wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
    tessellator.draw();
    GlStateManager.popMatrix();
    // GlStateManager.depthMask(true);
    GlStateManager.disableBlend();
    GlStateManager.enableCull();
    // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.popMatrix();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) TileAlchemyArray(WayofTime.bloodmagic.tile.TileAlchemyArray)

Example 3 with TileAlchemyArray

use of WayofTime.bloodmagic.tile.TileAlchemyArray in project BloodMagic by WayofTime.

the class AlchemyArrayEffectLaputa method update.

@Override
public boolean update(TileEntity tile, int ticksActive) {
    if (ticksActive >= 100) {
        World world = tile.getWorld();
        if (radius == -1) {
            ((TileAlchemyArray) tile).setItemDrop(false);
            radius = getRandomRadius(world.rand);
            teleportHeightOffset = getRandomHeightOffset(world.rand);
            currentPos = new BlockPos(-radius, -radius, -radius);
        }
        BlockPos pos = tile.getPos();
        if (world.isRemote) {
            return false;
        }
        int j = -radius;
        int i = -radius;
        int k = -radius;
        if (currentPos != null) {
            j = currentPos.getY();
            i = currentPos.getX();
            k = currentPos.getZ();
        }
        int checks = 0;
        int maxChecks = 100;
        while (j <= radius) {
            while (i <= radius) {
                while (k <= radius) {
                    if (i == 0 && j == 0 && k == 0) {
                        k++;
                        continue;
                    }
                    checks++;
                    if (checks >= maxChecks) {
                        this.currentPos = new BlockPos(i, j, k);
                        return false;
                    }
                    if (checkIfSphere(radius, i, j, k)) {
                        BlockPos newPos = pos.add(i, j, k);
                        BlockPos offsetPos = newPos.up(teleportHeightOffset);
                        TeleposeEvent event = new TeleposeEvent(world, newPos, world, offsetPos);
                        if (Utils.swapLocations(event.initalWorld, event.initialBlockPos, event.finalWorld, event.finalBlockPos) && !MinecraftForge.EVENT_BUS.post(event)) {
                            k++;
                            this.currentPos = new BlockPos(i, j, k);
                            return false;
                        }
                    }
                    k++;
                }
                i++;
                k = -radius;
            }
            j++;
            i = -radius;
            this.currentPos = new BlockPos(i, j, k);
            return false;
        }
        return true;
    }
    return false;
}
Also used : TeleposeEvent(WayofTime.bloodmagic.event.TeleposeEvent) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) TileAlchemyArray(WayofTime.bloodmagic.tile.TileAlchemyArray)

Example 4 with TileAlchemyArray

use of WayofTime.bloodmagic.tile.TileAlchemyArray in project BloodMagic by WayofTime.

the class RitualCobblestone method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
    TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up());
    Block block = Blocks.COBBLESTONE;
    if (currentEssence < getRefreshCost()) {
        masterRitualStone.getOwnerNetwork().causeNausea();
        return;
    }
    int maxEffects = currentEssence / getRefreshCost();
    int totalEffects = 0;
    AreaDescriptor cobblestoneRange = getBlockRange(COBBLESTONE_RANGE);
    if (tileEntity != null && tileEntity instanceof TileAlchemyArray) {
        TileAlchemyArray alchemyArray = (TileAlchemyArray) tileEntity;
        if (!alchemyArray.getStackInSlot(0).isEmpty() && alchemyArray.getStackInSlot(0).getItem() == RegistrarBloodMagicItems.COMPONENT) {
            switch(alchemyArray.getStackInSlot(0).getItemDamage()) {
                case 0:
                    block = Blocks.OBSIDIAN;
                    alchemyArray.decrStackSize(0, 1);
                    world.setBlockToAir(alchemyArray.getPos());
                    break;
                case 1:
                    block = Blocks.NETHERRACK;
                    alchemyArray.decrStackSize(0, 1);
                    world.setBlockToAir(alchemyArray.getPos());
                    break;
                /*
                 * case 4: block = Blocks.end_stone;
                 * alchemyArray.decrStackSize(0, 1);
                 * world.setBlockToAir(alchemyArray.getPos()); break;
                 */
                default:
                    break;
            }
        }
    }
    for (BlockPos blockPos : cobblestoneRange.getContainedPositions(masterRitualStone.getBlockPos())) {
        if (world.isAirBlock(blockPos)) {
            world.setBlockState(blockPos, block.getDefaultState());
            totalEffects++;
        }
        if (totalEffects >= maxEffects) {
            break;
        }
    }
    masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) TileAlchemyArray(WayofTime.bloodmagic.tile.TileAlchemyArray)

Example 5 with TileAlchemyArray

use of WayofTime.bloodmagic.tile.TileAlchemyArray in project BloodMagic by WayofTime.

the class BlockAlchemyArray method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    // TODO: Right click should rotate it
    TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos);
    if (array == null || player.isSneaking())
        return false;
    ItemStack playerItem = player.getHeldItem(hand);
    if (!playerItem.isEmpty()) {
        if (array.getStackInSlot(0).isEmpty()) {
            Utils.insertItemToTile(array, player, 0);
        } else if (!array.getStackInSlot(0).isEmpty()) {
            Utils.insertItemToTile(array, player, 1);
            array.attemptCraft();
        } else {
            return true;
        }
    }
    world.notifyBlockUpdate(pos, state, state, 3);
    return true;
}
Also used : TileAlchemyArray(WayofTime.bloodmagic.tile.TileAlchemyArray) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileAlchemyArray (WayofTime.bloodmagic.tile.TileAlchemyArray)11 EnumFacing (net.minecraft.util.EnumFacing)7 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)6 Tessellator (net.minecraft.client.renderer.Tessellator)6 BlockPos (net.minecraft.util.math.BlockPos)4 World (net.minecraft.world.World)3 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 AlchemyArrayEffect (WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect)1 AlchemyArrayEffectArrowTurret (WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectArrowTurret)1 TeleposeEvent (WayofTime.bloodmagic.event.TeleposeEvent)1 Block (net.minecraft.block.Block)1