Search in sources :

Example 61 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class PorterProperties method tickTeleport.

public void tickTeleport() {
    if (teleportTimeout < 0) {
        return;
    }
    teleportTimeout--;
    if (teleportTimeout <= 0) {
        EntityPlayer player = (EntityPlayer) entity;
        TeleportDestinations destinations = TeleportDestinations.getDestinations(entity.worldObj);
        GlobalCoordinate coordinate = destinations.getCoordinateForId(target);
        if (coordinate == null) {
            Logging.message(player, EnumChatFormatting.RED + "Something went wrong! The target has disappeared!");
            TeleportationTools.applyEffectForSeverity(player, 3, false);
            return;
        }
        TeleportDestination destination = destinations.getDestination(coordinate);
        TeleportationTools.performTeleport((EntityPlayer) entity, destination, 0, 10, false);
        teleportTimeout = -1;
        target = -1;
    }
}
Also used : TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) TeleportDestination(mcjty.rftools.blocks.teleporter.TeleportDestination)

Example 62 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class ShapeCardItem method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sx, float sy, float sz) {
    if (!world.isRemote) {
        int mode = getMode(stack);
        if (mode == MODE_NONE) {
            if (player.isSneaking()) {
                if (world.getTileEntity(x, y, z) instanceof BuilderTileEntity) {
                    setCurrentBlock(stack, new GlobalCoordinate(new Coordinate(x, y, z), world.provider.dimensionId));
                    Logging.message(player, EnumChatFormatting.GREEN + "Now select the first corner");
                    setMode(stack, MODE_CORNER1);
                    setCorner1(stack, null);
                } else {
                    Logging.message(player, EnumChatFormatting.RED + "You can only do this on a builder!");
                }
            } else {
                return false;
            }
        } else if (mode == MODE_CORNER1) {
            GlobalCoordinate currentBlock = getCurrentBlock(stack);
            if (currentBlock.getDimension() != world.provider.dimensionId) {
                Logging.message(player, EnumChatFormatting.RED + "The Builder is in another dimension!");
            } else if (currentBlock.getCoordinate().equals(new Coordinate(x, y, z))) {
                Logging.message(player, EnumChatFormatting.RED + "Cleared area selection mode!");
                setMode(stack, MODE_NONE);
            } else {
                Logging.message(player, EnumChatFormatting.GREEN + "Now select the second corner");
                setMode(stack, MODE_CORNER2);
                setCorner1(stack, new Coordinate(x, y, z));
            }
        } else {
            GlobalCoordinate currentBlock = getCurrentBlock(stack);
            if (currentBlock.getDimension() != world.provider.dimensionId) {
                Logging.message(player, EnumChatFormatting.RED + "The Builder is in another dimension!");
            } else if (currentBlock.getCoordinate().equals(new Coordinate(x, y, z))) {
                Logging.message(player, EnumChatFormatting.RED + "Cleared area selection mode!");
                setMode(stack, MODE_NONE);
            } else {
                NBTTagCompound tag = stack.getTagCompound();
                if (tag == null) {
                    tag = new NBTTagCompound();
                    stack.setTagCompound(tag);
                }
                Coordinate c1 = getCorner1(stack);
                if (c1 == null) {
                    Logging.message(player, EnumChatFormatting.RED + "Cleared area selection mode!");
                    setMode(stack, MODE_NONE);
                } else {
                    Logging.message(player, EnumChatFormatting.GREEN + "New settings copied to the shape card!");
                    System.out.println("currentBlock = " + currentBlock.getCoordinate());
                    System.out.println("corner1 = " + c1);
                    System.out.println("corner2 = " + x + ", " + y + ", " + z);
                    // Coordinate center = new Coordinate((int) ((c1.getX() + x) / 2.0f + .55f), (int) ((c1.getY() + y) / 2.0f + .55f), (int) ((c1.getZ() + z) / 2.0f + .55f));
                    Coordinate center = new Coordinate((int) Math.ceil((c1.getX() + x) / 2.0f), (int) Math.ceil((c1.getY() + y) / 2.0f), (int) Math.ceil((c1.getZ() + z) / 2.0f));
                    System.out.println("center = " + center);
                    tag.setInteger("dimX", Math.abs(c1.getX() - x) + 1);
                    tag.setInteger("dimY", Math.abs(c1.getY() - y) + 1);
                    tag.setInteger("dimZ", Math.abs(c1.getZ() - z) + 1);
                    tag.setInteger("offsetX", center.getX() - currentBlock.getCoordinate().getX());
                    tag.setInteger("offsetY", center.getY() - currentBlock.getCoordinate().getY());
                    tag.setInteger("offsetZ", center.getZ() - currentBlock.getCoordinate().getZ());
                    setMode(stack, MODE_NONE);
                    setCorner1(stack, null);
                }
            }
        }
    }
    return true;
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) BuilderTileEntity(mcjty.rftools.blocks.spaceprojector.BuilderTileEntity)

