Java Code Examples for net.minecraft.tileentity.MobSpawnerBaseLogic

The following are top voted examples for showing how to use net.minecraft.tileentity.MobSpawnerBaseLogic. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: pnc-repressurized   File: BlockTrackEntryMobSpawner.java   Source Code and License 6 votes vote down vote up
@Override
    public void addInformation(World world, BlockPos pos, TileEntity te, List<String> infoList) {
        if (te instanceof TileEntityMobSpawner) {
            MobSpawnerBaseLogic spawner = ((TileEntityMobSpawner) te).getSpawnerBaseLogic();
            ResourceLocation rl = Reflections.getEntityId(spawner);
//            infoList.add("Spawner Type: " + I18n.format("entity." + spawner.getEntityNameToSpawn() + ".name"));
            infoList.add("Spawner Type: " + (rl == null ? "?" : rl.toString()));
            
            if (Reflections.isActivated(spawner) || SemiBlockManager.getInstance(world).getSemiBlock(SemiBlockSpawnerAgitator.class, world, pos) != null) {
                infoList.add("Time until next spawn: " + PneumaticCraftUtils.convertTicksToMinutesAndSeconds(spawner.spawnDelay, false));
            } else if (HackableMobSpawner.isHacked(world, pos)) {
                infoList.add("Spawner is hacked");
            } else {
                infoList.add("Spawner is standing by");
            }
        }

    }
 
Example 2
Project: pnc-repressurized   File: SemiBlockSpawnerAgitator.java   Source Code and License 6 votes vote down vote up
@Override
public void update() {
    super.update();
    if (!world.isRemote) {
        TileEntityMobSpawner te = getTileEntity();
        if(te != null){
            MobSpawnerBaseLogic spawnerLogic = te.getSpawnerBaseLogic();
            
            //Only tick the logic if it wasn't ticked already by the TE itself, to prevent double ticking.
            if(!Reflections.isActivated(spawnerLogic)){
                
                //Temporarily add a fake player to the world to trick the spawner into thinking there's a player nearby
                EntityPlayer fakePlayer = FakePlayerFactory.get((WorldServer)world, FAKE_PLAYER_PROFILE);
                fakePlayer.posX = getPos().getX();
                fakePlayer.posY = getPos().getY();
                fakePlayer.posZ = getPos().getZ();
                
                world.playerEntities.add(fakePlayer);
                spawnerLogic.updateSpawner();
                world.playerEntities.remove(fakePlayer);
            }                
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * Render the mob inside the mob spawner.
 */
public static void renderMob(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks)
{
    Entity entity = mobSpawnerLogic.func_180612_a(mobSpawnerLogic.getSpawnerWorld());

    if (entity != null)
    {
        float f = 0.4375F;
        GlStateManager.translate(0.0F, 0.4F, 0.0F);
        GlStateManager.rotate((float)(mobSpawnerLogic.getPrevMobRotation() + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation()) * (double)partialTicks) * 10.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-30.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.4F, 0.0F);
        GlStateManager.scale(f, f, f);
        entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
        Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks);
    }
}
 
Example 4
Project: BaseClient   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * Render the mob inside the mob spawner.
 */
public static void renderMob(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks)
{
    Entity entity = mobSpawnerLogic.func_180612_a(mobSpawnerLogic.getSpawnerWorld());

    if (entity != null)
    {
        float f = 0.4375F;
        GlStateManager.translate(0.0F, 0.4F, 0.0F);
        GlStateManager.rotate((float)(mobSpawnerLogic.getPrevMobRotation() + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation()) * (double)partialTicks) * 10.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-30.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.4F, 0.0F);
        GlStateManager.scale(f, f, f);
        entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
        Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks);
    }
}
 
Example 5
Project: BaseClient   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * Render the mob inside the mob spawner.
 */
