Search in sources :

Example 6 with TEDemonPortal

use of WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal in project BloodMagic by WayofTime.

the class BlockDemonPortal method onBlockActivated.

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float what, float these, float are) {
    if (world.isRemote) {
        return false;
    }
    TEDemonPortal tileEntity = (TEDemonPortal) world.getTileEntity(x, y, z);
    tileEntity.rightClickBlock(player, side);
    return false;
}
Also used : TEDemonPortal(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal)

Example 7 with TEDemonPortal

use of WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal in project BloodMagic by WayofTime.

the class BlockTeleposer method swapBlocks.

public static boolean swapBlocks(Object caller, World worldI, World worldF, int xi, int yi, int zi, int xf, int yf, int zf, boolean doSound, int flag) {
    TileEntity tileEntityI = worldI.getTileEntity(xi, yi, zi);
    TileEntity tileEntityF = worldF.getTileEntity(xf, yf, zf);
    NBTTagCompound nbttag1 = new NBTTagCompound();
    NBTTagCompound nbttag2 = new NBTTagCompound();
    if (tileEntityI != null) {
        tileEntityI.writeToNBT(nbttag1);
    }
    if (tileEntityF != null) {
        tileEntityF.writeToNBT(nbttag2);
    }
    Block blockI = worldI.getBlock(xi, yi, zi);
    Block blockF = worldF.getBlock(xf, yf, zf);
    if (blockI.equals(Blocks.air) && blockF.equals(Blocks.air)) {
        return false;
    }
    if (blockI instanceof BlockMobSpawner || blockF instanceof BlockMobSpawner || caller instanceof TEDemonPortal ? false : blockI instanceof BlockPortal || blockF instanceof BlockPortal) {
        return false;
    }
    int metaI = worldI.getBlockMetadata(xi, yi, zi);
    int metaF = worldF.getBlockMetadata(xf, yf, zf);
    TeleposeEvent evt = new TeleposeEvent(worldI, xi, yi, zi, blockI, metaI, worldF, xf, yf, zf, blockF, metaF);
    if (MinecraftForge.EVENT_BUS.post(evt))
        return false;
    if (doSound) {
        worldI.playSoundEffect(xi, yi, zi, "mob.endermen.portal", 1.0F, 1.0F);
        worldF.playSoundEffect(xf, yf, zf, "mob.endermen.portal", 1.0F, 1.0F);
    }
    // CLEAR TILES
    Block finalBlock = blockF;
    if (finalBlock != null) {
        TileEntity tileToSet = finalBlock.createTileEntity(worldF, metaF);
        worldF.setTileEntity(xf, yf, zf, tileToSet);
    }
    if (blockI != null) {
        TileEntity tileToSet = blockI.createTileEntity(worldI, metaI);
        worldI.setTileEntity(xi, yi, zi, tileToSet);
    }
    // TILES CLEARED
    worldF.setBlock(xf, yf, zf, blockI, metaI, flag);
    if (tileEntityI != null) {
        TileEntity newTileEntityI = TileEntity.createAndLoadEntity(nbttag1);
        if (AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityI)) {
            newTileEntityI = createMultipartFromNBT(worldF, nbttag1);
        }
        worldF.setTileEntity(xf, yf, zf, newTileEntityI);
        newTileEntityI.xCoord = xf;
        newTileEntityI.yCoord = yf;
        newTileEntityI.zCoord = zf;
        if (AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityI)) {
            sendDescriptorOfTile(worldF, newTileEntityI);
        }
    }
    worldI.setBlock(xi, yi, zi, finalBlock, metaF, flag);
    if (tileEntityF != null) {
        TileEntity newTileEntityF = TileEntity.createAndLoadEntity(nbttag2);
        if (AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityF)) {
            newTileEntityF = createMultipartFromNBT(worldI, nbttag2);
        }
        worldI.setTileEntity(xi, yi, zi, newTileEntityF);
        newTileEntityF.xCoord = xi;
        newTileEntityF.yCoord = yi;
        newTileEntityF.zCoord = zi;
        if (AlchemicalWizardry.isFMPLoaded && isMultipart(tileEntityF)) {
            sendDescriptorOfTile(worldI, newTileEntityF);
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockMobSpawner(net.minecraft.block.BlockMobSpawner) TEDemonPortal(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) TeleposeEvent(WayofTime.alchemicalWizardry.api.event.TeleposeEvent) BlockPortal(net.minecraft.block.BlockPortal)

Aggregations

TEDemonPortal (WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal)7 TileEntity (net.minecraft.tileentity.TileEntity)5 Int3 (WayofTime.alchemicalWizardry.api.Int3)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 Reagent (WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)1 TeleposeEvent (WayofTime.alchemicalWizardry.api.event.TeleposeEvent)1 IMasterRitualStone (WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone)1 LocalRitualStorage (WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage)1 IHoardDemon (WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon)1 LocalStorageAlphaPact (WayofTime.alchemicalWizardry.common.rituals.LocalStorageAlphaPact)1 Block (net.minecraft.block.Block)1 BlockMobSpawner (net.minecraft.block.BlockMobSpawner)1 BlockPortal (net.minecraft.block.BlockPortal)1 World (net.minecraft.world.World)1