use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class ForgeEventHandlers method onPlayerInterractEvent.
@SubscribeEvent
public void onPlayerInterractEvent(PlayerInteractEvent event) {
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
World world = event.world;
if (!world.isRemote) {
Block block = world.getBlock(event.x, event.y, event.z);
if (block instanceof BlockBed) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionInformation(world.provider.dimensionId) != null) {
// We are in an RFTools dimension.
switch(DimletConfiguration.bedBehaviour) {
case 0:
event.setCanceled(true);
Logging.message(event.entityPlayer, "You cannot sleep in this dimension!");
break;
case 1:
// Just do the usual thing (this typically mean explosion).
break;
case 2:
event.setCanceled(true);
int meta = BedControl.getBedMeta(world, event.x, event.y, event.z);
if (meta != -1) {
BedControl.trySleep(world, event.entityPlayer, event.x, event.y, event.z, meta);
}
break;
}
}
}
}
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager 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.RfToolsDimensionManager 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.RfToolsDimensionManager 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);
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class BedControl method trySleep.
public static boolean trySleep(World world, EntityPlayer player, int x, int y, int z, int meta) {
if (BlockBed.func_149976_c(meta)) {
EntityPlayer entityplayer1 = null;
for (Object playerEntity : world.playerEntities) {
EntityPlayer entityplayer2 = (EntityPlayer) playerEntity;
if (entityplayer2.isPlayerSleeping()) {
ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation;
if (chunkcoordinates.posX == x && chunkcoordinates.posY == y && chunkcoordinates.posZ == z) {
entityplayer1 = entityplayer2;
}
}
}
if (entityplayer1 != null) {
player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.occupied"));
return true;
}
BlockBed.func_149979_a(world, x, y, z, false);
}
EntityPlayer.EnumStatus enumstatus = player.sleepInBedAt(x, y, z);
if (enumstatus == EntityPlayer.EnumStatus.OK) {
BlockBed.func_149979_a(world, x, y, z, true);
RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = manager.getDimensionInformation(world.provider.dimensionId);
if (DimletConfiguration.respawnSameDim || (information != null && information.isRespawnHere())) {
player.addChatComponentMessage(new ChatComponentText("Somehow this place feels more like home now."));
}
return true;
} else {
if (enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW) {
player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep"));
} else if (enumstatus == EntityPlayer.EnumStatus.NOT_SAFE) {
player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe"));
}
return true;
}
}
Aggregations