public static void renderMob(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks)
{
    Entity entity = mobSpawnerLogic.func_180612_a(mobSpawnerLogic.getSpawnerWorld());

    if (entity != null)
    {
        float f = 0.4375F;
        GlStateManager.translate(0.0F, 0.4F, 0.0F);
        GlStateManager.rotate((float)(mobSpawnerLogic.getPrevMobRotation() + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation()) * (double)partialTicks) * 10.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-30.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.4F, 0.0F);
        GlStateManager.scale(f, f, f);
        entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
        Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks);
    }
}
 
Example 6
Project: Backmemed   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * Render the mob inside the mob spawner.
 */
public static void renderMob(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks)
{
    Entity entity = mobSpawnerLogic.getCachedEntity();

    if (entity != null)
    {
        float f = 0.53125F;
        float f1 = Math.max(entity.width, entity.height);

        if ((double)f1 > 1.0D)
        {
            f /= f1;
        }

        GlStateManager.translate(0.0F, 0.4F, 0.0F);
        GlStateManager.rotate((float)(mobSpawnerLogic.getPrevMobRotation() + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation()) * (double)partialTicks) * 10.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.2F, 0.0F);
        GlStateManager.rotate(-30.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(f, f, f);
        entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
        Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks, false);
    }
}
 
Example 7
Project: CustomWorldGen   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * Render the mob inside the mob spawner.
 */
public static void renderMob(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks)
{
    Entity entity = mobSpawnerLogic.getCachedEntity();

    if (entity != null)
    {
        float f = 0.53125F;
        float f1 = Math.max(entity.width, entity.height);

        if ((double)f1 > 1.0D)
        {
            f /= f1;
        }

        GlStateManager.translate(0.0F, 0.4F, 0.0F);
        GlStateManager.rotate((float)(mobSpawnerLogic.getPrevMobRotation() + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation()) * (double)partialTicks) * 10.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.2F, 0.0F);
        GlStateManager.rotate(-30.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(f, f, f);
        entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
        Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks, false);
    }
}
 
Example 8
Project: PopularMMOS-EpicProportions-Mod   File: BombySpawnerBaseLogic.java   Source Code and License 6 votes vote down vote up
private void resetTimer()
{
    if (this.maxSpawnDelay <= this.minSpawnDelay)
    {
        this.spawnDelay = this.minSpawnDelay;
    }
    else
    {
        int i = this.maxSpawnDelay - this.minSpawnDelay;
        this.spawnDelay = this.minSpawnDelay + this.getSpawnerWorld().rand.nextInt(i);
    }

    if (this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0)
    {
        this.setRandomEntity((MobSpawnerBaseLogic.WeightedRandomMinecart)WeightedRandom.getRandomItem(this.getSpawnerWorld().rand, this.potentialEntitySpawns));
    }

    this.func_98267_a(1);
}
 
Example 9
Project: PopularMMOS-EpicProportions-Mod   File: Fred2_0SpawnerBaseLogic.java   Source Code and License 6 votes vote down vote up
private void resetTimer()
{
    if (this.maxSpawnDelay <= this.minSpawnDelay)
    {
        this.spawnDelay = this.minSpawnDelay;
    }
    else
    {
        int i = this.maxSpawnDelay - this.minSpawnDelay;
        this.spawnDelay = this.minSpawnDelay + this.getSpawnerWorld().rand.nextInt(i);
    }

    if (this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0)
    {
        this.setRandomEntity((MobSpawnerBaseLogic.WeightedRandomMinecart)WeightedRandom.getRandomItem(this.getSpawnerWorld().rand, this.potentialEntitySpawns));
    }

    this.func_98267_a(1);
}
 
