Search in sources :

Example 6 with TileEntityShortRangeTelepad

use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.

the class BlockShortRangeTelepad method breakBlock.

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    final TileEntity tileAt = worldIn.getTileEntity(pos);
    int fakeBlockCount = 0;
    for (int x = -1; x <= 1; x++) {
        for (int y = 0; y < 3; y += 2) {
            for (int z = -1; z <= 1; z++) {
                if (!(x == 0 && y == 0 && z == 0)) {
                    if (worldIn.getBlockState(pos.add(x, y, z)).getBlock() == AsteroidBlocks.fakeTelepad) {
                        fakeBlockCount++;
                    }
                }
            }
        }
    }
    if (tileAt instanceof TileEntityShortRangeTelepad) {
        if (fakeBlockCount > 0) {
            ((TileEntityShortRangeTelepad) tileAt).onDestroy(tileAt);
        }
        ShortRangeTelepadHandler.removeShortRangeTeleporter((TileEntityShortRangeTelepad) tileAt);
    }
    super.breakBlock(worldIn, pos, state);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityShortRangeTelepad(micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad)

Example 7 with TileEntityShortRangeTelepad

use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.

the class BlockShortRangeTelepad method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
    TileEntity tile = worldIn.getTileEntity(pos);
    boolean validSpot = true;
    for (int x = -1; x <= 1; x++) {
        for (int y = 0; y < 3; y += 2) {
            for (int z = -1; z <= 1; z++) {
                if (!(x == 0 && y == 0 && z == 0)) {
                    Block blockAt = worldIn.getBlockState(pos.add(x, y, z)).getBlock();
                    if (!blockAt.getMaterial().isReplaceable()) {
                        validSpot = false;
                    }
                }
            }
        }
    }
    if (!validSpot) {
        worldIn.setBlockToAir(pos);
        if (placer instanceof EntityPlayer) {
            if (!worldIn.isRemote) {
                ((EntityPlayer) placer).addChatMessage(new ChatComponentText(EnumColor.RED + GCCoreUtil.translate("gui.warning.noroom")));
            }
            ((EntityPlayer) placer).inventory.addItemStackToInventory(new ItemStack(Item.getItemFromBlock(this), 1, 0));
        }
        return;
    }
    if (tile instanceof TileEntityShortRangeTelepad) {
        ((TileEntityShortRangeTelepad) tile).onCreate(worldIn, pos);
        ((TileEntityShortRangeTelepad) tile).setOwner(PlayerUtil.getName(((EntityPlayer) placer)));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityShortRangeTelepad(micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad) Block(net.minecraft.block.Block) IMultiBlock(micdoodle8.mods.galacticraft.core.tile.IMultiBlock) EnumSortCategoryBlock(micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock) ISortableBlock(micdoodle8.mods.galacticraft.core.blocks.ISortableBlock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 8 with TileEntityShortRangeTelepad

use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.

the class BlockShortRangeTelepad method randomDisplayTick.

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    final TileEntity tileAt = worldIn.getTileEntity(pos);
    if (tileAt instanceof TileEntityShortRangeTelepad) {
        TileEntityShortRangeTelepad telepad = (TileEntityShortRangeTelepad) tileAt;
        float teleportTimeScaled = Math.min(1.0F, telepad.teleportTime / (float) TileEntityShortRangeTelepad.MAX_TELEPORT_TIME);
        float f;
        float r;
        float g;
        float b;
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 4; j++) {
                f = rand.nextFloat() * 0.6F + 0.4F;
                r = f * 0.3F;
                g = f * (0.3F + (teleportTimeScaled * 0.7F));
                b = f * (1.0F - (teleportTimeScaled * 0.7F));
                GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + 0.2 + rand.nextDouble() * 0.6, pos.getY() + 0.1, pos.getZ() + 0.2 + rand.nextDouble() * 0.6), new Vector3(0.0, 1.4, 0.0), telepad, false);
            }
            f = rand.nextFloat() * 0.6F + 0.4F;
            r = f * 0.3F;
            g = f * (0.3F + (teleportTimeScaled * 0.7F));
            b = f * (1.0F - (teleportTimeScaled * 0.7F));
            GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + 0.0 + rand.nextDouble() * 0.2, pos.getY() + 2.9, pos.getZ() + rand.nextDouble()), new Vector3(0.0, -2.95, 0.0), telepad, true);
            GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + 0.8 + rand.nextDouble() * 0.2, pos.getY() + 2.9, pos.getZ() + rand.nextDouble()), new Vector3(0.0, -2.95, 0.0), telepad, true);
            GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + rand.nextDouble(), pos.getY() + 2.9, pos.getZ() + 0.2 + rand.nextDouble() * 0.2), new Vector3(0.0, -2.95, 0.0), telepad, true);
            GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + rand.nextDouble(), pos.getY() + 2.9, pos.getZ() + 0.8 + rand.nextDouble() * 0.2), new Vector3(0.0, -2.95, 0.0), telepad, true);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityShortRangeTelepad(micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

TileEntityShortRangeTelepad (micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad)6 TileEntity (net.minecraft.tileentity.TileEntity)5 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ISortableBlock (micdoodle8.mods.galacticraft.core.blocks.ISortableBlock)1 IMultiBlock (micdoodle8.mods.galacticraft.core.tile.IMultiBlock)1 EnumSortCategoryBlock (micdoodle8.mods.galacticraft.core.util.EnumSortCategoryBlock)1 EntityFXTeleport (micdoodle8.mods.galacticraft.planets.asteroids.client.fx.EntityFXTeleport)1 ShortRangeTelepadHandler (micdoodle8.mods.galacticraft.planets.asteroids.dimension.ShortRangeTelepadHandler)1 PacketSimpleAsteroids (micdoodle8.mods.galacticraft.planets.asteroids.network.PacketSimpleAsteroids)1 EntityCryoFX (micdoodle8.mods.galacticraft.planets.mars.client.fx.EntityCryoFX)1 Block (net.minecraft.block.Block)1 Minecraft (net.minecraft.client.Minecraft)1 EntityFX (net.minecraft.client.particle.EntityFX)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 ItemStack (net.minecraft.item.ItemStack)1