use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class ForgeEventHandlers method onReplaceBiomeBlocks.
@SubscribeEvent
public void onReplaceBiomeBlocks(ChunkGeneratorEvent.ReplaceBiomeBlocks event) {
World world = event.getWorld();
if (world == null) {
return;
}
WorldProvider provider = world.provider;
if (!(provider instanceof GenericWorldProvider))
return;
DimensionInformation information = ((GenericWorldProvider) provider).getDimensionInformation();
if (information.hasFeatureType(FeatureType.FEATURE_CLEAN)) {
event.setResult(Event.Result.DENY);
}
}
use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class ForgeEventHandlers method onEntityJoinWorldEvent.
@SubscribeEvent
public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) {
World world = event.getWorld();
if (world.isRemote) {
return;
}
WorldProvider provider = world.provider;
if (!(provider instanceof GenericWorldProvider))
return;
DimensionInformation dimensionInformation = ((GenericWorldProvider) provider).getDimensionInformation();
if (dimensionInformation.isNoanimals() && event.getEntity() instanceof IAnimals && !(event.getEntity() instanceof IMob)) {
event.setCanceled(true);
Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.getEntity().getClass().getName());
}
}
use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class ForgeEventHandlers method onEntitySpawnEvent.
@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
World world = event.getWorld();
WorldProvider provider = world.provider;
if (!(provider instanceof GenericWorldProvider))
return;
DimensionInformation dimensionInformation = ((GenericWorldProvider) provider).getDimensionInformation();
if (PowerConfiguration.preventSpawnUnpowered) {
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
if (storage.getEnergyLevel(provider.getDimension()) <= 0) {
event.setResult(Event.Result.DENY);
Logging.logDebug("Dimension power low: Prevented a spawn of " + event.getEntity().getClass().getName());
}
}
if (dimensionInformation.hasEffectType(EffectType.EFFECT_STRONGMOBS) || dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
if (event.getEntity() instanceof EntityLivingBase) {
EntityLivingBase entityLivingBase = (EntityLivingBase) event.getEntity();
IAttributeInstance entityAttribute = entityLivingBase.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
double newMax = entityAttribute.getBaseValue() * (dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS) ? GeneralConfiguration.brutalMobsFactor : GeneralConfiguration.strongMobsFactor);
entityAttribute.setBaseValue(newMax);
entityLivingBase.setHealth((float) newMax);
}
}
if (event.getEntity() instanceof IMob) {
/* BlockPos coordinate = new BlockPos((int) event.getEntity().posX, (int) event.getEntity().posY, (int) event.getEntity().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.isPeaceful()) {
// RFTools dimension.
event.setResult(Event.Result.DENY);
Logging.logDebug("Peaceful dimension: Prevented a spawn of " + event.getEntity().getClass().getName());
}
} else if (event.getEntity() instanceof IAnimals && dimensionInformation.isNoanimals()) {
// RFTools dimension.
event.setResult(Event.Result.DENY);
Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.getEntity().getClass().getName());
}
// @todo
}
use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class FeatureAbsorberTileEntity method checkStateServer.
protected void checkStateServer() {
if (absorbing > 0) {
int dim = getWorld().provider.getDimension();
DimensionInformation information = RfToolsDimensionManager.getDimensionManager(getWorld()).getDimensionInformation(dim);
if (information == null || !information.hasFeatureType(FeatureType.getFeatureById(featureName))) {
return;
}
absorbing--;
markDirtyClient();
}
}
use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.
the class DimensionEditorTileEntity method canDeleteDimension.
private ItemStack canDeleteDimension(ItemStack itemStack) {
if (!GeneralConfiguration.playersCanDeleteDimensions) {
Broadcaster.broadcast(getWorld(), pos.getX(), pos.getY(), pos.getZ(), "Players cannot delete dimensions!", 10);
return ItemStack.EMPTY;
}
if (!GeneralConfiguration.editorCanDeleteDimensions) {
Broadcaster.broadcast(getWorld(), pos.getX(), pos.getY(), pos.getZ(), "Dimension deletion with the editor is not enabled!", 10);
return ItemStack.EMPTY;
}
ItemStack dimensionStack = inventoryHelper.getStackInSlot(DimensionEditorContainer.SLOT_DIMENSIONTARGET);
if (dimensionStack.isEmpty()) {
return ItemStack.EMPTY;
}
NBTTagCompound tagCompound = dimensionStack.getTagCompound();
int id = tagCompound.getInteger("id");
if (id == 0) {
return ItemStack.EMPTY;
}
DimensionInformation information = RfToolsDimensionManager.getDimensionManager(getWorld()).getDimensionInformation(id);
if (getOwnerUUID() != null && getOwnerUUID().equals(information.getOwner())) {
return itemStack;
}
Broadcaster.broadcast(getWorld(), pos.getX(), pos.getY(), pos.getZ(), "This machine's owner differs from the dimensions owner!", 10);
return ItemStack.EMPTY;
}
Aggregations