Search in sources :

Example 1 with GenericWorldProvider

use of mcjty.rftoolsdim.dimensions.world.GenericWorldProvider in project RFToolsDimensions by McJty.

the class ForgeEventHandlers method onOreGenEvent.

@SubscribeEvent
public void onOreGenEvent(OreGenEvent.GenerateMinable 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 != null && 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 2 with GenericWorldProvider

use of mcjty.rftoolsdim.dimensions.world.GenericWorldProvider 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 3 with GenericWorldProvider

use of mcjty.rftoolsdim.dimensions.world.GenericWorldProvider in project RFToolsDimensions by McJty.

the class ForgeEventHandlers method onPlayerRightClickEvent.

@SubscribeEvent
public void onPlayerRightClickEvent(PlayerInteractEvent.RightClickBlock event) {
    World world = event.getWorld();
    if (world.isRemote)
        return;
    BlockPos pos = event.getPos();
    WorldProvider provider = world.provider;
    if (!(world.getBlockState(pos).getBlock() instanceof BlockBed && provider instanceof GenericWorldProvider))
        return;
    // 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;
        // In case 1, just do the usual thing (this typically mean explosion).
        case 2:
            event.setCanceled(true);
            event.getEntityPlayer().setSpawnChunk(pos, true, provider.getDimension());
            Logging.message(event.getEntityPlayer(), "Spawn point set!");
    }
}
Also used : GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) BlockBed(net.minecraft.block.BlockBed) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with GenericWorldProvider

use of mcjty.rftoolsdim.dimensions.world.GenericWorldProvider in project RFToolsDimensions by McJty.

the class ForgeEventHandlers method onEntitySpawn.

@SubscribeEvent
public void onEntitySpawn(LivingSpawnEvent.SpecialSpawn event) {
    World world = event.getWorld();
    if (world.isRemote) {
        return;
    }
    EntityLivingBase entityLiving = event.getEntityLiving();
    if (entityLiving instanceof EntityDragon && world.provider instanceof GenericWorldProvider) {
        // Ender dragon needs to be spawned with an additional NBT key set
        NBTTagCompound dragonTag = new NBTTagCompound();
        entityLiving.writeEntityToNBT(dragonTag);
        dragonTag.setShort("DragonPhase", (short) 0);
        entityLiving.readEntityFromNBT(dragonTag);
    }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) World(net.minecraft.world.World) GenericWorldProvider(mcjty.rftoolsdim.dimensions.world.GenericWorldProvider) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

GenericWorldProvider (mcjty.rftoolsdim.dimensions.world.GenericWorldProvider)4 World (net.minecraft.world.World)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 WorldProvider (net.minecraft.world.WorldProvider)3 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)2 BlockBed (net.minecraft.block.BlockBed)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 BlockPos (net.minecraft.util.math.BlockPos)1