Example 10
Project: Resilience-Client-Source   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
public static void func_147517_a(MobSpawnerBaseLogic p_147517_0_, double p_147517_1_, double p_147517_3_, double p_147517_5_, float p_147517_7_)
{
    Entity var8 = p_147517_0_.func_98281_h();

    if (var8 != null)
    {
        var8.setWorld(p_147517_0_.getSpawnerWorld());
        float var9 = 0.4375F;
        GL11.glTranslatef(0.0F, 0.4F, 0.0F);
        GL11.glRotatef((float)(p_147517_0_.field_98284_d + (p_147517_0_.field_98287_c - p_147517_0_.field_98284_d) * (double)p_147517_7_) * 10.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, -0.4F, 0.0F);
        GL11.glScalef(var9, var9, var9);
        var8.setLocationAndAngles(p_147517_1_, p_147517_3_, p_147517_5_, 0.0F, 0.0F);
        RenderManager.instance.func_147940_a(var8, 0.0D, 0.0D, 0.0D, 0.0F, p_147517_7_);
    }
}
 
Example 11
Project: ExpandedRailsMod   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
/**
 * Render the mob inside the mob spawner.
 */
public static void renderMob(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks)
{
    Entity entity = mobSpawnerLogic.getCachedEntity();

    if (entity != null)
    {
        float f = 0.53125F;
        float f1 = Math.max(entity.width, entity.height);

        if ((double)f1 > 1.0D)
        {
            f /= f1;
        }

        GlStateManager.translate(0.0F, 0.4F, 0.0F);
        GlStateManager.rotate((float)(mobSpawnerLogic.getPrevMobRotation() + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation()) * (double)partialTicks) * 10.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.2F, 0.0F);
        GlStateManager.rotate(-30.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(f, f, f);
        entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
        Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks, false);
    }
}
 
Example 12
Project: Cauldron   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
public static void func_147517_a(MobSpawnerBaseLogic p_147517_0_, double p_147517_1_, double p_147517_3_, double p_147517_5_, float p_147517_7_)
{
    Entity entity = p_147517_0_.func_98281_h();

    if (entity != null)
    {
        entity.setWorld(p_147517_0_.getSpawnerWorld());
        float f1 = 0.4375F;
        GL11.glTranslatef(0.0F, 0.4F, 0.0F);
        GL11.glRotatef((float)(p_147517_0_.field_98284_d + (p_147517_0_.field_98287_c - p_147517_0_.field_98284_d) * (double)p_147517_7_) * 10.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, -0.4F, 0.0F);
        GL11.glScalef(f1, f1, f1);
        entity.setLocationAndAngles(p_147517_1_, p_147517_3_, p_147517_5_, 0.0F, 0.0F);
        RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, p_147517_7_);
    }
}
 
Example 13
Project: Cauldron   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
public static void func_147517_a(MobSpawnerBaseLogic p_147517_0_, double p_147517_1_, double p_147517_3_, double p_147517_5_, float p_147517_7_)
{
    Entity entity = p_147517_0_.func_98281_h();

    if (entity != null)
    {
        entity.setWorld(p_147517_0_.getSpawnerWorld());
        float f1 = 0.4375F;
        GL11.glTranslatef(0.0F, 0.4F, 0.0F);
        GL11.glRotatef((float)(p_147517_0_.field_98284_d + (p_147517_0_.field_98287_c - p_147517_0_.field_98284_d) * (double)p_147517_7_) * 10.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, -0.4F, 0.0F);
        GL11.glScalef(f1, f1, f1);
        entity.setLocationAndAngles(p_147517_1_, p_147517_3_, p_147517_5_, 0.0F, 0.0F);
        RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, p_147517_7_);
    }
}
 
Example 14
Project: RuneCraftery   File: WeightedRandomMinecart.java   Source Code and License 6 votes vote down vote up
public WeightedRandomMinecart(MobSpawnerBaseLogic p_i1945_1_, NBTTagCompound p_i1945_2_) {
   super(p_i1945_2_.func_74762_e("Weight"));
   this.field_98221_d = p_i1945_1_;
   NBTTagCompound var3 = p_i1945_2_.func_74775_l("Properties");
   String var4 = p_i1945_2_.func_74779_i("Type");
   if(var4.equals("Minecart")) {
      if(var3 != null) {
         switch(var3.func_74762_e("Type")) {
         case 0:
            var4 = "MinecartRideable";
            break;
         case 1:
            var4 = "MinecartChest";
            break;
         case 2:
            var4 = "MinecartFurnace";
         }
      } else {
         var4 = "MinecartRideable";
      }
   }

   this.field_98222_b = var3;
   this.field_98223_c = var4;
}
 
