Java Code Examples for net.minecraft.tileentity.TileEntityMobSpawner

The following are top voted examples for showing how to use net.minecraft.tileentity.TileEntityMobSpawner. 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: NetHandlerPlayClient.java   Source Code and License 6 votes vote down vote up
/**
 * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
 * beacons, skulls, flowerpot
 */
public void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos()))
    {
        TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
        int i = packetIn.getTileEntityType();

        if (i == 1 && tileentity instanceof TileEntityMobSpawner || i == 2 && tileentity instanceof TileEntityCommandBlock || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner)
        {
            tileentity.readFromNBT(packetIn.getNbtCompound());
        }
    }
}
 
Example 4
Project: DecompiledMinecraft   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());

    for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values())
    {
        tileentityspecialrenderer.setRendererDispatcher(this);
    }
}
 
Example 5
Project: BaseClient   File: NetHandlerPlayClient.java   Source Code and License 6 votes vote down vote up
/**
 * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
 * beacons, skulls, flowerpot
 */
public void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos()))
    {
        TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
        int i = packetIn.getTileEntityType();

        if (i == 1 && tileentity instanceof TileEntityMobSpawner || i == 2 && tileentity instanceof TileEntityCommandBlock || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner)
        {
            tileentity.readFromNBT(packetIn.getNbtCompound());
        }
    }
}
 
Example 6
Project: BaseClient   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());

    for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values())
    {
        tileentityspecialrenderer.setRendererDispatcher(this);
    }
}
 
Example 7
Project: BaseClient   File: NetHandlerPlayClient.java   Source Code and License 6 votes vote down vote up
/**
 * Updates the NBTTagCompound metadata of instances of the following
 * entitytypes: Mob spawners, command blocks, beacons, skulls, flowerpot
 */
public void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

	if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) {
		TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
		int i = packetIn.getTileEntityType();

		if (i == 1 && tileentity instanceof TileEntityMobSpawner
				|| i == 2 && tileentity instanceof TileEntityCommandBlock
				|| i == 3 && tileentity instanceof TileEntityBeacon
				|| i == 4 && tileentity instanceof TileEntitySkull
				|| i == 5 && tileentity instanceof TileEntityFlowerPot
				|| i == 6 && tileentity instanceof TileEntityBanner) {
			tileentity.readFromNBT(packetIn.getNbtCompound());
		}
	}
}
 
Example 8
Project: BaseClient   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());

    for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values())
    {
        tileentityspecialrenderer.setRendererDispatcher(this);
    }
}
 
Example 9
Project: Zombe-Modpack   File: NetHandlerPlayClient.java   Source Code and License 6 votes vote down vote up
/**
 * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
 * beacons, skulls, flowerpot
 */
public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (this.gameController.world.isBlockLoaded(packetIn.getPos()))
    {
        TileEntity tileentity = this.gameController.world.getTileEntity(packetIn.getPos());
        int i = packetIn.getTileEntityType();
        boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock;

        if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign || i == 10 && tileentity instanceof TileEntityShulkerBox)
        {
            tileentity.readFromNBT(packetIn.getNbtCompound());
        }

        if (flag && this.gameController.currentScreen instanceof GuiCommandBlock)
        {
            ((GuiCommandBlock)this.gameController.currentScreen).updateGui();
        }
    }
}
 
Example 10
Project: Backmemed   File: NetHandlerPlayClient.java   Source Code and License 6 votes vote down vote up
/**
 * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
 * beacons, skulls, flowerpot
 */
public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (this.gameController.world.isBlockLoaded(packetIn.getPos()))
    {
        TileEntity tileentity = this.gameController.world.getTileEntity(packetIn.getPos());
        int i = packetIn.getTileEntityType();
        boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock;

        if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign || i == 10 && tileentity instanceof TileEntityShulkerBox)
        {
            tileentity.readFromNBT(packetIn.getNbtCompound());
        }

        if (flag && this.gameController.currentScreen instanceof GuiCommandBlock)
        {
            ((GuiCommandBlock)this.gameController.currentScreen).updateGui();
        }
    }
}
 
