Made this system less stupid

This commit is contained in:
Ellpeck 2016-06-27 20:24:45 +02:00
parent 925b259d8f
commit 1c9c7af416
7 changed files with 23 additions and 24 deletions

View file

@ -20,7 +20,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
public class BlockBase extends Block{
public class BlockBase extends Block implements ItemBlockBase.ICustomRarity{
private final String name;
@ -53,6 +53,7 @@ public class BlockBase extends Block{
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.COMMON;
}

View file

@ -20,7 +20,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
public class BlockBushBase extends BlockBush{
public class BlockBushBase extends BlockBush implements ItemBlockBase.ICustomRarity{
private final String name;
@ -53,6 +53,7 @@ public class BlockBushBase extends BlockBush{
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.COMMON;
}

View file

@ -41,7 +41,7 @@ import net.minecraftforge.fluids.FluidUtil;
import java.util.ArrayList;
import java.util.Random;
public abstract class BlockContainerBase extends BlockContainer{
public abstract class BlockContainerBase extends BlockContainer implements ItemBlockBase.ICustomRarity{
private final String name;
@ -74,6 +74,7 @@ public abstract class BlockContainerBase extends BlockContainer{
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.COMMON;
}

View file

@ -22,7 +22,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
public class BlockFluidFlowing extends BlockFluidClassic{
public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity{
private final String name;
@ -60,6 +60,7 @@ public class BlockFluidFlowing extends BlockFluidClassic{
return !PosUtil.getMaterial(pos, world).isLiquid() && super.displaceIfPossible(world, pos);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.EPIC;
}

View file

@ -29,7 +29,7 @@ import net.minecraftforge.common.EnumPlantType;
import java.util.List;
import java.util.Random;
public class BlockPlant extends BlockCrops{
public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarity{
private final String name;
private final int minDropAmount;
@ -73,6 +73,7 @@ public class BlockPlant extends BlockCrops{
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE;
}

View file

@ -18,7 +18,7 @@ import net.minecraft.block.BlockStairs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
public class BlockStair extends BlockStairs{
public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRarity{
private final String name;
@ -56,6 +56,7 @@ public class BlockStair extends BlockStairs{
ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.COMMON;
}

View file

@ -24,6 +24,7 @@ public class ItemBlockBase extends ItemBlock{
this.setMaxDamage(0);
}
@Override
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName();
@ -34,28 +35,20 @@ public class ItemBlockBase extends ItemBlock{
return damage;
}
@Override
public EnumRarity getRarity(ItemStack stack){
if(this.block instanceof BlockBase){
return ((BlockBase)this.block).getRarity(stack);
}
else if(this.block instanceof BlockContainerBase){
return ((BlockContainerBase)this.block).getRarity(stack);
}
else if(this.block instanceof BlockFluidFlowing){
return ((BlockFluidFlowing)this.block).getRarity(stack);
}
else if(this.block instanceof BlockPlant){
return ((BlockPlant)this.block).getRarity(stack);
}
else if(this.block instanceof BlockStair){
return ((BlockStair)this.block).getRarity(stack);
}
else if(this.block instanceof BlockBushBase){
return ((BlockBushBase)this.block).getRarity(stack);
if(this.block instanceof ICustomRarity){
return ((ICustomRarity)this.block).getRarity(stack);
}
else{
return Util.FALLBACK_RARITY;
}
}
public interface ICustomRarity{
EnumRarity getRarity(ItemStack stack);
}
}