2015-08-29 14:33:25 +02:00
|
|
|
/*
|
|
|
|
* This file ("BlockWildPlant.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-01-03 16:05:51 +01:00
|
|
|
* http://ellpeck.de/actaddlicense/
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-01-03 16:05:51 +01:00
|
|
|
* © 2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
2015-06-28 03:12:32 +02:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2015-06-28 03:12:32 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
2015-07-06 23:41:10 +02:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2015-06-28 03:12:32 +02:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.item.EnumRarity;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-06-28 03:12:32 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public class BlockWildPlant extends BlockBushBase{
|
2015-06-28 03:12:32 +02:00
|
|
|
|
|
|
|
public static final TheWildPlants[] allWildPlants = TheWildPlants.values();
|
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public BlockWildPlant(String name){
|
|
|
|
super(name);
|
2015-06-28 03:12:32 +02:00
|
|
|
this.setStepSound(soundTypeGrass);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canBlockStay(World world, int x, int y, int z){
|
2015-10-02 16:48:01 +02:00
|
|
|
return world.getBlockMetadata(x, y, z) == TheWildPlants.RICE.ordinal() ? world.getBlock(x, y-1, z).getMaterial() == Material.water : world.getBlock(x, y-1, z).canSustainPlant(world, x, y-1, z, ForgeDirection.UP, this);
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
|
|
|
|
2015-12-16 15:26:33 +01:00
|
|
|
@Override
|
2015-12-21 22:46:23 +01:00
|
|
|
public Class<? extends ItemBlockBase> getItemBlock(){
|
|
|
|
return TheItemBlock.class;
|
2015-12-16 15:26:33 +01:00
|
|
|
}
|
|
|
|
|
2015-12-19 10:30:39 +01:00
|
|
|
@Override
|
2015-12-21 22:46:23 +01:00
|
|
|
public boolean shouldAddCreative(){
|
|
|
|
return false;
|
2015-12-19 10:30:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
|
|
|
return stack.getItemDamage() >= allWildPlants.length ? EnumRarity.common : allWildPlants[stack.getItemDamage()].rarity;
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
2015-10-28 14:46:04 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-10-03 10:19:40 +02:00
|
|
|
public IIcon getIcon(int side, int metadata){
|
|
|
|
return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getIcon(0, 7);
|
|
|
|
}
|
|
|
|
|
2015-06-28 03:12:32 +02:00
|
|
|
@Override
|
|
|
|
public boolean canSilkHarvest(){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public Item getItem(World world, int x, int y, int z){
|
|
|
|
int meta = world.getBlockMetadata(x, y, z);
|
|
|
|
return meta >= allWildPlants.length ? null : ((BlockPlant)allWildPlants[meta].wildVersionOf).seedItem;
|
|
|
|
}
|
|
|
|
|
2015-06-28 03:12:32 +02:00
|
|
|
@SuppressWarnings("all")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubBlocks(Item item, CreativeTabs tab, List list){
|
2015-10-02 16:48:01 +02:00
|
|
|
for(int j = 0; j < allWildPlants.length; j++){
|
2015-06-28 03:12:32 +02:00
|
|
|
list.add(new ItemStack(item, 1, j));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-06 23:41:10 +02:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerBlockIcons(IIconRegister iconReg){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-06-28 03:12:32 +02:00
|
|
|
@Override
|
2015-10-03 10:19:40 +02:00
|
|
|
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune){
|
|
|
|
return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getDrops(world, x, y, z, 7, fortune);
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
|
|
|
|
2015-10-23 16:48:56 +02:00
|
|
|
public static class TheItemBlock extends ItemBlockBase{
|
2015-06-28 03:12:32 +02:00
|
|
|
|
|
|
|
public TheItemBlock(Block block){
|
|
|
|
super(block);
|
|
|
|
this.setHasSubtypes(true);
|
|
|
|
this.setMaxDamage(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-28 14:46:04 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-10-23 16:54:33 +02:00
|
|
|
public IIcon getIconFromDamage(int meta){
|
|
|
|
return this.field_150939_a.getIcon(0, meta);
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-10-23 16:54:33 +02:00
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
2015-11-23 19:06:07 +01:00
|
|
|
return stack.getItemDamage() >= allWildPlants.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allWildPlants[stack.getItemDamage()].name;
|
2015-06-28 03:12:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|