Example 11
Project: Backmemed   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer());
    this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());
    this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer());
    this.mapSpecialRenderers.put(TileEntityShulkerBox.class, new TileEntityShulkerBoxRenderer(new ModelShulker()));

    for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values())
    {
        tileentityspecialrenderer.setRendererDispatcher(this);
    }
}
 
Example 12
Project: CustomWorldGen   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer());
    this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());
    this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer());

    for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values())
    {
        tileentityspecialrenderer.setRendererDispatcher(this);
    }
}
 
Example 13
Project: 4Space-5   File: StructureComponentGC.java   Source Code and License 6 votes vote down vote up
protected void placeSpawnerAtCurrentPosition(World var1, Random var2, int var3, int var4, int var5, String var6, StructureBoundingBox var7)
{
    final int var8 = this.getXWithOffset(var3, var5);
    final int var9 = this.getYWithOffset(var4);
    final int var10 = this.getZWithOffset(var3, var5);

    if (var7.isVecInside(var8, var9, var10) && var1.getBlock(var8, var9, var10) != Blocks.mob_spawner)
    {
        var1.setBlock(var8, var9, var10, Blocks.mob_spawner, 0, 3);
        final TileEntityMobSpawner var11 = (TileEntityMobSpawner) var1.getTileEntity(var8, var9, var10);

        if (var11 != null)
        {
            var11.func_145881_a().setEntityName(var6);
        }
    }
}
 
Example 14
Project: BlockSystems   File: UpdateBlockEntityMessage.java   Source Code and License 6 votes vote down vote up
@Override
public void onReceiveClient(Minecraft client, WorldClient world, EntityPlayerSP player, MessageContext context) {
    BlockSystem blockSystem = BlockSystems.PROXY.getBlockSystemHandler(world).getBlockSystem(this.blockSystem);
    if (blockSystem != null) {
        if (blockSystem.isBlockLoaded(this.pos)) {
            TileEntity blockEntity = blockSystem.getTileEntity(this.pos);
            boolean commandBlock = this.type == 2 && blockEntity instanceof TileEntityCommandBlock;
            if (this.type == 1 && blockEntity instanceof TileEntityMobSpawner || commandBlock || this.type == 3 && blockEntity instanceof TileEntityBeacon || this.type == 4 && blockEntity instanceof TileEntitySkull || this.type == 5 && blockEntity instanceof TileEntityFlowerPot || this.type == 6 && blockEntity instanceof TileEntityBanner || this.type == 7 && blockEntity instanceof TileEntityStructure || this.type == 8 && blockEntity instanceof TileEntityEndGateway || this.type == 9 && blockEntity instanceof TileEntitySign) {
                blockEntity.readFromNBT(this.data);
            } else {
                blockEntity.onDataPacket(client.getConnection().getNetworkManager(), new SPacketUpdateTileEntity(this.pos, this.type, this.data));
            }
            if (commandBlock && client.currentScreen instanceof GuiCommandBlock) {
                ((GuiCommandBlock) client.currentScreen).updateGui();
            }
        }
    }
}
 
Example 15
Project: NotEnoughItems   File: ItemMobSpawner.java   Source Code and License 6 votes vote down vote up
/**
 * Called from BlockMobSpawner on the client via asm generated onBlockPlacedBy
 */
public static void onBlockPlaced(World world, BlockPos pos, ItemStack stack) {
    if (!NEIClientConfig.hasSMPCounterPart()) {
        return;
    }

    TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) world.getTileEntity(pos);
    if (tileentitymobspawner != null) {
        setDefaultTag(stack);
        String mobtype = IDtoNameMap.get(stack.getItemDamage());
        if (mobtype != null) {
            NEIClientPacketHandler.sendMobSpawnerID(pos.getX(), pos.getY(), pos.getZ(), mobtype);
            tileentitymobspawner.getSpawnerBaseLogic().setEntityId(new ResourceLocation(mobtype));
        }
    }
}
 
