mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 02:45:13 +00:00
99 lines
2.7 KiB
Java
99 lines
2.7 KiB
Java
/**
|
|
* This class was created by <Vazkii>. It's distributed as
|
|
* part of the Botania Mod. Get the Source Code in github:
|
|
* https://github.com/Vazkii/Botania
|
|
*
|
|
* Botania is Open Source and distributed under the
|
|
* Botania License: http://botaniamod.net/license.php
|
|
*
|
|
* File Created @ [Jul 8, 2015, 4:29:01 PM (GMT)]
|
|
*/
|
|
package vazkii.botania.common.block;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.init.Items;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.BlockPos;
|
|
import net.minecraft.util.EnumFacing;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import vazkii.botania.api.lexicon.ILexiconable;
|
|
import vazkii.botania.api.lexicon.LexiconEntry;
|
|
import vazkii.botania.common.block.tile.TileCocoon;
|
|
import vazkii.botania.common.lexicon.LexiconData;
|
|
import vazkii.botania.common.lib.LibBlockNames;
|
|
|
|
public class BlockCocoon extends BlockMod implements ILexiconable {
|
|
|
|
protected BlockCocoon() {
|
|
super(Material.cloth);
|
|
setHardness(3.0F);
|
|
setResistance(50.0F);
|
|
setStepSound(soundTypeCloth);
|
|
setUnlocalizedName(LibBlockNames.COCOON);
|
|
float f = 3F / 16F;
|
|
float f1 = 14F / 16F;
|
|
setBlockBounds(f, 0F, f, 1F - f, f1, 1F - f);
|
|
}
|
|
|
|
@Override
|
|
public boolean isFullCube() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int getRenderType() {
|
|
return 2;
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing s, float xs, float ys, float zs) {
|
|
TileCocoon cocoon = (TileCocoon) world.getTileEntity(pos);
|
|
ItemStack item = player.getCurrentEquippedItem();
|
|
if(cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && item != null && item.getItem() == Items.emerald) {
|
|
if(!player.capabilities.isCreativeMode)
|
|
item.stackSize--;
|
|
cocoon.emeraldsGiven++;
|
|
world.playAuxSFX(2005, pos, 6 + world.rand.nextInt(4));
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
|
return new ArrayList<>();
|
|
}
|
|
|
|
@Override
|
|
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean hasTileEntity(IBlockState state) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public TileEntity createTileEntity(World world, IBlockState state) {
|
|
return new TileCocoon();
|
|
}
|
|
|
|
@Override
|
|
public LexiconEntry getEntry(World world, BlockPos pos, EntityPlayer player, ItemStack lexicon) {
|
|
return LexiconData.cocoon;
|
|
}
|
|
|
|
}
|