net.minecraft.tileentity.TileEntitySkull Java Examples

The following examples show how to use net.minecraft.tileentity.TileEntitySkull. 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 check out the related API usage on the sidebar.
Example #1
Source File: ClientProxy.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
private void registerBlockRenderers() {
	if (EtFuturum.enableSlimeBlock)
		RenderingRegistry.registerBlockHandler(new BlockSlimeBlockRender());

	if (EtFuturum.enableDoors)
		RenderingRegistry.registerBlockHandler(new BlockDoorRenderer());

	if (EtFuturum.enableBanners)
		ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBanner.class, new TileEntityBannerRenderer());

	if (EtFuturum.enableFancySkulls)
		ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkull.class, new TileEntityFancySkullRenderer());

	if (EtFuturum.enableChorusFruit) {
		RenderingRegistry.registerBlockHandler(new BlockEndRodRender());
		RenderingRegistry.registerBlockHandler(new BlockChorusFlowerRender());
		RenderingRegistry.registerBlockHandler(new BlockChorusPlantRender());
		ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEndRod.class, new TileEntityEndRodRenderer());
	}

	if (EtFuturum.enableColourfulBeacons)
		ClientRegistry.bindTileEntitySpecialRenderer(TileEntityNewBeacon.class, new TileEntityNewBeaconRenderer());

	RenderingRegistry.registerBlockHandler(new BlockChestRenderer());
}
 
Example #2
Source File: AdapterSkull.java    From OpenPeripheral-Integration with MIT License 6 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.STRING)
public String getType(TileEntitySkull skull) {
	int skullType = skull.func_145904_a();

	switch (skullType) {
		case 0:
			return "skeleton";
		case 1:
			return "wither_skeleton";
		case 2:
			return "zombie";
		case 3:
			return "player";
		case 4:
			return "creeper";
	}

	return "unknown";
}
 
Example #3
Source File: CraftBlock.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.block.Block block = this.getNMSBlock();
    if (block != Blocks.AIR) {
        IBlockState data = getData0();
        // based on nms.Block.dropNaturally
        int count = block.quantityDroppedWithBonus(0, chunk.getHandle().getWorld().rand);
        for (int i = 0; i < count; ++i) {
            Item item = block.getItemDropped(data, chunk.getHandle().getWorld().rand, 0);
            if (item != Items.AIR) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.SKULL == block) {
                    net.minecraft.item.ItemStack nmsStack = new net.minecraft.item.ItemStack(item, 1, block.damageDropped(data));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().getWorld().getTileEntity(new BlockPos(x, y, z));

                    if (tileentityskull.getSkullType() == 3 && tileentityskull.getPlayerProfile() != null) {
                        nmsStack.setTagCompound(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        NBTUtil.writeGameProfile(nbttagcompound, tileentityskull.getPlayerProfile());
                        nmsStack.getTagCompound().setTag("SkullOwner", nbttagcompound);
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                    // We don't want to drop cocoa blocks, we want to drop cocoa beans.
                } else if (Blocks.COCOA == block) {
                    int age = (Integer) data.getValue(BlockCocoa.AGE);
                    int dropAmount = (age >= 2 ? 3 : 1);
                    for (int j = 0; j < dropAmount; ++j) {
                        drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
                    }
                } else {
                    drops.add(new ItemStack(CraftMagicNumbers.getMaterial(item), 1, (short) block.damageDropped(data)));
                }
            }
        }
    }
    return drops;
}
 
Example #4
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void load(TileEntitySkull skull) {
    super.load(skull);

    profile = skull.getPlayerProfile();
    skullType = getSkullType(skull.getSkullType());
    rotation = (byte) skull.skullRotation;
}
 
Example #5
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void applyTo(TileEntitySkull skull) {
    super.applyTo(skull);

    if (skullType == SkullType.PLAYER) {
        skull.setPlayerProfile(profile);
    } else {
        skull.setType(getSkullType(skullType));
    }

    skull.setSkullRotation(rotation);
}
 
Example #6
Source File: CraftMetaSkull.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
void applyToItem(NBTTagCompound tag) {
    super.applyToItem(tag);

    if (profile != null) {
        // Fill in textures
        profile = TileEntitySkull.updateGameprofile(profile);

        NBTTagCompound owner = new NBTTagCompound();
        NBTUtil.writeGameProfile(owner, profile);
        tag.setTag(SKULL_OWNER.NBT, owner);
    }
}
 