Example 16
Project: MobSpawnerFinder   File: MobSpawnerFinder.java   Source Code and License 6 votes vote down vote up
/**
 * search in all loaded TileEntities for MobSpawners,
 * when a new MobSpawner gets found, display its type and coordinates in chat.
 * @param showKnown show already found spawners
 */
public static void findSpawners(boolean showKnown) {
    final Minecraft mc = Minecraft.getMinecraft();
    if (mc == null || mc.theWorld == null || mc.theWorld.loadedTileEntityList == null)
        return;
    for (Object o : mc.theWorld.loadedTileEntityList) {
        if (o.getClass() == TileEntityMobSpawner.class) {
            final TileEntityMobSpawner spawnerTileEntity = (TileEntityMobSpawner) o;
            final BlockPos spawnerPos = spawnerTileEntity.getPos();
            if (showKnown || !foundSpawners.contains(spawnerPos)) {
                if (!showKnown) foundSpawners.add(spawnerPos);

                // tell player about newly found spawner
                NBTTagCompound nbt = new NBTTagCompound();
                spawnerTileEntity.writeToNBT(nbt);
                final String entityId = nbt.getString("EntityId");
                mc.thePlayer.addChatMessage(getSpawnerFoundChatMessage(spawnerPos, entityId));
            }
        }
    }
}
 
Example 17
Project: Resilience-Client-Source   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityRendererPiston());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new RenderEndPortal());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    Iterator var1 = this.mapSpecialRenderers.values().iterator();

    while (var1.hasNext())
    {
        TileEntitySpecialRenderer var2 = (TileEntitySpecialRenderer)var1.next();
        var2.func_147497_a(this);
    }
}
 
Example 18
Project: CustomAI   File: AICopierItem.java   Source Code and License 6 votes vote down vote up
private void copyToSpawner(NBTTagCompound nbt, ItemStack stack, TileEntityMobSpawner mobSpawner, EntityPlayer player)
    {
        if(mobSpawner.func_145881_a().getRandomEntity() == null)
        {
            mobSpawner.func_145881_a().setRandomEntity(mobSpawner.func_145881_a().new WeightedRandomMinecart((NBTTagCompound) nbt.copy(), mobSpawner.func_145881_a().getEntityNameToSpawn()));
        }
        else
        {
            NBTTagCompound old = mobSpawner.func_145881_a().getRandomEntity().field_98222_b;
            if(nbt.hasKey("CustomAITasks"))
                old.setTag("CustomAITasks", nbt.getTag("CustomAITasks"));
            if(nbt.hasKey("CustomAITargetTasks"))
                old.setTag("CustomAITargetTasks", nbt.getTag("CustomAITargetTasks"));
        }
        player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC+"Successfully transfered AI data to the spawner"));
//        ModCustomAI.packetPipeline.sendToAll(new PacketUpdateMobSpawnerData(mobSpawner, fromNBTListToList((NBTTagList)nbt.getTag("CustomAITasks")), fromNBTListToList((NBTTagList)nbt.getTag("CustomAITargetTasks"))));
        mobSpawner.getWorldObj().markBlockForUpdate(mobSpawner.xCoord, mobSpawner.yCoord, mobSpawner.zCoord);
    }
 
Example 19
Project: ExpandedRailsMod   File: NetHandlerPlayClient.java   Source Code and License 6 votes vote down vote up
/**
 * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
 * beacons, skulls, flowerpot
 */
public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos()))
    {
        TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
        int i = packetIn.getTileEntityType();
        boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock;

        if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign)
        {
            tileentity.readFromNBT(packetIn.getNbtCompound());
        }
        else
        {
            tileentity.onDataPacket(netManager, packetIn);
        }

        if (flag && this.gameController.currentScreen instanceof GuiCommandBlock)
        {
            ((GuiCommandBlock)this.gameController.currentScreen).updateGui();
        }
    }
}
 
