use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager 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.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class EssencePainterTileEntity method setName.
private void setName(String name) {
ItemStack realizedTab = inventoryHelper.getStackInSlot(EssencePainterContainer.SLOT_TAB);
if (realizedTab != null) {
NBTTagCompound tagCompound = realizedTab.getTagCompound();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
realizedTab.setTagCompound(tagCompound);
}
tagCompound.setString("name", name);
if (tagCompound.hasKey("id")) {
Integer id = tagCompound.getInteger("id");
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(getWorld());
DimensionInformation information = dimensionManager.getDimensionInformation(id);
if (information != null) {
information.setName(name);
dimensionManager.save(getWorld());
}
}
markDirty();
}
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class EssencePainterTileEntity method createRealizedTab.
/**
* Create a realized dimension tab by taking a map of ids per type and storing
* that in the NBT of the realized dimension tab.
*/
public static ItemStack createRealizedTab(DimensionDescriptor descriptor, World world) {
ItemStack realizedTab = new ItemStack(ModItems.realizedDimensionTabItem, 1, 0);
NBTTagCompound tagCompound = new NBTTagCompound();
descriptor.writeToNBT(tagCompound);
// Check if the dimension already exists and if so set the progress to 100%.
RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(world);
Integer id = manager.getDimensionID(descriptor);
if (id != null) {
// The dimension was already created.
tagCompound.setInteger("ticksLeft", 0);
tagCompound.setInteger("id", id);
}
realizedTab.setTagCompound(tagCompound);
return realizedTab;
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class ForgeEventHandlers method onEntitySpawnEvent.
@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
World world = event.getWorld();
int id = world.provider.getDimension();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
if (PowerConfiguration.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.getEntity().getClass().getName());
}
}
}
if (dimensionInformation != null) {
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;
if (dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
newMax = entityAttribute.getBaseValue() * GeneralConfiguration.brutalMobsFactor;
} else {
newMax = entityAttribute.getBaseValue() * 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 != null && 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) {
if (dimensionInformation != null && 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.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class ForgeEventHandlers method onPlayerRightClickEvent.
@SubscribeEvent
public void onPlayerRightClickEvent(PlayerInteractEvent.RightClickBlock event) {
World world = event.getWorld();
if (!world.isRemote) {
Block block = world.getBlockState(event.getPos()).getBlock();
if (block instanceof BlockBed) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionInformation(world.provider.getDimension()) != null) {
// We are in an RFTools dimension.
switch(GeneralConfiguration.bedBehaviour) {
case 0:
event.setCanceled(true);
Logging.message(event.getEntityPlayer(), "You cannot sleep in this dimension!");
break;
case 1:
// Just do the usual thing (this typically mean explosion).
break;
case 2:
event.setCanceled(true);
event.getEntityPlayer().setSpawnChunk(event.getPos(), true, event.getWorld().provider.getDimension());
Logging.message(event.getEntityPlayer(), "Spawn point set!");
break;
}
}
}
}
}
Aggregations