Search in sources :

Example 1 with TileEntityMobSpawner

use of net.minecraft.tileentity.TileEntityMobSpawner in project SimplyJetpacks by Tonius.

the class ItemMysteriousPotato method onItemUse.

@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int meta, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        TileEntity tile = world.getTileEntity(x, y, z);
        if (tile instanceof TileEntityMobSpawner) {
            NBTTagCompound tag = new NBTTagCompound();
            tile.writeToNBT(tag);
            tag.setString("EntityId", "Zombie");
            NBTTagList spawnPotentials = new NBTTagList();
            NBTTagCompound zombieSpawn = new NBTTagCompound();
            zombieSpawn.setString("Type", "Zombie");
            zombieSpawn.setInteger("Weight", 1);
            NBTTagCompound zombieSpawnProperties = new NBTTagCompound();
            zombieSpawnProperties.setString("id", "Zombie");
            NBTTagList equipment = new NBTTagList();
            equipment.appendTag(new NBTTagCompound());
            equipment.appendTag(new NBTTagCompound());
            equipment.appendTag(new NBTTagCompound());
            equipment.appendTag(ModItems.jetpackPotato.writeToNBT(new NBTTagCompound()));
            zombieSpawnProperties.setTag("Equipment", equipment);
            NBTTagList dropChances = new NBTTagList();
            for (int i = 0; i <= 4; i++) {
                dropChances.appendTag(new NBTTagFloat(0.0F));
            }
            zombieSpawnProperties.setTag("DropChances", dropChances);
            zombieSpawn.setTag("Properties", zombieSpawnProperties);
            spawnPotentials.appendTag(zombieSpawn);
            tag.setTag("SpawnPotentials", spawnPotentials);
            tag.setShort("SpawnCount", (short) 2);
            tag.setShort("SpawnRange", (short) 8);
            tag.setShort("Delay", (short) -1);
            tag.setShort("MinSpawnDelay", (short) 30);
            tag.setShort("MaxSpawnDelay", (short) 60);
            tag.setShort("MaxNearbyEntities", (short) 10);
            tag.setShort("RequiredPlayerRange", (short) 96);
            tile.readFromNBT(tag);
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagFloat(net.minecraft.nbt.NBTTagFloat) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner)

Example 2 with TileEntityMobSpawner

use of net.minecraft.tileentity.TileEntityMobSpawner in project PneumaticCraft by MineMaarten.

the class HackableMobSpawner method afterHackTick.

@Override
public boolean afterHackTick(World world, int x, int y, int z) {
    MobSpawnerBaseLogic spawner = ((TileEntityMobSpawner) world.getTileEntity(x, y, z)).func_145881_a();
    //oldRotation = rotation, to stop render glitching
    spawner.field_98284_d = spawner.field_98287_c;
    spawner.spawnDelay = 10;
    return false;
}
Also used : MobSpawnerBaseLogic(net.minecraft.tileentity.MobSpawnerBaseLogic) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner)

Example 3 with TileEntityMobSpawner

use of net.minecraft.tileentity.TileEntityMobSpawner in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method generateLootSpawners.

private void generateLootSpawners(Random random, int chunkX, int chunkZ, World world) {
    BuildingInfo info = new BuildingInfo(chunkX, chunkZ, world.getSeed());
    int buildingtop = 0;
    boolean building = info.hasBuilding;
    if (building) {
        buildingtop = 69 + info.floors * 6;
    }
    int height = 63 - info.floorsBelowGround * 6;
    while (height < buildingtop) {
        int f = LostCitiesTerrainGenerator.getFloor(height);
        if (f == 0) {
            BlockPos floorpos = new BlockPos(chunkX * 16, height, chunkZ * 16);
            int floortype = info.floorTypes[LostCitiesTerrainGenerator.getLevel(height) + info.floorsBelowGround];
            GenInfo getInfo = LostCitiesTerrainGenerator.getGenInfos().get(Pair.of(info.getGenInfoIndex(), floortype));
            for (BlockPos p : getInfo.getChest()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createLootChest(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getRandomFeatures()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createRandomFeature(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getModularStorages()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createModularStorage(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getRandomRFToolsMachines()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createRFToolsMachine(random, world, pos);
                }
            }
            for (Map.Entry<BlockPos, Integer> entry : getInfo.getSpawnerType().entrySet()) {
                BlockPos pos = floorpos.add(entry.getKey());
                if (!world.isAirBlock(pos)) {
                    world.setBlockState(pos, Blocks.MOB_SPAWNER.getDefaultState());
                    TileEntity tileentity = world.getTileEntity(pos);
                    if (tileentity instanceof TileEntityMobSpawner) {
                        TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileentity;
                        switch(entry.getValue()) {
                            case 1:
                                EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:zombie"), "Zombie");
                                break;
                            case 2:
                                EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:skeleton"), "Skeleton");
                                break;
                            case 3:
                                EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:spider"), "Spider");
                                break;
                            case 4:
                                EntityTools.setSpawnerEntity(world, spawner, new ResourceLocation("minecraft:blaze"), "Blaze");
                                break;
                        }
                    }
                }
            }
        }
        height++;
    }
}
Also used : ModularStorageTileEntity(mcjty.rftools.blocks.storage.ModularStorageTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) BuildingInfo(mcjty.rftoolsdim.dimensions.world.terrain.lost.BuildingInfo) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) GenInfo(mcjty.rftoolsdim.dimensions.world.terrain.lost.GenInfo) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner) Map(java.util.Map)