Example 20
Project: ExpandedRailsMod   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new TileEntityEnchantmentTableRenderer());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new TileEntityEndPortalRenderer());
    this.mapSpecialRenderers.put(TileEntityEndGateway.class, new TileEntityEndGatewayRenderer());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());
    this.mapSpecialRenderers.put(TileEntityStructure.class, new TileEntityStructureRenderer());

    for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values())
    {
        tileentityspecialrenderer.setRendererDispatcher(this);
    }
}
 
Example 21
Project: Cauldron   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityRendererPiston());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new RenderEndPortal());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    Iterator iterator = this.mapSpecialRenderers.values().iterator();

    while (iterator.hasNext())
    {
        TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next();
        tileentityspecialrenderer.func_147497_a(this);
    }
}
 
Example 22
Project: Cauldron   File: TileEntityRendererDispatcher.java   Source Code and License 6 votes vote down vote up
private TileEntityRendererDispatcher()
{
    this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityRendererPiston());
    this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable());
    this.mapSpecialRenderers.put(TileEntityEndPortal.class, new RenderEndPortal());
    this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    Iterator iterator = this.mapSpecialRenderers.values().iterator();

    while (iterator.hasNext())
    {
        TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next();
        tileentityspecialrenderer.func_147497_a(this);
    }
}
 
Example 23
Project: RuneCraftery   File: NetClientHandler.java   Source Code and License 6 votes vote down vote up
public void func_72468_a(Packet132TileEntityData p_72468_1_) {
   if(this.field_72563_h.field_71441_e.func_72899_e(p_72468_1_.field_73334_a, p_72468_1_.field_73332_b, p_72468_1_.field_73333_c)) {
      TileEntity var2 = this.field_72563_h.field_71441_e.func_72796_p(p_72468_1_.field_73334_a, p_72468_1_.field_73332_b, p_72468_1_.field_73333_c);
      if(var2 != null) {
         if(p_72468_1_.field_73330_d == 1 && var2 instanceof TileEntityMobSpawner) {
            var2.func_70307_a(p_72468_1_.field_73331_e);
         } else if(p_72468_1_.field_73330_d == 2 && var2 instanceof TileEntityCommandBlock) {
            var2.func_70307_a(p_72468_1_.field_73331_e);
         } else if(p_72468_1_.field_73330_d == 3 && var2 instanceof TileEntityBeacon) {
            var2.func_70307_a(p_72468_1_.field_73331_e);
         } else if(p_72468_1_.field_73330_d == 4 && var2 instanceof TileEntitySkull) {
            var2.func_70307_a(p_72468_1_.field_73331_e);
         }
      }
   }

}
 
Example 24
Project: RuneCraftery   File: TileEntityRenderer.java   Source Code and License 6 votes vote down vote up
private TileEntityRenderer()
{
    this.specialRendererMap.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.specialRendererMap.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.specialRendererMap.put(TileEntityPiston.class, new TileEntityRendererPiston());
    this.specialRendererMap.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.specialRendererMap.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.specialRendererMap.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable());
    this.specialRendererMap.put(TileEntityEndPortal.class, new RenderEndPortal());
    this.specialRendererMap.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.specialRendererMap.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    Iterator iterator = this.specialRendererMap.values().iterator();

    while (iterator.hasNext())
    {
        TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next();
        tileentityspecialrenderer.setTileEntityRenderer(this);
    }
}
 
Example 25
Project: Generatormods   File: Building.java   Source Code and License 6 votes vote down vote up
protected void setMobSpawner(int[] pt, Block spawner, int metadata, String info) {
	if(world.setBlock(pt[0], pt[1], pt[2], spawner, metadata, 2)){
           TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) world.getTileEntity(pt[0], pt[1], pt[2]);
           if (tileentitymobspawner != null){
               if(info.equals("UPRIGHT")) {
                   if (random.nextInt(3) == 0)
                       setMobSpawner(tileentitymobspawner, 1, 3);
                   else
                       setMobSpawner(tileentitymobspawner, 2, 0);
               }else if(info.equals("EASY")){
                   setMobSpawner(tileentitymobspawner, 2, 0);
               }else if(info.equals("MEDIUM")){
                   setMobSpawner(tileentitymobspawner, 3, 0);
               }else if(info.equals("HARD")){
                   setMobSpawner(tileentitymobspawner, 4, 0);
               }else if(EntityList.stringToClassMapping.containsKey(info))
                   tileentitymobspawner.func_145881_a().setEntityName(info);
           }
       }
}
 
