Search in sources :

Example 26 with DimensionInformation

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);
    }
}
Also used : GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 27 with DimensionInformation

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());
    }
}
Also used : IAnimals(net.minecraft.entity.passive.IAnimals) IMob(net.minecraft.entity.monster.IMob) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 28 with DimensionInformation

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
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) IAnimals(net.minecraft.entity.passive.IAnimals) IMob(net.minecraft.entity.monster.IMob) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 29 with DimensionInformation

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();
    }
}
Also used : DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation)

Example 30 with DimensionInformation

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;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation)

Aggregations

DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)34 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)21 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)11 World (net.minecraft.world.World)10 ItemStack (net.minecraft.item.ItemStack)8 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 ITextComponent (net.minecraft.util.text.ITextComponent)5 TextComponentString (net.minecraft.util.text.TextComponentString)5 IOException (java.io.IOException)4 GenericWorldProvider (mcjty.rftoolsdim.dimensions.world.GenericWorldProvider)4 PacketGetDimensionEnergy (mcjty.rftoolsdim.network.PacketGetDimensionEnergy)4 IBlockState (net.minecraft.block.state.IBlockState)4 PacketBuffer (net.minecraft.network.PacketBuffer)4 ActionResult (net.minecraft.util.ActionResult)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 WorldProvider (net.minecraft.world.WorldProvider)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 Map (java.util.Map)3