Example 15
Project: RuneCraftery   File: WeightedRandomMinecart.java   Source Code and License 6 votes vote down vote up
public WeightedRandomMinecart(MobSpawnerBaseLogic p_i1946_1_, NBTTagCompound p_i1946_2_, String p_i1946_3_) {
   super(1);
   this.field_98221_d = p_i1946_1_;
   if(p_i1946_3_.equals("Minecart")) {
      if(p_i1946_2_ != null) {
         switch(p_i1946_2_.func_74762_e("Type")) {
         case 0:
            p_i1946_3_ = "MinecartRideable";
            break;
         case 1:
            p_i1946_3_ = "MinecartChest";
            break;
         case 2:
            p_i1946_3_ = "MinecartFurnace";
         }
      } else {
         p_i1946_3_ = "MinecartRideable";
      }
   }

   this.field_98222_b = p_i1946_2_;
   this.field_98223_c = p_i1946_3_;
}
 
Example 16
Project: RuneCraftery   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
public static void func_98144_a(MobSpawnerBaseLogic par0MobSpawnerBaseLogic, double par1, double par3, double par5, float par7)
{
    Entity entity = par0MobSpawnerBaseLogic.func_98281_h();

    if (entity != null)
    {
        entity.setWorld(par0MobSpawnerBaseLogic.getSpawnerWorld());
        float f1 = 0.4375F;
        GL11.glTranslatef(0.0F, 0.4F, 0.0F);
        GL11.glRotatef((float)(par0MobSpawnerBaseLogic.field_98284_d + (par0MobSpawnerBaseLogic.field_98287_c - par0MobSpawnerBaseLogic.field_98284_d) * (double)par7) * 10.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, -0.4F, 0.0F);
        GL11.glScalef(f1, f1, f1);
        entity.setLocationAndAngles(par1, par3, par5, 0.0F, 0.0F);
        RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, par7);
    }
}
 
Example 17
Project: BetterNutritionMod   File: TileEntityMobSpawnerRenderer.java   Source Code and License 6 votes vote down vote up
public static void func_98144_a(MobSpawnerBaseLogic par0MobSpawnerBaseLogic, double par1, double par3, double par5, float par7)
{
    Entity entity = par0MobSpawnerBaseLogic.func_98281_h();

    if (entity != null)
    {
        entity.setWorld(par0MobSpawnerBaseLogic.getSpawnerWorld());
        float f1 = 0.4375F;
        GL11.glTranslatef(0.0F, 0.4F, 0.0F);
        GL11.glRotatef((float)(par0MobSpawnerBaseLogic.field_98284_d + (par0MobSpawnerBaseLogic.field_98287_c - par0MobSpawnerBaseLogic.field_98284_d) * (double)par7) * 10.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, -0.4F, 0.0F);
        GL11.glScalef(f1, f1, f1);
        entity.setLocationAndAngles(par1, par3, par5, 0.0F, 0.0F);
        RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, par7);
    }
}
 
Example 18
Project: Hats   File: HatHandler.java   Source Code and License 6 votes vote down vote up
public static MobSpawnerBaseLogic getMobSpawnerLogic(Class<? extends TileEntity> clz, TileEntity instance)
{
    try
    {
        Field field = mobSpawnerLogic.get(clz);
        if(field != null)
        {
            field.setAccessible(true);
            Object obj = field.get(instance);
            if(obj instanceof MobSpawnerBaseLogic)
            {
                return (MobSpawnerBaseLogic)obj;
            }
        }
    }
    catch(Exception e)
    {
    }
    return null;
}
 