Example 26
Project: BetterNutritionMod   File: TileEntityRenderer.java   Source Code and License 6 votes vote down vote up
private TileEntityRenderer()
{
    this.specialRendererMap.put(TileEntitySign.class, new TileEntitySignRenderer());
    this.specialRendererMap.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
    this.specialRendererMap.put(TileEntityPiston.class, new TileEntityRendererPiston());
    this.specialRendererMap.put(TileEntityChest.class, new TileEntityChestRenderer());
    this.specialRendererMap.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer());
    this.specialRendererMap.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable());
    this.specialRendererMap.put(TileEntityEndPortal.class, new RenderEndPortal());
    this.specialRendererMap.put(TileEntityBeacon.class, new TileEntityBeaconRenderer());
    this.specialRendererMap.put(TileEntitySkull.class, new TileEntitySkullRenderer());
    Iterator iterator = this.specialRendererMap.values().iterator();

    while (iterator.hasNext())
    {
        TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next();
        tileentityspecialrenderer.setTileEntityRenderer(this);
    }
}
 
Example 27
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 28
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 29
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 30
Project: ForgeHax   File: SpawnerEspMod.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public void onRender(RenderEvent event) {
    event.getBuffer().begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);

    for(TileEntity tileEntity : getWorld().loadedTileEntityList) {
        if(tileEntity instanceof TileEntityMobSpawner) {
            BlockPos pos = tileEntity.getPos();
            GeometryTessellator.drawCuboid(event.getBuffer(), pos, GeometryMasks.Line.ALL, Utils.Colors.RED);
        }
    }

    event.getTessellator().draw();
}
 
Example 31
Project: DecompiledMinecraft   File: TileEntityMobSpawnerRenderer.java   Source Code and License 5 votes vote down vote up
public void renderTileEntityAt(TileEntityMobSpawner te, double x, double y, double z, float partialTicks, int destroyStage)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x + 0.5F, (float)y, (float)z + 0.5F);
    renderMob(te.getSpawnerBaseLogic(), x, y, z, partialTicks);
    GlStateManager.popMatrix();
}
 
Example 32
Project: BaseClient   File: TileEntityMobSpawnerRenderer.java   Source Code and License 5 votes vote down vote up
public void renderTileEntityAt(TileEntityMobSpawner te, double x, double y, double z, float partialTicks, int destroyStage)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x + 0.5F, (float)y, (float)z + 0.5F);
    renderMob(te.getSpawnerBaseLogic(), x, y, z, partialTicks);
    GlStateManager.popMatrix();
}
 
Example 33
Project: BaseClient   File: TileEntityMobSpawnerRenderer.java   Source Code and License 5 votes vote down vote up
public void renderTileEntityAt(TileEntityMobSpawner te, double x, double y, double z, float partialTicks, int destroyStage)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x + 0.5F, (float)y, (float)z + 0.5F);
    renderMob(te.getSpawnerBaseLogic(), x, y, z, partialTicks);
    GlStateManager.popMatrix();
}
 
Example 34
Project: Backmemed   File: TileEntityMobSpawnerRenderer.java   Source Code and License 5 votes vote down vote up
public void renderTileEntityAt(TileEntityMobSpawner te, double x, double y, double z, float partialTicks, int destroyStage)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x + 0.5F, (float)y, (float)z + 0.5F);
    renderMob(te.getSpawnerBaseLogic(), x, y, z, partialTicks);
    GlStateManager.popMatrix();
}
 
