Search in sources :

Example 41 with RfToolsDimensionManager

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

the class CmdCreateTab method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameter is missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionDescriptor dimensionDescriptor = dimensionManager.getDimensionDescriptor(dim);
    if (dimensionDescriptor == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    if (sender instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sender;
        ItemStack tab = DimensionEnscriberTileEntity.createRealizedTab(dimensionDescriptor, sender.getEntityWorld());
        InventoryHelper.mergeItemStack(player.inventory, false, tab, 0, 35, null);
    } else {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This command only works as a player!"));
    }
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Aggregations

RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)41 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)29 World (net.minecraft.world.World)13 DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)11 ItemStack (net.minecraft.item.ItemStack)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 ChatComponentText (net.minecraft.util.ChatComponentText)7 IBlockState (net.minecraft.block.state.IBlockState)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)4 ActionResult (net.minecraft.util.ActionResult)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 PacketGetDimensionEnergy (mcjty.rftoolsdim.network.PacketGetDimensionEnergy)3 Block (net.minecraft.block.Block)3 BlockPos (net.minecraft.util.BlockPos)3 File (java.io.File)2 IOException (java.io.IOException)2 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)2 IMob (net.minecraft.entity.monster.IMob)2