Search in sources :

Example 16 with DimensionInformation

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

the class DimensionSyncPacket method getData.

public ByteBuf getData() {
    ByteBuf data = Unpooled.buffer();
    data.writeInt(dimensions.size());
    for (Map.Entry<Integer, DimensionDescriptor> me : dimensions.entrySet()) {
        data.writeInt(me.getKey());
        NBTTagCompound tagCompound = new NBTTagCompound();
        me.getValue().writeToNBT(tagCompound);
        PacketBuffer buffer = new PacketBuffer(data);
        buffer.writeCompoundTag(tagCompound);
    }
    data.writeInt(dimensionInformation.size());
    for (Map.Entry<Integer, DimensionInformation> me : dimensionInformation.entrySet()) {
        data.writeInt(me.getKey());
        DimensionInformation dimInfo = me.getValue();
        NetworkTools.writeString(data, dimInfo.getName());
        dimInfo.toBytes(data);
    }
    return data;
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ByteBuf(io.netty.buffer.ByteBuf) HashMap(java.util.HashMap) Map(java.util.Map) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) PacketBuffer(net.minecraft.network.PacketBuffer)

Example 17 with DimensionInformation

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

the class PacketSyncDimensionInfo method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(dimensions.size());
    for (Map.Entry<Integer, DimensionDescriptor> me : dimensions.entrySet()) {
        buf.writeInt(me.getKey());
        NBTTagCompound tagCompound = new NBTTagCompound();
        me.getValue().writeToNBT(tagCompound);
        PacketBuffer buffer = new PacketBuffer(buf);
        buffer.writeCompoundTag(tagCompound);
    }
    buf.writeInt(dimensionInformation.size());
    for (Map.Entry<Integer, DimensionInformation> me : dimensionInformation.entrySet()) {
        buf.writeInt(me.getKey());
        DimensionInformation dimInfo = me.getValue();
        NetworkTools.writeString(buf, dimInfo.getName());
        dimInfo.toBytes(buf);
    }
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) HashMap(java.util.HashMap) Map(java.util.Map) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) PacketBuffer(net.minecraft.network.PacketBuffer)

Example 18 with DimensionInformation

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

the class DimensionMonitorItem method addInformation.

//    @SideOnly(Side.CLIENT)
//    @Override
//    public IIcon getIconIndex(ItemStack stack) {
//        EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
//        int id = player.worldObj.provider.dimensionId;
//        DimensionStorage storage = DimensionStorage.getDimensionStorage(player.worldObj);
//        int energyLevel = storage.getEnergyLevel(id);
//        int level = (9*energyLevel) / DimletConfiguration.MAX_DIMENSION_POWER;
//        if (level < 0) {
//            level = 0;
//        } else if (level > 8) {
//            level = 8;
//        }
//        return powerLevel[8-level];
//    }
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    int id = player.getEntityWorld().provider.getDimension();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManagerNullable(player.getEntityWorld());
    DimensionInformation dimensionInformation = dimensionManager == null ? null : dimensionManager.getDimensionInformation(id);
    if (dimensionInformation == null) {
        list.add("Not an RFTools dimension!");
    } else {
        if (System.currentTimeMillis() - lastTime > 500) {
            lastTime = System.currentTimeMillis();
            RFToolsDimMessages.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(TextFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
        list.add(TextFormatting.YELLOW + "Power: " + power + " RF");
    }
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) PacketGetDimensionEnergy(mcjty.rftoolsdim.network.PacketGetDimensionEnergy)

Example 19 with DimensionInformation

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

the class ActivityProbeBlock method clGetStateForPlacement.

@Override
protected IBlockState clGetStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
    IBlockState state = super.clGetStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer);
    if (!world.isRemote) {
        RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
        DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.getDimension());
        if (information != null) {
            information.addProbe();
        }
        dimensionManager.save(world);
    }
    return state;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 20 with DimensionInformation

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

the class GenericWorldGenerator method generateBigSpawnPlatform.

private void generateBigSpawnPlatform(World world, int chunkX, int chunkZ, int[][] platform) {
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.getDimension());
    int midx = 8;
    int midz = 8;
    int starty = WorldGenerationTools.findSuitableEmptySpot(world, midx, midz);
    if (starty == -1) {
        // No suitable spot. We will carve something out.
        starty = 64;
    } else {
        // Go one up
        starty++;
    }
    if (isReceiverPresent(world, midx, midz, starty - 1, platform)) {
        starty--;
    }
    int r = platform.length;
    int sx = -r / 2;
    int sz = -r / 2;
    for (int x = sx; x < sx + r; x++) {
        int cx = (x + midx) >> 4;
        if (chunkX == cx) {
            for (int z = sz; z < sz + r; z++) {
                int cz = (z + midz) >> 4;
                if (chunkZ == cz) {
                    int color = platform[r - x - r / 2 - 1][z + r / 2];
                    if (color == -2) {
                        RFToolsDim.teleportationManager.createReceiver(world, new BlockPos(x + midx, starty, z + midz), information.getName(), -1);
                    } else if (color != -1) {
                        world.setBlockState(new BlockPos(x + midx, starty, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(color), 18);
                    } else {
                        world.setBlockToAir(new BlockPos(x + midx, starty, z + midz));
                    }
                    for (int y = 1; y <= 3; y++) {
                        world.setBlockToAir(new BlockPos(x + midx, starty + y, z + midz));
                    }
                }
            }
        }
    }
    if (chunkX == 0 && chunkZ == 0) {
        registerReceiver(world, dimensionManager, information, midx, midz, starty);
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

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