Example #7
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.block.Block block = this.getNMSBlock();
    if (block != Blocks.air) {
        byte data = getData();
        // based on nms.Block.dropNaturally
        int count = block.quantityDroppedWithBonus(0, chunk.getHandle().worldObj.rand);
        for (int i = 0; i < count; ++i) {
            Item item = block.getItemDropped(data, chunk.getHandle().worldObj.rand, 0);
            if (item != null) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.skull == block) {
                    net.minecraft.item.ItemStack nmsStack = new net.minecraft.item.ItemStack(item, 1, block.getDamageValue(chunk.getHandle().worldObj, x, y, z));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().worldObj.getTileEntity(x, y, z);

                    if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_152108_a() != null) {
                        nmsStack.setTagCompound(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        NBTUtil.func_152460_a(nbttagcompound, tileentityskull.func_152108_a());
                        nmsStack.getTagCompound().setTag("SkullOwner", nbttagcompound);
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                    // We don't want to drop cocoa blocks, we want to drop cocoa beans.
                } else if (Blocks.cocoa == block) {
                    int dropAmount = (BlockCocoa.func_149987_c(data) >= 2 ? 3 : 1);
                    for (int j = 0; j < dropAmount; ++j) {
                        drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
                    }
                } else {
                    drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.damageDropped(data)));
                }
            }
        }
    }
    return drops;
}
 
Example #8
Source File: CraftSkull.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public CraftSkull(final Block block) {
    super(block);

    CraftWorld world = (CraftWorld) block.getWorld();
    skull = (TileEntitySkull) world.getTileEntityAt(getX(), getY(), getZ());
    profile = skull.func_152108_a();
    skullType = getSkullType(skull.func_145904_a());
    rotation = (byte) skull.getRotation();
}
 
Example #9
Source File: AdapterSkull.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@MultipleReturn
@ScriptCallable(returnTypes = { ReturnType.STRING, ReturnType.STRING })
public Object[] getPlayer(TileEntitySkull skull) {
	if (skull.func_145904_a() != 3) return new Object[] { null, null };

	GameProfile profile = skull.func_152108_a();
	if (profile == null) return new Object[] { null, null };

	return new Object[] { profile.getId(), profile.getName() };
}
 
Example #10
Source File: MixinTileEntityItemStackRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void renderByItem(ItemStack itemStackIn) {
    if(itemStackIn.getItem() == Items.banner) {
        this.banner.setItemValues(itemStackIn);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }else if(itemStackIn.getItem() == Items.skull) {
        GameProfile gameprofile = null;

        if(itemStackIn.hasTagCompound()) {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            try {
                if(nbttagcompound.hasKey("SkullOwner", 10)) {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }else if(nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0) {
                    GameProfile lvt_2_2_ = new GameProfile(null, nbttagcompound.getString("SkullOwner"));
                    gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                    nbttagcompound.removeTag("SkullOwner");
                    nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                }
            }catch(Exception ignored) {
            }
        }

        if(TileEntitySkullRenderer.instance != null) {
            GlStateManager.pushMatrix();
            GlStateManager.translate(-0.5F, 0.0F, -0.5F);
            GlStateManager.scale(2.0F, 2.0F, 2.0F);
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }else{
        Block block = Block.getBlockFromItem(itemStackIn.getItem());

        if(block == Blocks.ender_chest) {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
        }else if(block == Blocks.trapped_chest) {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F);
        }else if(block != Blocks.chest)
            net.minecraftforge.client.ForgeHooksClient.renderTileItem(itemStackIn.getItem(), itemStackIn.getMetadata());
        else{
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}
 
Example #11
Source File: MixinTileEntityItemStackRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void renderByItem(ItemStack itemStackIn) {
    if(itemStackIn.getItem() == Items.banner) {
        this.banner.setItemValues(itemStackIn);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }else if(itemStackIn.getItem() == Items.skull) {
        GameProfile gameprofile = null;

        if(itemStackIn.hasTagCompound()) {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            try {
                if(nbttagcompound.hasKey("SkullOwner", 10)) {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }else if(nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0) {
                    GameProfile lvt_2_2_ = new GameProfile(null, nbttagcompound.getString("SkullOwner"));
                    gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                    nbttagcompound.removeTag("SkullOwner");
                    nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                }
            }catch(Exception ignored) {
            }
        }

        if(TileEntitySkullRenderer.instance != null) {
            GlStateManager.pushMatrix();
            GlStateManager.translate(-0.5F, 0.0F, -0.5F);
            GlStateManager.scale(2.0F, 2.0F, 2.0F);
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }else{
        Block block = Block.getBlockFromItem(itemStackIn.getItem());

        if(block == Blocks.ender_chest) {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
        }else if(block == Blocks.trapped_chest) {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F);
        }else{
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}
 
Example #12
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftSkull(final Block block) {
    super(block, TileEntitySkull.class);
}
 
Example #13
Source File: CraftSkull.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftSkull(final Material material, final TileEntitySkull te) {
    super(material, te);
}
 
Example #14
Source File: TileEntityFancySkullRenderer.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTick) {
	TileEntitySkull skull = (TileEntitySkull) tile;
	renderSkull((float) x, (float) y, (float) z, tile.getBlockMetadata() & 7, skull.func_145906_b() * 360 / 16.0F, skull.func_145904_a(), skull.func_152108_a());
}
 
Example #15
Source File: AdapterSkull.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@Override
public Class<?> getTargetClass() {
	return TileEntitySkull.class;
}