use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.
the class CmdSetPower method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length > 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
int rf = fetchInt(sender, args, 1, DimletConfiguration.MAX_DIMENSION_POWER);
World world = sender.getEntityWorld();
int dim = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
return;
}
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
storage.setEnergyLevel(dim, rf);
storage.save(world);
}
use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.
the class CmdSaveDim method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and filename parameters are missing!"));
return;
} else if (args.length > 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
int dim = fetchInt(sender, args, 1, 0);
String filename = fetchString(sender, args, 2, null);
World world = sender.getEntityWorld();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionDescriptor(dim) == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
return;
}
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
String error = information.buildJson(filename);
if (error != null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Error: " + error));
}
}
use of mcjty.rftools.dimension.DimensionInformation 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.DimensionInformation in project RFTools by McJty.
the class ForgeEventHandlers method onReplaceBiomeBlocks.
@SubscribeEvent
public void onReplaceBiomeBlocks(ChunkProviderEvent.ReplaceBiomeBlocks event) {
World world = event.world;
if (world == null) {
return;
}
int id = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(id);
if (information != null && information.hasFeatureType(FeatureType.FEATURE_CLEAN)) {
event.setResult(Event.Result.DENY);
}
}
use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.
the class ForgeTerrainGenHandlers method onDecorateBiome.
@SubscribeEvent
public void onDecorateBiome(DecorateBiomeEvent.Decorate event) {
World world = event.world;
int id = world.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(id);
if (information != null && information.hasFeatureType(FeatureType.FEATURE_CLEAN)) {
event.setResult(Event.Result.DENY);
}
}
Aggregations