Example 63 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class ForgeEventHandlers method onBlockBreakEvent.

@SubscribeEvent
public void onBlockBreakEvent(BlockEvent.BreakEvent event) {
    int x = event.x;
    int y = event.y;
    int z = event.z;
    World world = event.world;
    Collection<GlobalCoordinate> protectors = getProtectors(world, x, y, z);
    checkHarvestProtection(event, x, y, z, world, protectors);
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) World(net.minecraft.world.World) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 64 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class ForgeEventHandlers method onEntitySpawnEvent.

@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
    World world = event.world;
    int id = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
    if (DimletConfiguration.preventSpawnUnpowered) {
        if (dimensionInformation != null) {
            // RFTools dimension.
            DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
            int energy = storage.getEnergyLevel(id);
            if (energy <= 0) {
                event.setResult(Event.Result.DENY);
                Logging.logDebug("Dimension power low: Prevented a spawn of " + event.entity.getClass().getName());
            }
        }
    }
    if (dimensionInformation != null) {
        if (dimensionInformation.hasEffectType(EffectType.EFFECT_STRONGMOBS) || dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
            if (event.entity instanceof EntityLivingBase) {
                EntityLivingBase entityLivingBase = (EntityLivingBase) event.entity;
                IAttributeInstance entityAttribute = entityLivingBase.getEntityAttribute(SharedMonsterAttributes.maxHealth);
                double newMax;
                if (dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
                    newMax = entityAttribute.getBaseValue() * DimletConfiguration.brutalMobsFactor;
                } else {
                    newMax = entityAttribute.getBaseValue() * DimletConfiguration.strongMobsFactor;
                }
                entityAttribute.setBaseValue(newMax);
                entityLivingBase.setHealth((float) newMax);
            }
        }
    }
    if (event.entity instanceof IMob) {
        Coordinate coordinate = new Coordinate((int) event.entity.posX, (int) event.entity.posY, (int) event.entity.posZ);
        if (PeacefulAreaManager.isPeaceful(new GlobalCoordinate(coordinate, id))) {
            event.setResult(Event.Result.DENY);
            Logging.logDebug("Peaceful manager: Prevented a spawn of " + event.entity.getClass().getName());
        } else if (dimensionInformation != null && dimensionInformation.isPeaceful()) {
            // RFTools dimension.
            event.setResult(Event.Result.DENY);
            Logging.logDebug("Peaceful dimension: Prevented a spawn of " + event.entity.getClass().getName());
        }
    } else if (event.entity instanceof IAnimals) {
        if (dimensionInformation != null && dimensionInformation.isNoanimals()) {
            // RFTools dimension.
            event.setResult(Event.Result.DENY);
            Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.entity.getClass().getName());
        }
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) IAnimals(net.minecraft.entity.passive.IAnimals) IMob(net.minecraft.entity.monster.IMob) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) World(net.minecraft.world.World) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 65 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class MatterReceiverBlock method onBlockPlaced.

@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float sx, float sy, float sz, int meta) {
    int rc = super.onBlockPlaced(world, x, y, z, side, sx, sy, sz, meta);
    if (world.isRemote) {
        return rc;
    }
    TeleportDestinations destinations = TeleportDestinations.getDestinations(world);
    GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(x, y, z), world.provider.dimensionId);
    destinations.getNewId(gc);
    destinations.addDestination(gc);
    destinations.save(world);
    return rc;
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Aggregations

GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)78 Coordinate (mcjty.lib.varia.Coordinate)33 TileEntity (net.minecraft.tileentity.TileEntity)15 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)14 World (net.minecraft.world.World)13 NBTTagList (net.minecraft.nbt.NBTTagList)7 ItemStack (net.minecraft.item.ItemStack)6 BlockPos (net.minecraft.util.math.BlockPos)6 ArrayList (java.util.ArrayList)5 TeleportDestination (mcjty.rftools.blocks.teleporter.TeleportDestination)5 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)4 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)4 MovingSound (net.minecraft.client.audio.MovingSound)4 BlockProtectorTileEntity (mcjty.rftools.blocks.blockprotector.BlockProtectorTileEntity)3 PlayerExtendedProperties (mcjty.rftools.playerprops.PlayerExtendedProperties)3 IBlockState (net.minecraft.block.state.IBlockState)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 WorldServer (net.minecraft.world.WorldServer)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3