Search in sources :

Example 1 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class RealizedDimensionTab method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> 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(TextFormatting.BLUE + "Name: " + name);
            } else {
                list.add(TextFormatting.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(TextFormatting.RED + "Dimension information Missing!");
            } else {
                list.add(TextFormatting.BLUE + "Dimension ready!");
                int maintainCost = tagCompound.getInteger("rfMaintainCost");
                int actualCost = information.getActualRfCost();
                if (actualCost == maintainCost || actualCost == 0) {
                    list.add(TextFormatting.YELLOW + "    Maintenance cost: " + maintainCost + " RF/tick");
                } else {
                    list.add(TextFormatting.YELLOW + "    Maintenance cost: " + actualCost + " RF/tick (Specified: " + maintainCost + " RF/tick)");
                }
                if (id != 0) {
                    if (System.currentTimeMillis() - lastTime > 500) {
                        lastTime = System.currentTimeMillis();
                        RFToolsDimMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
                    }
                    DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
                    int power = storage.getEnergyLevel(id);
                    list.add(TextFormatting.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(TextFormatting.BLUE + "Dimension progress: " + percentage + "%");
            list.add(TextFormatting.YELLOW + "    Creation cost: " + createCost + " RF/tick");
            list.add(TextFormatting.YELLOW + "    Maintenance cost: " + maintainCost + " RF/tick");
            list.add(TextFormatting.YELLOW + "    Tick cost: " + tickCost + " ticks");
        }
    }
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) PacketGetDimensionEnergy(mcjty.rftoolsdim.network.PacketGetDimensionEnergy) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class RealizedDimensionTab method clOnItemRightClick.

@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    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 new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 3 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class DimensionMonitorItem method clOnItemRightClick.

@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (!world.isRemote) {
        int id = player.getEntityWorld().provider.getDimension();
        RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld());
        DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
        if (dimensionInformation == null) {
            Logging.message(player, "Not an RFTools dimension!");
        } else {
            String name = dimensionInformation.getName();
            DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
            int power = storage != null ? storage.getEnergyLevel(id) : 0;
            Logging.message(player, TextFormatting.BLUE + "Name: " + name + " (Id " + id + ")" + TextFormatting.YELLOW + "    Power: " + power + " RF");
            if (player.isSneaking()) {
                Logging.message(player, TextFormatting.RED + "Description: " + dimensionInformation.getDescriptor().getDescriptionString());
                System.out.println("Description:  = " + dimensionInformation.getDescriptor().getDescriptionString());
            }
        }
        return new ActionResult<>(EnumActionResult.SUCCESS, stack);
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) ItemStack(net.minecraft.item.ItemStack) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 4 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class ForgeEventHandlers method onOreGenEvent.

@SubscribeEvent
public void onOreGenEvent(OreGenEvent.GenerateMinable event) {
    World world = event.getWorld();
    if (world == null) {
        return;
    }
    WorldProvider provider = world.provider;
    if (!(provider instanceof GenericWorldProvider))
        return;
    DimensionInformation information = ((GenericWorldProvider) provider).getDimensionInformation();
    if (information != null && information.hasFeatureType(FeatureType.FEATURE_CLEAN)) {
        event.setResult(Event.Result.DENY);
    }
}
Also used : GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class FeatureAbsorberTileEntity method getRandomFeature.

private String getRandomFeature(int dim) {
    DimensionInformation information = RfToolsDimensionManager.getDimensionManager(getWorld()).getDimensionInformation(dim);
    if (information == null) {
        return null;
    }
    Set<FeatureType> featureTypes = information.getFeatureTypes();
    if (featureTypes.isEmpty()) {
        return null;
    }
    List<FeatureType> list = new ArrayList<>(featureTypes);
    return list.get(getWorld().rand.nextInt(list.size())).getId();
}
Also used : FeatureType(mcjty.rftoolsdim.dimensions.types.FeatureType) ArrayList(java.util.ArrayList) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation)

Aggregations

DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)34 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)21 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)11 World (net.minecraft.world.World)10 ItemStack (net.minecraft.item.ItemStack)8 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 ITextComponent (net.minecraft.util.text.ITextComponent)5 TextComponentString (net.minecraft.util.text.TextComponentString)5 IOException (java.io.IOException)4 GenericWorldProvider (mcjty.rftoolsdim.dimensions.world.GenericWorldProvider)4 PacketGetDimensionEnergy (mcjty.rftoolsdim.network.PacketGetDimensionEnergy)4 IBlockState (net.minecraft.block.state.IBlockState)4 PacketBuffer (net.minecraft.network.PacketBuffer)4 ActionResult (net.minecraft.util.ActionResult)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 WorldProvider (net.minecraft.world.WorldProvider)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 Map (java.util.Map)3