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;
}
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);
}
}
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");
}
}
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;
}
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);
}
}
Aggregations