use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.
the class ModelLeaves method getWorldKey.
@Override
protected Key getWorldKey(IBlockState state) {
IExtendedBlockState stateExtended = (IExtendedBlockState) state;
IBlockAccess world = stateExtended.getValue(UnlistedBlockAccess.BLOCKACCESS);
BlockPos pos = stateExtended.getValue(UnlistedBlockPos.POS);
boolean fancy = Proxies.render.fancyGraphicsEnabled();
TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
if (world == null || pos == null) {
return createEmptyKey(map, fancy);
}
TileLeaves tile = TileUtil.getTile(world, pos, TileLeaves.class);
if (tile == null) {
return createEmptyKey(map, fancy);
}
ResourceLocation leafLocation = tile.getLeaveSprite(fancy);
ResourceLocation fruitLocation = tile.getFruitSprite();
return new Key(map.getAtlasSprite(leafLocation.toString()), fruitLocation != null ? map.getAtlasSprite(fruitLocation.toString()) : null, fancy);
}
use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.
the class ModelLeaves method getInventoryKey.
@Override
protected Key getInventoryKey(ItemStack itemStack) {
TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
TileLeaves leaves = new TileLeaves();
if (itemStack.getTagCompound() != null) {
leaves.readFromNBT(itemStack.getTagCompound());
} else {
leaves.setTree(TreeRoot.treeTemplates.get(0));
}
boolean fancy = Proxies.render.fancyGraphicsEnabled();
ResourceLocation leafLocation = leaves.getLeaveSprite(fancy);
ResourceLocation fruitLocation = leaves.getFruitSprite();
return new Key(map.getAtlasSprite(leafLocation.toString()), fruitLocation != null ? map.getAtlasSprite(fruitLocation.toString()) : null, fancy);
}
use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.
the class ItemBlockLeaves method getColorFromItemstack.
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack itemStack, int renderPass) {
if (itemStack.getTagCompound() == null) {
return ModuleArboriculture.proxy.getFoliageColorBasic();
}
TileLeaves tileLeaves = new TileLeaves();
tileLeaves.readFromNBT(itemStack.getTagCompound());
if (renderPass == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
return tileLeaves.getFruitColour();
} else {
EntityPlayer player = Minecraft.getMinecraft().player;
return tileLeaves.getFoliageColour(player);
}
}
use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.
the class ItemBlockLeaves method getItemStackDisplayName.
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
if (itemstack.getTagCompound() == null) {
return Translator.translateToLocal("trees.grammar.leaves.type");
}
TileLeaves tileLeaves = new TileLeaves();
tileLeaves.readFromNBT(itemstack.getTagCompound());
String unlocalizedName = tileLeaves.getUnlocalizedName();
return getDisplayName(unlocalizedName);
}
use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.
the class BlockForestryLeaves method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
TileLeaves leaves = TileUtil.getTile(worldIn, pos, TileLeaves.class);
if (leaves != null) {
IButterfly caterpillar = leaves.getCaterpillar();
ItemStack heldItem = playerIn.getHeldItem(hand);
if (heldItem.getItem() instanceof IToolScoop && caterpillar != null) {
ItemStack butterfly = ButterflyManager.butterflyRoot.getMemberStack(caterpillar, EnumFlutterType.CATERPILLAR);
ItemStackUtil.dropItemStackAsEntity(butterfly, worldIn, pos);
leaves.setCaterpillar(null);
return true;
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
Aggregations