mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-17 10:55:06 +00:00
80 lines
2.8 KiB
Java
Executable File
80 lines
2.8 KiB
Java
Executable File
/*******************************************************************************
|
|
* Copyright (c) 2011-2014 SirSengir.
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the GNU Lesser Public License v3
|
|
* which accompanies this distribution, and is available at
|
|
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
*
|
|
* Various Contributors including, but not limited to:
|
|
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
|
******************************************************************************/
|
|
package forestry.apiculture.blocks;
|
|
|
|
import java.util.Random;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockTorch;
|
|
import net.minecraft.block.SoundType;
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.EnumFacing;
|
|
import net.minecraft.util.EnumHand;
|
|
import net.minecraft.util.NonNullList;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
import forestry.api.core.IItemModelRegister;
|
|
import forestry.api.core.IModelManager;
|
|
import forestry.api.core.Tabs;
|
|
import forestry.apiculture.PluginApiculture;
|
|
import forestry.apiculture.tiles.TileCandle;
|
|
import forestry.core.config.Constants;
|
|
|
|
public class BlockStump extends BlockTorch implements IItemModelRegister {
|
|
|
|
public BlockStump() {
|
|
this.setHardness(0.0F);
|
|
this.setSoundType(SoundType.WOOD);
|
|
setCreativeTab(Tabs.tabApiculture);
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
@Override
|
|
public void registerModel(Item item, IModelManager manager) {
|
|
manager.registerItemModel(item, 0, "stump");
|
|
}
|
|
|
|
@Override
|
|
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
|
list.add(new ItemStack(this, 1, 0));
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
|
ItemStack heldItem = playerIn.getHeldItem(hand);
|
|
if (BlockCandle.lightingItems.contains(heldItem.getItem())) {
|
|
IBlockState blockState = worldIn.getBlockState(pos);
|
|
Block block = blockState.getBlock();
|
|
IBlockState activatedState = PluginApiculture.getBlocks().candle.getStateFromMeta(block.getMetaFromState(blockState));
|
|
worldIn.setBlockState(pos, activatedState, Constants.FLAG_BLOCK_SYNC);
|
|
TileCandle tc = new TileCandle();
|
|
tc.setColour(16777215); // default to white
|
|
tc.setLit(true);
|
|
worldIn.setTileEntity(pos, tc);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
|
|
}
|
|
}
|