Added rarity settings
This commit is contained in:
parent
32cf54347c
commit
8920792356
13 changed files with 107 additions and 13 deletions
|
@ -431,7 +431,7 @@ public class WarpDrive implements LoadingCallback {
|
|||
blockHulls_stairs = new Block[3][16];
|
||||
blockHulls_slab = new Block[3][16];
|
||||
|
||||
for(int tier = 1; tier <= 3; tier++) {
|
||||
for(byte tier = 1; tier <= 3; tier++) {
|
||||
int index = tier - 1;
|
||||
blockHulls_plain[index] = new BlockHullPlain(tier);
|
||||
blockHulls_glass[index] = new BlockHullGlass(tier);
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.block.BlockContainer;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -23,6 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
})
|
||||
public abstract class BlockAbstractContainer extends BlockContainer implements IEMPBlock {
|
||||
protected boolean isRotating = false;
|
||||
protected boolean hasSubBlocks = false;
|
||||
|
||||
protected BlockAbstractContainer(Material material) {
|
||||
super(material);
|
||||
|
@ -106,6 +108,7 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
|
|||
super.dropBlockAsItem(world, x, y, z, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer entityPlayer) {
|
||||
ItemStack itemStack = super.getPickBlock(target, world, x, y, z, entityPlayer);
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
|
@ -164,6 +167,7 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "DefenseTech")
|
||||
public void onEMP(World world, int x, int y, int z, IExplosion explosiveEMP) {
|
||||
if (WarpDriveConfig.LOGGING_WEAPON) {
|
||||
|
@ -183,4 +187,18 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte getTier(final ItemStack itemStack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import cr0s.warpdrive.WarpDrive;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -31,8 +32,27 @@ public class ItemBlockAbstractBase extends ItemBlock {
|
|||
return damage;
|
||||
}
|
||||
|
||||
public String getStatus(final NBTTagCompound nbtTagCompound) {
|
||||
TileEntity tileEntity = field_150939_a.createTileEntity(null, 0);
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack) {
|
||||
if ( itemStack == null
|
||||
|| !(field_150939_a instanceof BlockAbstractContainer)
|
||||
|| !((BlockAbstractContainer) field_150939_a).hasSubBlocks ) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
return getUnlocalizedName() + itemStack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack itemStack) {
|
||||
if ( itemStack == null
|
||||
|| !(field_150939_a instanceof BlockAbstractContainer) ) {
|
||||
return super.getRarity(itemStack);
|
||||
}
|
||||
return ((BlockAbstractContainer)field_150939_a).getRarity(itemStack, super.getRarity(itemStack));
|
||||
}
|
||||
|
||||
private String getStatus(final NBTTagCompound nbtTagCompound, final int metadata) {
|
||||
TileEntity tileEntity = field_150939_a.createTileEntity(null, metadata);
|
||||
if (tileEntity instanceof TileEntityAbstractBase) {
|
||||
if (nbtTagCompound != null) {
|
||||
tileEntity.readFromNBT(nbtTagCompound);
|
||||
|
@ -58,6 +78,6 @@ public class ItemBlockAbstractBase extends ItemBlock {
|
|||
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted(tooltipName2));
|
||||
}
|
||||
|
||||
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted(getStatus(itemStack.getTagCompound())));
|
||||
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted(getStatus(itemStack.getTagCompound(), itemStack.getItemDamage())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,7 +338,12 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
|
|||
|
||||
// status
|
||||
public String getStatus() {
|
||||
return (worldObj != null ? StatCollector.translateToLocalFormatted("warpdrive.guide.prefix", getBlockType().getLocalizedName()) : "");
|
||||
if (worldObj == null) {
|
||||
return "";
|
||||
} else {
|
||||
ItemStack itemStack = new ItemStack(Item.getItemFromBlock(getBlockType()), 1, getBlockMetadata());
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.guide.prefix", StatCollector.translateToLocalFormatted(itemStack.getUnlocalizedName() + ".name"));
|
||||
}
|
||||
}
|
||||
|
||||
// upgrade system
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
@ -58,6 +59,11 @@ public class BlockCloakingCore extends BlockAbstractContainer {
|
|||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getTier(final ItemStack itemStack) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item to drop on destruction.
|
||||
*/
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
@ -90,6 +91,11 @@ public class BlockRadar extends BlockAbstractContainer {
|
|||
return Item.getItemFromBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getTier(final ItemStack itemStack) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import cr0s.warpdrive.block.BlockAbstractContainer;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
@ -76,4 +77,9 @@ public class BlockEnanReactorCore extends BlockAbstractContainer {
|
|||
iconBuffer[14] = par1IconRegister.registerIcon("warpdrive:energy/enanReactorCoreSide32");
|
||||
iconBuffer[15] = par1IconRegister.registerIcon("warpdrive:energy/enanReactorCoreSide33");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getTier(final ItemStack itemStack) {
|
||||
return 3;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package cr0s.warpdrive.block.energy;
|
|||
import cr0s.warpdrive.block.BlockAbstractContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
@ -74,4 +75,9 @@ public class BlockEnanReactorLaser extends BlockAbstractContainer {
|
|||
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:energy/enanReactorLaserSides");
|
||||
iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:energy/enanReactorLaserActive");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getTier(final ItemStack itemStack) {
|
||||
return 3;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package cr0s.warpdrive.block.forcefield;
|
|||
import cr0s.warpdrive.block.BlockAbstractContainer;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockAbstractForceField extends BlockAbstractContainer {
|
||||
|
@ -25,6 +26,11 @@ public abstract class BlockAbstractForceField extends BlockAbstractContainer {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getTier(final ItemStack itemStack) {
|
||||
return tier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEMP(World world, final int x, final int y, final int z, final float efficiency) {
|
||||
super.onEMP(world, x, y, z, efficiency * (1.0F - 0.2F * (tier - 1)));
|
||||
|
|
|
@ -14,9 +14,9 @@ import cr0s.warpdrive.api.IDamageReceiver;
|
|||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
||||
public class BlockHullGlass extends BlockColored implements IDamageReceiver {
|
||||
private final int tier;
|
||||
final byte tier;
|
||||
|
||||
public BlockHullGlass(final int tier) {
|
||||
public BlockHullGlass(final byte tier) {
|
||||
super(Material.glass);
|
||||
this.tier = tier;
|
||||
setHardness(WarpDriveConfig.HULL_HARDNESS[tier - 1]);
|
||||
|
|
|
@ -23,9 +23,9 @@ import cr0s.warpdrive.config.WarpDriveConfig;
|
|||
public class BlockHullPlain extends Block implements IDamageReceiver {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
private final int tier;
|
||||
final byte tier;
|
||||
|
||||
public BlockHullPlain(final int tier) {
|
||||
public BlockHullPlain(final byte tier) {
|
||||
super(Material.rock);
|
||||
this.tier = tier;
|
||||
setHardness(WarpDriveConfig.HULL_HARDNESS[tier - 1]);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package cr0s.warpdrive.block.hull;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IDamageReceiver;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
@ -14,11 +12,11 @@ import net.minecraft.util.DamageSource;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockHullStairs extends BlockStairs implements IDamageReceiver {
|
||||
private final int tier;
|
||||
protected final byte tier;
|
||||
private final Block blockHull;
|
||||
private final int metaHull;
|
||||
|
||||
public BlockHullStairs(final Block blockHull, final int metaHull, final int tier) {
|
||||
public BlockHullStairs(final Block blockHull, final int metaHull, final byte tier) {
|
||||
super(blockHull, metaHull);
|
||||
this.blockHull = blockHull;
|
||||
this.metaHull = metaHull;
|
||||
|
|
|
@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -36,4 +37,26 @@ public class ItemBlockHull extends ItemBlock {
|
|||
}
|
||||
return getUnlocalizedName() + ItemDye.field_150923_a[BlockColored.func_150031_c(itemstack.getItemDamage())];
|
||||
}
|
||||
|
||||
private byte getTier() {
|
||||
if (field_150939_a instanceof BlockHullGlass) {
|
||||
return ((BlockHullGlass)field_150939_a).tier;
|
||||
} else if (field_150939_a instanceof BlockHullPlain) {
|
||||
return ((BlockHullPlain)field_150939_a).tier;
|
||||
} else if (field_150939_a instanceof BlockHullStairs) {
|
||||
return ((BlockHullStairs)field_150939_a).tier;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(final ItemStack itemStack) {
|
||||
switch (getTier()) {
|
||||
case 0: return EnumRarity.epic;
|
||||
case 1: return EnumRarity.common;
|
||||
case 2: return EnumRarity.uncommon;
|
||||
case 3: return EnumRarity.rare;
|
||||
default: return EnumRarity.common;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue