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;
}
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;
}
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++;
}
}
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.
}
}
}
}
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");
}
}
}
Aggregations