Example 4 with TileEntityMobSpawner

use of net.minecraft.tileentity.TileEntityMobSpawner in project malmo by Microsoft.

the class BlockDrawingHelper method setBlockState.

public void setBlockState(World w, BlockPos pos, XMLBlockState state) {
    if (!state.isValid())
        return;
    // Do some depressingly necessary specific stuff here for different block types:
    if (state.getBlock() instanceof BlockRailBase && state.variant != null) {
        // Caller has specified a variant - is it a shape variant?
        try {
            ShapeTypes shape = ShapeTypes.fromValue(state.variant.getValue());
            if (shape != null) {
                // Yes, user has requested a particular shape.
                // Minecraft won't honour this - and, worse, it may get altered by neighbouring pieces that are added later.
                // So we don't bother trying to get this right now - we add it as a state check, and set it correctly
                // after drawing has finished.
                StateCheck sc = new StateCheck();
                sc.pos = pos;
                sc.desiredState = state.state;
                sc.propertiesToCheck = new ArrayList<IProperty>();
                sc.propertiesToCheck.add(((BlockRailBase) state.getBlock()).getShapeProperty());
                this.checkList.add(sc);
            }
        } catch (IllegalArgumentException e) {
        // Wasn't a shape variation. Ignore.
        }
    }
    // Actually set the block state into the world:
    w.setBlockState(pos, state.state);
    // And now do the necessary post-placement processing:
    if (state.type == BlockType.MOB_SPAWNER) {
        TileEntity te = w.getTileEntity(pos);
        if (// Ought to be!
        te != null && te instanceof TileEntityMobSpawner) {
            // Attempt to use the variation to control what type of mob this spawns:
            try {
                EntityTypes entvar = EntityTypes.fromValue(state.variant.getValue());
                ((TileEntityMobSpawner) te).getSpawnerBaseLogic().setEntityName(entvar.value());
            } catch (Exception e) {
            // Do nothing - user has requested a non-entity variant.
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityTypes(com.microsoft.Malmo.Schemas.EntityTypes) ShapeTypes(com.microsoft.Malmo.Schemas.ShapeTypes) IProperty(net.minecraft.block.properties.IProperty) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner) BlockRailBase(net.minecraft.block.BlockRailBase)

Example 5 with TileEntityMobSpawner

use of net.minecraft.tileentity.TileEntityMobSpawner in project PneumaticCraft by MineMaarten.

the class BlockTrackEntryMobSpawner method addInformation.

@Override
public void addInformation(World world, int x, int y, int z, TileEntity te, List<String> infoList) {
    if (te instanceof TileEntityMobSpawner) {
        MobSpawnerBaseLogic spawner = ((TileEntityMobSpawner) te).func_145881_a();
        infoList.add("Spawner Type: " + StatCollector.translateToLocal("entity." + spawner.getEntityNameToSpawn() + ".name"));
        if (spawner.isActivated()) {
            infoList.add("Time until next spawn: " + PneumaticCraftUtils.convertTicksToMinutesAndSeconds(spawner.spawnDelay, false));
        } else if (HackableMobSpawner.isHacked(world, x, y, z)) {
            infoList.add("Spawner is hacked");
        } else {
            infoList.add("Spawner is standing by");
        }
    }
}
Also used : MobSpawnerBaseLogic(net.minecraft.tileentity.MobSpawnerBaseLogic) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner)

Aggregations

TileEntityMobSpawner (net.minecraft.tileentity.TileEntityMobSpawner)6 TileEntity (net.minecraft.tileentity.TileEntity)4 NBTTagList (net.minecraft.nbt.NBTTagList)2 MobSpawnerBaseLogic (net.minecraft.tileentity.MobSpawnerBaseLogic)2 BlockPos (net.minecraft.util.math.BlockPos)2 EntityTypes (com.microsoft.Malmo.Schemas.EntityTypes)1 ShapeTypes (com.microsoft.Malmo.Schemas.ShapeTypes)1 List (java.util.List)1 Map (java.util.Map)1 ModularStorageTileEntity (mcjty.rftools.blocks.storage.ModularStorageTileEntity)1 BuildingInfo (mcjty.rftoolsdim.dimensions.world.terrain.lost.BuildingInfo)1 GenInfo (mcjty.rftoolsdim.dimensions.world.terrain.lost.GenInfo)1 Block (net.minecraft.block.Block)1 BlockChest (net.minecraft.block.BlockChest)1 BlockMobSpawner (net.minecraft.block.BlockMobSpawner)1 BlockRailBase (net.minecraft.block.BlockRailBase)1 IProperty (net.minecraft.block.properties.IProperty)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityList (net.minecraft.entity.EntityList)1 IInventory (net.minecraft.inventory.IInventory)1