Java Code Examples for net.minecraft.tileentity.MobSpawnerBaseLogic

The following examples show how to use net.minecraft.tileentity.MobSpawnerBaseLogic. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public void generate(IWorldEditor editor, Random rand, Coord cursor, int level){
	Coord pos = new Coord(cursor);
	editor.setBlock(pos, new MetaBlock(Blocks.MOB_SPAWNER.getDefaultState()), true,	true);
	
	TileEntity tileentity = editor.getTileEntity(pos);
	if (!(tileentity instanceof TileEntityMobSpawner)) return;
	
	TileEntityMobSpawner spawner = (TileEntityMobSpawner)tileentity;
	MobSpawnerBaseLogic spawnerLogic = spawner.getSpawnerBaseLogic();
	
	NBTTagCompound nbt = new NBTTagCompound();
	nbt.setInteger("x", pos.getX());
	nbt.setInteger("y", pos.getY());
	nbt.setInteger("z", pos.getZ());
	
	nbt.setTag("SpawnPotentials", getSpawnPotentials(rand, level));
	
	spawnerLogic.readFromNBT(nbt);
	spawnerLogic.updateSpawner();
	tileentity.markDirty();
}
 
Example 2
@Inject(method = "renderMob", cancellable = true, at = @At("HEAD"))
private static void injectPaintingSpawnerFix(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks, CallbackInfo ci) {
    Entity entity = mobSpawnerLogic.func_180612_a(mobSpawnerLogic.getSpawnerWorld());

    if (entity == null || entity instanceof EntityPainting)
        ci.cancel();
}
 
Example 3
@Inject(method = "renderMob", cancellable = true, at = @At("HEAD"))
private static void injectPaintingSpawnerFix(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks, CallbackInfo ci) {
    Entity entity = mobSpawnerLogic.func_180612_a(mobSpawnerLogic.getSpawnerWorld());

    if (entity == null || entity instanceof EntityPainting)
        ci.cancel();
}
 
Example 4
@Override
public boolean afterHackTick(World world, int x, int y, int z){
    MobSpawnerBaseLogic spawner = ((TileEntityMobSpawner)world.getTileEntity(x, y, z)).func_145881_a();
    spawner.field_98284_d = spawner.field_98287_c;//oldRotation = rotation, to stop render glitching
    spawner.spawnDelay = 10;
    return false;
}
 
Example 5
@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");
        }
    }

}
 
Example 6
Source Project: ToroQuest   Source File: MageTowerGenerator.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static void placeSpawner(World world, BlockPos pos, String mob) {
	placeBlock(world, pos, Blocks.MOB_SPAWNER);
	TileEntityMobSpawner theSpawner = (TileEntityMobSpawner) world.getTileEntity(pos);
	MobSpawnerBaseLogic logic = theSpawner.getSpawnerBaseLogic();
	logic.setEntityId(new ResourceLocation(mob));
}
 
Example 7
Source Project: ToroQuest   Source File: MonolithGenerator.java    License: GNU General Public License v3.0 4 votes vote down vote up
public void placeSpawner(World world, BlockPos pos) {
	setBlockAndNotifyAdequately(world, pos, Blocks.MOB_SPAWNER.getDefaultState());
	TileEntityMobSpawner theSpawner = (TileEntityMobSpawner) world.getTileEntity(pos);
	MobSpawnerBaseLogic logic = theSpawner.getSpawnerBaseLogic();
	logic.setEntityId(new ResourceLocation("magma_cube"));
}
 
Example 8
Source Project: OpenPeripheral-Integration   Source File: AdapterMobSpawner.java    License: MIT License 4 votes vote down vote up
private static MobSpawnerBaseLogic getSpawnerLogic(TileEntityMobSpawner spawner) {
	return spawner.func_145881_a();
}