Search in sources :

Example 6 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class ForgeEventHandlers method onEntityJoinWorldEvent.

@SubscribeEvent
public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) {
    World world = event.world;
    if (world.isRemote) {
        return;
    }
    int id = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
    if (dimensionInformation != null && dimensionInformation.isNoanimals()) {
        if (event.entity instanceof IAnimals && !(event.entity instanceof IMob)) {
            event.setCanceled(true);
            Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.entity.getClass().getName());
        }
    }
}
Also used : IAnimals(net.minecraft.entity.passive.IAnimals) IMob(net.minecraft.entity.monster.IMob) World(net.minecraft.world.World) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 7 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class ForgeOregenHandlers method onGenerateMinable.

@SubscribeEvent
public void onGenerateMinable(OreGenEvent.GenerateMinable event) {
    World world = event.world;
    int id = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(id);
    if (information != null && information.hasFeatureType(FeatureType.FEATURE_CLEAN)) {
        event.setResult(Event.Result.DENY);
    }
}
Also used : World(net.minecraft.world.World) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 8 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class RealizedDimensionTab method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    NBTTagCompound tagCompound = itemStack.getTagCompound();
    if (tagCompound != null) {
        String name = tagCompound.getString("name");
        int id = 0;
        if (name != null) {
            id = tagCompound.getInteger("id");
            if (id == 0) {
                list.add(EnumChatFormatting.BLUE + "Name: " + name);
            } else {
                list.add(EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
            }
        }
        String descriptionString = tagCompound.getString("descriptionString");
        constructDescriptionHelp(list, descriptionString);
        Integer ticksLeft = tagCompound.getInteger("ticksLeft");
        if (ticksLeft == 0) {
            DimensionInformation information = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld()).getDimensionInformation(id);
            if (information == null) {
                list.add(EnumChatFormatting.RED + "Dimension information Missing!");
            } else {
                list.add(EnumChatFormatting.BLUE + "Dimension ready!");
                int maintainCost = tagCompound.getInteger("rfMaintainCost");
                int actualCost = information.getActualRfCost();
                if (actualCost == maintainCost || actualCost == 0) {
                    list.add(EnumChatFormatting.YELLOW + "    Maintenance cost: " + maintainCost + " RF/tick");
                } else {
                    list.add(EnumChatFormatting.YELLOW + "    Maintenance cost: " + actualCost + " RF/tick (Specified: " + maintainCost + " RF/tick)");
                }
                if (id != 0) {
                    if (System.currentTimeMillis() - lastTime > 500) {
                        lastTime = System.currentTimeMillis();
                        RFToolsMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
                    }
                    DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
                    int power = storage.getEnergyLevel(id);
                    list.add(EnumChatFormatting.YELLOW + "    Current power: " + power + " RF");
                }
            }
        } else {
            int createCost = tagCompound.getInteger("rfCreateCost");
            int maintainCost = tagCompound.getInteger("rfMaintainCost");
            int tickCost = tagCompound.getInteger("tickCost");
            int percentage = (tickCost - ticksLeft) * 100 / tickCost;
            list.add(EnumChatFormatting.BLUE + "Dimension progress: " + percentage + "%");
            list.add(EnumChatFormatting.YELLOW + "    Creation cost: " + createCost + " RF/tick");
            list.add(EnumChatFormatting.YELLOW + "    Maintenance cost: " + maintainCost + " RF/tick");
            list.add(EnumChatFormatting.YELLOW + "    Tick cost: " + tickCost + " ticks");
        }
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) PacketGetDimensionEnergy(mcjty.rftools.dimension.network.PacketGetDimensionEnergy) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 9 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class RealizedDimensionTab method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if ((!world.isRemote) && player.isSneaking()) {
        NBTTagCompound tagCompound = stack.getTagCompound();
        Logging.message(player, tagCompound.getString("descriptionString"));
        int id = tagCompound.getInteger("id");
        if (id != 0) {
            RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
            DimensionInformation information = dimensionManager.getDimensionInformation(id);
            if (information != null) {
                information.dump(player);
            }
        }
    }
    return stack;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 10 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class DimensionMonitorItem method addInformation.

@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    int id = player.worldObj.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.worldObj);
    DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
    if (dimensionInformation == null) {
        list.add("Not an RFTools dimension!");
    } else {
        if (System.currentTimeMillis() - lastTime > 500) {
            lastTime = System.currentTimeMillis();
            RFToolsMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
        }
        String name = dimensionInformation.getName();
        DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
        int power = storage != null ? storage.getEnergyLevel(id) : 0;
        list.add(EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
        list.add(EnumChatFormatting.YELLOW + "Power: " + power + " RF");
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) PacketGetDimensionEnergy(mcjty.rftools.dimension.network.PacketGetDimensionEnergy)

Aggregations

DimensionInformation (mcjty.rftools.dimension.DimensionInformation)35 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)29 World (net.minecraft.world.World)19 ChatComponentText (net.minecraft.util.ChatComponentText)13 DimensionStorage (mcjty.rftools.dimension.DimensionStorage)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)5 IOException (java.io.IOException)4 DimensionDescriptor (mcjty.rftools.dimension.description.DimensionDescriptor)4 ItemStack (net.minecraft.item.ItemStack)4 File (java.io.File)3 EffectType (mcjty.rftools.dimension.world.types.EffectType)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 Map (java.util.Map)2 Coordinate (mcjty.lib.varia.Coordinate)2 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)2 PacketGetDimensionEnergy (mcjty.rftools.dimension.network.PacketGetDimensionEnergy)2 IMob (net.minecraft.entity.monster.IMob)2