Example 19
Project: minecraft-roguelike   File: Spawnable.java   Source Code and License 6 votes vote down vote up
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 20
Project: pnc-repressurized   File: HackableMobSpawner.java   Source Code and License 5 votes vote down vote up
@Override
public boolean afterHackTick(World world, BlockPos pos) {
    MobSpawnerBaseLogic spawner = ((TileEntityMobSpawner) world.getTileEntity(pos)).getSpawnerBaseLogic();
    spawner.prevMobRotation = spawner.getMobRotation();
    spawner.spawnDelay = 10;
    return false;
}
 
Example 21
Project: pnc-repressurized   File: Reflections.java   Source Code and License 5 votes vote down vote up
public static void init() {
    msbl_isActivated = ReflectionHelper.findMethod(MobSpawnerBaseLogic.class, "isActivated", "func_98279_f");
    msbl_getEntityId = ReflectionHelper.findMethod(MobSpawnerBaseLogic.class, "getEntityId", "func_190895_g");
    
    // access to non-public entity AI's for hacking purposes
    blaze_aiFireballAttack = findEnclosedClass(EntityBlaze.class, "AIFireballAttack", "a");
    ghast_aiFireballAttack = findEnclosedClass(EntityGhast.class, "AIFireballAttack", "c");
}
 