Example 35
Project: CustomWorldGen   File: NetHandlerPlayClient.java   Source Code and License 5 votes vote down vote up
/**
 * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
 * beacons, skulls, flowerpot
 */
public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos()))
    {
        TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos());
        int i = packetIn.getTileEntityType();
        boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock;

        if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign)
        {
            tileentity.readFromNBT(packetIn.getNbtCompound());
        }
        else
        {
            if(tileentity == null)
            {
                LOGGER.error("Received invalid update packet for null tile entity at {} with data: {}", packetIn.getPos(), packetIn.getNbtCompound());
                return;
            }
            tileentity.onDataPacket(netManager, packetIn);
        }

        if (flag && this.gameController.currentScreen instanceof GuiCommandBlock)
        {
            ((GuiCommandBlock)this.gameController.currentScreen).updateGui();
        }
    }
}
 
Example 36
Project: CustomWorldGen   File: TileEntityMobSpawnerRenderer.java   Source Code and License 5 votes vote down vote up
public void renderTileEntityAt(TileEntityMobSpawner te, double x, double y, double z, float partialTicks, int destroyStage)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x + 0.5F, (float)y, (float)z + 0.5F);
    renderMob(te.getSpawnerBaseLogic(), x, y, z, partialTicks);
    GlStateManager.popMatrix();
}
 
Example 37
Project: ExtraUtilities   File: WorldGenCastle.java   Source Code and License 5 votes vote down vote up
public static void setMobSpawner(final World world, final int x, final int y, final int z, final Random rand) {
    world.setBlock(x, y, z, Blocks.mob_spawner, 0, 2);
    final TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getTileEntity(x, y, z);
    if (tileentitymobspawner != null) {
        tileentitymobspawner.func_145881_a().setEntityName(DungeonHooks.getRandomDungeonMob(rand));
    }
    else {
        LogHelper.error("Failed to fetch mob spawner entity at (" + x + ", " + y + ", " + z + ")", new Object[0]);
    }
}
 
Example 38
Project: 4Space-5   File: RoomSpawnerMars.java   Source Code and License 5 votes vote down vote up
@Override
protected void handleTileEntities(Random rand)
{
    for (final ChunkCoordinates spawnerCoords : this.spawners)
    {
        if (this.worldObj.getBlock(spawnerCoords.posX, spawnerCoords.posY, spawnerCoords.posZ) == Blocks.mob_spawner)
        {
            final TileEntityMobSpawner spawner = (TileEntityMobSpawner) this.worldObj.getTileEntity(spawnerCoords.posX, spawnerCoords.posY, spawnerCoords.posZ);
            if (spawner != null)
            {
                spawner.func_145881_a().setEntityName(RoomSpawnerMars.getMob(rand));
            }
        }
    }
}
 
Example 39
Project: 4Space-5   File: RoomSpawnerMoon.java   Source Code and License 5 votes vote down vote up
@Override
protected void handleTileEntities(Random rand)
{
    for (final ChunkCoordinates spawnerCoords : this.spawners)
    {
        if (this.worldObj.getBlock(spawnerCoords.posX, spawnerCoords.posY, spawnerCoords.posZ) == Blocks.mob_spawner)
        {
            final TileEntityMobSpawner spawner = (TileEntityMobSpawner) this.worldObj.getTileEntity(spawnerCoords.posX, spawnerCoords.posY, spawnerCoords.posZ);
            if (spawner != null)
            {
                spawner.func_145881_a().setEntityName(RoomSpawnerMoon.getMob(rand));
            }
        }
    }
}
 
Example 40
Project: 4Space-5   File: NEISPH.java   Source Code and License 5 votes vote down vote up
private void handleMobSpawnerID(World world, BlockCoord coord, String mobtype) {
    TileEntity tile = world.getTileEntity(coord.x, coord.y, coord.z);
    if (tile instanceof TileEntityMobSpawner) {
        ((TileEntityMobSpawner) tile).func_145881_a().setEntityName(mobtype);
        tile.markDirty();
        world.markBlockForUpdate(coord.x, coord.y, coord.z);
    }
}