use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class ReturnEnergyHelper method setEnergyLevel.
public static void setEnergyLevel(PacketReturnEnergy message) {
World world = Minecraft.getMinecraft().theWorld;
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
dimensionStorage.setEnergyLevel(message.getId(), message.getEnergy());
}
use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class ForgeEventHandlers method onAttackEntityEvent.
@SubscribeEvent
public void onAttackEntityEvent(AttackEntityEvent event) {
World world = event.entityPlayer.getEntityWorld();
int id = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionInformation(id) != null) {
// RFTools dimension.
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
int energy = storage.getEnergyLevel(id);
if (energy <= 0) {
event.setCanceled(true);
}
}
}
use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class ForgeEventHandlers method onEntitySpawnEvent.
@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
World world = event.world;
int id = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
if (DimletConfiguration.preventSpawnUnpowered) {
if (dimensionInformation != null) {
// RFTools dimension.
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
int energy = storage.getEnergyLevel(id);
if (energy <= 0) {
event.setResult(Event.Result.DENY);
Logging.logDebug("Dimension power low: Prevented a spawn of " + event.entity.getClass().getName());
}
}
}
if (dimensionInformation != null) {
if (dimensionInformation.hasEffectType(EffectType.EFFECT_STRONGMOBS) || dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
if (event.entity instanceof EntityLivingBase) {
EntityLivingBase entityLivingBase = (EntityLivingBase) event.entity;
IAttributeInstance entityAttribute = entityLivingBase.getEntityAttribute(SharedMonsterAttributes.maxHealth);
double newMax;
if (dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
newMax = entityAttribute.getBaseValue() * DimletConfiguration.brutalMobsFactor;
} else {
newMax = entityAttribute.getBaseValue() * DimletConfiguration.strongMobsFactor;
}
entityAttribute.setBaseValue(newMax);
entityLivingBase.setHealth((float) newMax);
}
}
}
if (event.entity instanceof IMob) {
Coordinate coordinate = new Coordinate((int) event.entity.posX, (int) event.entity.posY, (int) event.entity.posZ);
if (PeacefulAreaManager.isPeaceful(new GlobalCoordinate(coordinate, id))) {
event.setResult(Event.Result.DENY);
Logging.logDebug("Peaceful manager: Prevented a spawn of " + event.entity.getClass().getName());
} else if (dimensionInformation != null && dimensionInformation.isPeaceful()) {
// RFTools dimension.
event.setResult(Event.Result.DENY);
Logging.logDebug("Peaceful dimension: Prevented a spawn of " + event.entity.getClass().getName());
}
} else if (event.entity instanceof IAnimals) {
if (dimensionInformation != null && dimensionInformation.isNoanimals()) {
// RFTools dimension.
event.setResult(Event.Result.DENY);
Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.entity.getClass().getName());
}
}
}
use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class MatterTransmitterTileEntity method checkReceiverStatus.
// Server side only
private int checkReceiverStatus() {
TeleportDestination destination = getTeleportDestination();
if (destination == null) {
return TeleportationTools.STATUS_WARN;
}
int dimension = destination.getDimension();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(worldObj);
if (dimensionManager.getDimensionInformation(dimension) != null) {
// This is an RFTools dimension. Check power.
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(worldObj);
int energyLevel = dimensionStorage.getEnergyLevel(dimension);
if (energyLevel < DimletConfiguration.DIMPOWER_WARN_TP) {
return TeleportationTools.STATUS_WARN;
}
}
World w = DimensionManager.getWorld(dimension);
// By default we will not check if the dimension is not loaded. Can be changed in config.
if (w == null) {
if (TeleportConfiguration.matterTransmitterLoadWorld == -1) {
return TeleportationTools.STATUS_UNKNOWN;
} else {
w = MinecraftServer.getServer().worldServerForDimension(dimension);
checkReceiverStatusCounter = TeleportConfiguration.matterTransmitterLoadWorld;
}
}
Coordinate c = destination.getCoordinate();
boolean exists = w.getChunkProvider().chunkExists(c.getX() >> 4, c.getZ() >> 4);
if (!exists) {
if (TeleportConfiguration.matterTransmitterLoadChunk == -1) {
return TeleportationTools.STATUS_UNKNOWN;
} else {
checkReceiverStatusCounter = TeleportConfiguration.matterTransmitterLoadChunk;
}
}
TileEntity tileEntity = w.getTileEntity(c.getX(), c.getY(), c.getZ());
if (!(tileEntity instanceof MatterReceiverTileEntity)) {
return TeleportationTools.STATUS_WARN;
}
MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) tileEntity;
int status = matterReceiverTileEntity.checkStatus();
return (status == DialingDeviceTileEntity.DIAL_OK) ? TeleportationTools.STATUS_OK : TeleportationTools.STATUS_WARN;
}
use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class CmdListDimensions method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
WorldServer[] worlds = DimensionManager.getWorlds();
for (WorldServer world : worlds) {
int id = world.provider.dimensionId;
String dimName = world.provider.getDimensionName();
sender.addChatMessage(new ChatComponentText(" Loaded: id:" + id + ", " + dimName));
}
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(sender.getEntityWorld());
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(sender.getEntityWorld());
for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
int id = me.getKey();
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
String dimName = dimensionInformation.getName();
int energy = dimensionStorage.getEnergyLevel(id);
String ownerName = dimensionInformation.getOwnerName();
if (ownerName != null && !ownerName.isEmpty()) {
sender.addChatMessage(new ChatComponentText(" RfTools: id:" + id + ", " + dimName + " (power " + energy + ") (owner " + ownerName + ")"));
} else {
sender.addChatMessage(new ChatComponentText(" RfTools: id:" + id + ", " + dimName + " (power " + energy + ")"));
}
}
}
Aggregations