Example 22
Project: pnc-repressurized   File: Reflections.java   Source Code and License 5 votes vote down vote up
public static ResourceLocation getEntityId(MobSpawnerBaseLogic msbl) {
    try {
        return (ResourceLocation) msbl_getEntityId.invoke(msbl);
    } catch (IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 23
Project: pnc-repressurized   File: Reflections.java   Source Code and License 5 votes vote down vote up
public static boolean isActivated(MobSpawnerBaseLogic msbl) {
    try {
        return (boolean) msbl_isActivated.invoke(msbl);
    } catch (IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
        return false;
    }
}
 
Example 24
Project: pnc-repressurized   File: SemiBlockSpawnerAgitator.java   Source Code and License 5 votes vote down vote up
private void setSpawnPersistentEntities(boolean persistent){
    TileEntityMobSpawner te = getTileEntity();
    if(te != null){
        MobSpawnerBaseLogic spawnerLogic = te.getSpawnerBaseLogic();
        spawnerLogic.spawnData.getNbt().setBoolean("PersistenceRequired", persistent);
    }
}
 
Example 25
Project: ExtraUtilities   File: BlockCursedEarth.java   Source Code and License 5 votes vote down vote up
public void resetTimer(final MobSpawnerBaseLogic logic) {
    if (this.cache == null) {
        this.cache = ReflectionHelper.findMethod((Class)MobSpawnerBaseLogic.class, (Object)logic, new String[] { "resetTimer", "func_98273_j" }, new Class[0]);
    }
    try {
        this.cache.invoke(logic, new Object[0]);
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 26
Project: InspiringWorld   File: EnderSpiderSpawnerGen.java   Source Code and License 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
    IChunkProvider chunkProvider) {
    for (TileEntity tileEntity : world.getChunkFromChunkCoords(chunkX, chunkZ).getTileEntityMap().values()) {
        if (tileEntity instanceof TileEntityMobSpawner) {
            MobSpawnerBaseLogic spawner = ((TileEntityMobSpawner) tileEntity).getSpawnerBaseLogic();
            if ("CaveSpider".equals(spawner.getEntityNameToSpawn()) && random.nextInt(4) == 0) {
                spawner.setEntityName("EnderSpider");
            }
        }
    }
}
 
Example 27
Project: PopularMMOS-EpicProportions-Mod   File: BombySpawnerBaseLogic.java   Source Code and License 5 votes vote down vote up
public void writeToNBT(NBTTagCompound p_98280_1_)
{
    p_98280_1_.setString("EntityId", this.getEntityNameToSpawn());
    p_98280_1_.setShort("Delay", (short)this.spawnDelay);
    p_98280_1_.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
    p_98280_1_.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
    p_98280_1_.setShort("SpawnCount", (short)this.spawnCount);
    p_98280_1_.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
    p_98280_1_.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
    p_98280_1_.setShort("SpawnRange", (short)this.spawnRange);

    if (this.getRandomEntity() != null)
    {
        p_98280_1_.setTag("SpawnData", this.getRandomEntity().field_98222_b.copy());
    }

    if (this.getRandomEntity() != null || this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0)
    {
        NBTTagList nbttaglist = new NBTTagList();

        if (this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0)
        {
            Iterator iterator = this.potentialEntitySpawns.iterator();

            while (iterator.hasNext())
            {
                MobSpawnerBaseLogic.WeightedRandomMinecart weightedrandomminecart = (MobSpawnerBaseLogic.WeightedRandomMinecart)iterator.next();
                nbttaglist.appendTag(weightedrandomminecart.func_98220_a());
            }
        }
        else
        {
            nbttaglist.appendTag(this.getRandomEntity().func_98220_a());
        }

        p_98280_1_.setTag("SpawnPotentials", nbttaglist);
    }
}
 
Example 28
Project: PopularMMOS-EpicProportions-Mod   File: TileEntityBombySpawner.java   Source Code and License 5 votes vote down vote up
public void setRandomEntity(MobSpawnerBaseLogic.WeightedRandomMinecart p_98277_1_)
{
    super.setRandomEntity(p_98277_1_);

    if (this.getSpawnerWorld() != null)
    {
        this.getSpawnerWorld().markBlockForUpdate(TileEntityBombySpawner.this.xCoord, TileEntityBombySpawner.this.yCoord, TileEntityBombySpawner.this.zCoord);
    }
}
 
Example 29
Project: PopularMMOS-EpicProportions-Mod   File: Fred2_0SpawnerBaseLogic.java   Source Code and License 5 votes vote down vote up
public void writeToNBT(NBTTagCompound p_98280_1_)
{
    //p_98280_1_.setString("EntityId", this.getEntityNameToSpawn());
    p_98280_1_.setShort("Delay", (short)this.spawnDelay);
    p_98280_1_.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
    p_98280_1_.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
    p_98280_1_.setShort("SpawnCount", (short)this.spawnCount);
    p_98280_1_.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
    p_98280_1_.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
    p_98280_1_.setShort("SpawnRange", (short)this.spawnRange);

    if (this.getRandomEntity() != null)
    {
        p_98280_1_.setTag("SpawnData", this.getRandomEntity().field_98222_b.copy());
    }

    if (this.getRandomEntity() != null || this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0)
    {
        NBTTagList nbttaglist = new NBTTagList();

        if (this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0)
        {
            Iterator iterator = this.potentialEntitySpawns.iterator();

            while (iterator.hasNext())
            {
                MobSpawnerBaseLogic.WeightedRandomMinecart weightedrandomminecart = (MobSpawnerBaseLogic.WeightedRandomMinecart)iterator.next();
                nbttaglist.appendTag(weightedrandomminecart.func_98220_a());
            }
        }
        else
        {
            nbttaglist.appendTag(this.getRandomEntity().func_98220_a());
        }

        p_98280_1_.setTag("SpawnPotentials", nbttaglist);
    }
}
 
Example 30
Project: RuneCraftery   File: TileEntityMobSpawnerRenderer.java   Source Code and License 5 votes vote down vote up
public static void func_98144_a(MobSpawnerBaseLogic p_98144_0_, double p_98144_1_, double p_98144_3_, double p_98144_5_, float p_98144_7_) {
   Entity var8 = p_98144_0_.func_98281_h();
   if(var8 != null) {
      var8.func_70029_a(p_98144_0_.func_98271_a());
      float var9 = 0.4375F;
      GL11.glTranslatef(0.0F, 0.4F, 0.0F);
      GL11.glRotatef((float)(p_98144_0_.field_98284_d + (p_98144_0_.field_98287_c - p_98144_0_.field_98284_d) * (double)p_98144_7_) * 10.0F, 0.0F, 1.0F, 0.0F);
      GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
      GL11.glTranslatef(0.0F, -0.4F, 0.0F);
      GL11.glScalef(var9, var9, var9);
      var8.func_70012_b(p_98144_1_, p_98144_3_, p_98144_5_, 0.0F, 0.0F);
      RenderManager.field_78727_a.func_78719_a(var8, 0.0D, 0.0D, 0.0D, 0.0F, p_98144_7_);
   }

}
 
Example 31
Project: Hats   File: HatHandler.java   Source Code and License 5 votes vote down vote up
public static boolean isMobSpawner(Class clz, Class callingClz)
{
    if(!TileEntity.class.isAssignableFrom(clz))
    {
        return false;
    }
    Boolean bool = mobSpawners.get(clz);
    if(bool == null)
    {
        try
        {
            Field[] fields = clz.getDeclaredFields();
            for(Field field : fields)
            {
                field.setAccessible(true);
                if(MobSpawnerBaseLogic.class.isAssignableFrom(field.getType()))
                {
                    bool = true;
                    mobSpawnerLogic.put(callingClz, field);
                    mobSpawners.put(callingClz, bool);
                    break;
                }
            }
            if(bool == null)
            {
                bool = clz.getSuperclass() == TileEntity.class ? false : isMobSpawner(clz.getSuperclass(), callingClz);
                mobSpawners.put(callingClz, bool);
            }
        }
        catch(Throwable e)
        {
            bool = false;
            mobSpawners.put(callingClz, bool);
        }
    }
    return bool;
}
 
Example 32
Project: PneumaticCraft   File: HackableMobSpawner.java   Source Code and License 5 votes vote down vote up
@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 33
Project: PneumaticCraft   File: BlockTrackEntryMobSpawner.java   Source Code and License 5 votes vote down vote up
@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 34
Project: EnderIO   File: BrokenSpawnerHandler.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public static void onBreakEvent(BlockEvent.BreakEvent evt) {
  if (evt.getState().getBlock() instanceof BlockMobSpawner) {
    if (evt.getPlayer() != null && !evt.getPlayer().capabilities.isCreativeMode && !evt.getPlayer().world.isRemote && !evt.isCanceled()) {
      TileEntity tile = evt.getPlayer().world.getTileEntity(NullHelper.notnullF(evt.getPos(), "BlockEvent.BreakEvent.getPos()"));
      if (tile instanceof TileEntityMobSpawner) {

        if (Math.random() > SpawnerConfig.brokenSpawnerDropChance.get()) {
          return;
        }

        ItemStack equipped = evt.getPlayer().getHeldItemMainhand();
        if (Prep.isValid(equipped) && SpawnerConfig.brokenSpawnerToolBlacklist.get().contains(equipped)) {
          return;
        }

        TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile;
        MobSpawnerBaseLogic logic = spawner.getSpawnerBaseLogic();
        ResourceLocation entityName = getEntityName(logic);
        if (entityName != null && !isBlackListed(entityName)) {
          final CapturedMob capturedMob = CapturedMob.create(entityName);
          if (capturedMob != null) {
            ItemStack drop = capturedMob.toStack(ModObject.itemBrokenSpawner.getItemNN(), 0, 1);
            dropCache.put(evt.getPos().toImmutable(), drop);

            for (int i = (int) (Math.random() * 7); i > 0; i--) {
              setSpawnDelay(logic);
              logic.updateSpawner();
            }
          } else {
            dropCache.put(evt.getPos().toImmutable(), Prep.getEmpty());
          }
        }
      }
    } else {
      dropCache.put(evt.getPos().toImmutable(), Prep.getEmpty());
    }
  }
}
 
Example 35
Project: EnderIO   File: BrokenSpawnerHandler.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public static void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent evt) {
  if (!evt.isCanceled() && evt.getState().getBlock() instanceof BlockMobSpawner) {
    if (dropCache.containsKey(evt.getPos())) {
      ItemStack stack = dropCache.get(evt.getPos());
      if (Prep.isValid(stack)) {
        evt.getDrops().add(stack);
        dropCache.put(evt.getPos().toImmutable(), Prep.getEmpty());
      }
    } else {
      // A spawner was broken---but not by a player. The TE has been
      // invalidated already, but we might be able to recover it.
      try {
        for (Object object : evt.getWorld().loadedTileEntityList) {
          if (object instanceof TileEntityMobSpawner) {
            TileEntityMobSpawner spawner = (TileEntityMobSpawner) object;
            BlockPos p = spawner.getPos();
            if (spawner.getWorld() == evt.getWorld() && p.equals(evt.getPos())) {
              // Bingo!
              MobSpawnerBaseLogic logic = spawner.getSpawnerBaseLogic();
              ResourceLocation entityName = getEntityName(logic);
              if (entityName != null && !isBlackListed(entityName)) {
                final CapturedMob capturedMob = CapturedMob.create(entityName);
                if (capturedMob != null) {
                  evt.getDrops().add(capturedMob.toStack(ModObject.itemBrokenSpawner.getItemNN(), 0, 1));
                }
              }
            }
          }
        }
      } catch (Exception e) {
        // Risky recovery failed. Happens.
      }
    }
  }
}
 
Example 36
Project: EnderIO   File: BrokenSpawnerHandler.java   Source Code and License 5 votes vote down vote up
private static ResourceLocation getEntityName(MobSpawnerBaseLogic logic) {
  if (getEntityIdMethod != null) {
    try {
      return (ResourceLocation) getEntityIdMethod.invoke(logic, new Object[0]);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  return null;
}
 
Example 37
Project: EnderIO   File: BrokenSpawnerHandler.java   Source Code and License 5 votes vote down vote up
private static void setSpawnDelay(MobSpawnerBaseLogic logic) {
  if (spawnDelayField != null) {
    try {
      spawnDelayField.set(logic, 0);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
 
Example 38
Project: DecompiledMinecraft   File: ItemMonsterPlacer.java   Source Code and License 4 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == Blocks.mob_spawner)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityMobSpawner)
            {
                MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
                mobspawnerbaselogic.setEntityName(EntityList.getStringFromID(stack.getMetadata()));
                tileentity.markDirty();
                worldIn.markBlockForUpdate(pos);

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --stack.stackSize;
                }

                return true;
            }
        }

        pos = pos.offset(side);
        double d0 = 0.0D;

        if (side == EnumFacing.UP && iblockstate instanceof BlockFence)
        {
            d0 = 0.5D;
        }

        Entity entity = spawnCreature(worldIn, stack.getMetadata(), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);

        if (entity != null)
        {
            if (entity instanceof EntityLivingBase && stack.hasDisplayName())
            {
                entity.setCustomNameTag(stack.getDisplayName());
            }

            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }
        }

        return true;
    }
}
 
Example 39
Project: DecompiledMinecraft   File: EntityMinecartMobSpawner.java   Source Code and License 4 votes vote down vote up
public MobSpawnerBaseLogic func_98039_d()
{
    return this.mobSpawnerLogic;
}
 
Example 40
Project: DecompiledMinecraft   File: ItemMonsterPlacer.java   Source Code and License 4 votes vote down vote up
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == Blocks.mob_spawner)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityMobSpawner)
            {
                MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
                mobspawnerbaselogic.setEntityName(EntityList.getStringFromID(stack.getMetadata()));
                tileentity.markDirty();
                worldIn.markBlockForUpdate(pos);

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --stack.stackSize;
                }

                return true;
            }
        }

        pos = pos.offset(side);
        double d0 = 0.0D;

        if (side == EnumFacing.UP && iblockstate instanceof BlockFence)
        {
            d0 = 0.5D;
        }

        Entity entity = spawnCreature(worldIn, stack.getMetadata(), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);

        if (entity != null)
        {
            if (entity instanceof EntityLivingBase && stack.hasDisplayName())
            {
                entity.setCustomNameTag(stack.getDisplayName());
            }

            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }
        }

        return true;
    }
}