Added rarity to accelerator blocks

This commit is contained in:
LemADEC 2017-02-04 00:31:55 +01:00
parent 2f739e87bf
commit 1d9409f5ef
4 changed files with 35 additions and 6 deletions

View file

@ -0,0 +1,9 @@
package cr0s.warpdrive.api;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
public interface IBlockBase {
EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity);
}

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.block;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.api.IBlockBase;
import cr0s.warpdrive.config.WarpDriveConfig;
import defense.api.IEMPBlock;
import defense.api.IExplosion;
@ -23,7 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection;
@Optional.InterfaceList({
@Optional.Interface(iface = "defense.api.IEMPBlock", modid = "DefenseTech")
})
public abstract class BlockAbstractContainer extends BlockContainer implements IEMPBlock {
public abstract class BlockAbstractContainer extends BlockContainer implements IBlockBase, IEMPBlock {
protected boolean isRotating = false;
protected boolean hasSubBlocks = false;
@ -198,7 +199,8 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
return 1;
}
EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity) {
@Override
public EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity) {
switch (getTier(itemStack)) {
case 0: return EnumRarity.epic;
case 1: return EnumRarity.common;

View file

@ -3,6 +3,7 @@ package cr0s.warpdrive.block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBlockBase;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
@ -48,10 +49,10 @@ public class ItemBlockAbstractBase extends ItemBlock {
@Override
public EnumRarity getRarity(ItemStack itemStack) {
if ( itemStack == null
|| !(field_150939_a instanceof BlockAbstractContainer) ) {
|| !(field_150939_a instanceof IBlockBase) ) {
return super.getRarity(itemStack);
}
return ((BlockAbstractContainer)field_150939_a).getRarity(itemStack, super.getRarity(itemStack));
return ((IBlockBase) field_150939_a).getRarity(itemStack, super.getRarity(itemStack));
}
private String getStatus(final NBTTagCompound nbtTagCompound, final int metadata) {

View file

@ -1,14 +1,16 @@
package cr0s.warpdrive.block.atomic;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBlockBase;
import cr0s.warpdrive.config.WarpDriveConfig;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockAbstractAccelerator extends Block {
public class BlockAbstractAccelerator extends Block implements IBlockBase {
public final byte tier;
public BlockAbstractAccelerator(final byte tier) {
@ -40,6 +42,21 @@ public class BlockAbstractAccelerator extends Block {
return 0;
}
public byte getTier(final ItemStack itemStack) {
return tier;
}
@Override
public EnumRarity getRarity(final ItemStack itemStack, final EnumRarity rarity) {
switch (getTier(itemStack)) {
case 0: return EnumRarity.epic;
case 1: return EnumRarity.common;
case 2: return EnumRarity.uncommon;
case 3: return EnumRarity.rare;
default: return rarity;
}
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return false;