Refactored upgrade system for EnergyBanks
This commit is contained in:
parent
8116e14e94
commit
4d8ccf7df2
7 changed files with 54 additions and 34 deletions
|
@ -337,6 +337,17 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
|
||||||
}
|
}
|
||||||
|
|
||||||
// status
|
// status
|
||||||
|
protected String getUpgradeStatus() {
|
||||||
|
String strUpgrades = getUpgradesAsString();
|
||||||
|
if (strUpgrades.isEmpty()) {
|
||||||
|
return StatCollector.translateToLocalFormatted("warpdrive.upgrade.statusLine.none",
|
||||||
|
strUpgrades);
|
||||||
|
} else {
|
||||||
|
return StatCollector.translateToLocalFormatted("warpdrive.upgrade.statusLine.valid",
|
||||||
|
strUpgrades);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
if (worldObj == null) {
|
if (worldObj == null) {
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||||
|
|
||||||
if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) {
|
if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) {
|
||||||
// no more upgrades to dismount
|
// no more upgrades to dismount
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.noUpgradeToDismount"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||||
|
|
||||||
tileEntityForceFieldProjector.dismountUpgrade(enumForceFieldUpgrade);
|
tileEntityForceFieldProjector.dismountUpgrade(enumForceFieldUpgrade);
|
||||||
// upgrade dismounted
|
// upgrade dismounted
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.dismounted"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumForceFieldUpgrade.name()));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else {// default to dismount shape
|
} else {// default to dismount shape
|
||||||
|
@ -162,15 +162,15 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||||
|
|
||||||
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.NONE);
|
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.NONE);
|
||||||
// shape dismounted
|
// shape dismounted
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.dismounted"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.shapeDismounted"));
|
||||||
} else {
|
} else {
|
||||||
// wrong side
|
// wrong side
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.wrongSide"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.wrongShapeSide"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no shape to dismount
|
// no shape to dismount
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.noShapeToDismount"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noShapeToDismount"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||||
// not enough shape items
|
// not enough shape items
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted(
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted(
|
||||||
tileEntityForceFieldProjector.isDoubleSided ?
|
tileEntityForceFieldProjector.isDoubleSided ?
|
||||||
"warpdrive.forcefield.shape.result.notEnoughShapes.double" : "warpdrive.forcefield.shape.result.notEnoughShapes.single"));
|
"warpdrive.upgrade.result.notEnoughShapes.double" : "warpdrive.upgrade.result.notEnoughShapes.single"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,11 +206,11 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||||
// mount the new shape item(s)
|
// mount the new shape item(s)
|
||||||
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.get(itemStackHeld.getItemDamage()));
|
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.get(itemStackHeld.getItemDamage()));
|
||||||
// shape mounted
|
// shape mounted
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.mounted"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.shapeMounted"));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// wrong side
|
// wrong side
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.wrongSide"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.wrongShapeSide"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,12 +218,12 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||||
// validate type
|
// validate type
|
||||||
if (tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade) <= 0) {
|
if (tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade) <= 0) {
|
||||||
// invalid upgrade type
|
// invalid upgrade type
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.invalidProjectorUpgrade"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidProjectorUpgrade"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!tileEntityForceFieldProjector.canUpgrade(enumForceFieldUpgrade)) {
|
if (!tileEntityForceFieldProjector.canUpgrade(enumForceFieldUpgrade)) {
|
||||||
// too many upgrades
|
// too many upgrades
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.tooManyUpgrades",
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.tooManyUpgrades",
|
||||||
tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade)));
|
tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||||
// validate quantity
|
// validate quantity
|
||||||
if (itemStackHeld.stackSize < 1) {
|
if (itemStackHeld.stackSize < 1) {
|
||||||
// not enough upgrade items
|
// not enough upgrade items
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.notEnoughUpgrades"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
||||||
// mount the new upgrade item
|
// mount the new upgrade item
|
||||||
tileEntityForceFieldProjector.mountUpgrade(enumForceFieldUpgrade);
|
tileEntityForceFieldProjector.mountUpgrade(enumForceFieldUpgrade);
|
||||||
// upgrade mounted
|
// upgrade mounted
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.mounted"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumForceFieldUpgrade));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -85,10 +85,11 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
||||||
|
|
||||||
// sneaking with an empty hand or an upgrade item in hand to dismount current upgrade
|
// sneaking with an empty hand or an upgrade item in hand to dismount current upgrade
|
||||||
if (entityPlayer.isSneaking()) {
|
if (entityPlayer.isSneaking()) {
|
||||||
if (tileEntityForceFieldRelay.getUpgrade() != EnumForceFieldUpgrade.NONE) {
|
EnumForceFieldUpgrade enumForceFieldUpgrade = tileEntityForceFieldRelay.getUpgrade();
|
||||||
|
if (enumForceFieldUpgrade != EnumForceFieldUpgrade.NONE) {
|
||||||
if (!entityPlayer.capabilities.isCreativeMode) {
|
if (!entityPlayer.capabilities.isCreativeMode) {
|
||||||
// dismount the upgrade item
|
// dismount the upgrade item
|
||||||
ItemStack itemStackDrop = ItemForceFieldUpgrade.getItemStackNoCache(tileEntityForceFieldRelay.getUpgrade(), 1);
|
ItemStack itemStackDrop = ItemForceFieldUpgrade.getItemStackNoCache(enumForceFieldUpgrade, 1);
|
||||||
EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop);
|
EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop);
|
||||||
entityItem.delayBeforeCanPickup = 0;
|
entityItem.delayBeforeCanPickup = 0;
|
||||||
world.spawnEntityInWorld(entityItem);
|
world.spawnEntityInWorld(entityItem);
|
||||||
|
@ -96,11 +97,11 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
||||||
|
|
||||||
tileEntityForceFieldRelay.setUpgrade(EnumForceFieldUpgrade.NONE);
|
tileEntityForceFieldRelay.setUpgrade(EnumForceFieldUpgrade.NONE);
|
||||||
// upgrade dismounted
|
// upgrade dismounted
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.dismounted"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumForceFieldUpgrade.name()));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no more upgrades to dismount
|
// no more upgrades to dismount
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.noUpgradeToDismount"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
||||||
// validate type
|
// validate type
|
||||||
if (EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()).maxCountOnRelay <= 0) {
|
if (EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()).maxCountOnRelay <= 0) {
|
||||||
// invalid upgrade type
|
// invalid upgrade type
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.invalidRelayUpgrade"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidRelayUpgrade"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
||||||
// validate quantity
|
// validate quantity
|
||||||
if (itemStackHeld.stackSize < 1) {
|
if (itemStackHeld.stackSize < 1) {
|
||||||
// not enough upgrade items
|
// not enough upgrade items
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.notEnoughUpgrades"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +138,10 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount the new upgrade item
|
// mount the new upgrade item
|
||||||
tileEntityForceFieldRelay.setUpgrade(EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()));
|
EnumForceFieldUpgrade enumForceFieldUpgrade = EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage());
|
||||||
|
tileEntityForceFieldRelay.setUpgrade(enumForceFieldUpgrade);
|
||||||
// upgrade mounted
|
// upgrade mounted
|
||||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.mounted"));
|
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumForceFieldUpgrade.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -853,17 +853,6 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getUpgradeStatus() {
|
|
||||||
String strUpgrades = getUpgradesAsString();
|
|
||||||
if (strUpgrades.isEmpty()) {
|
|
||||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine.none",
|
|
||||||
strUpgrades);
|
|
||||||
} else {
|
|
||||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine.valid",
|
|
||||||
strUpgrades);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return super.getStatus()
|
return super.getStatus()
|
||||||
|
|
|
@ -36,14 +36,15 @@ public class TileEntityForceFieldRelay extends TileEntityAbstractForceField impl
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getUpgradeStatus() {
|
@Override
|
||||||
|
public String getUpgradeStatus() {
|
||||||
EnumForceFieldUpgrade enumForceFieldUpgrade = getUpgrade();
|
EnumForceFieldUpgrade enumForceFieldUpgrade = getUpgrade();
|
||||||
String strDisplayName = StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine." + enumForceFieldUpgrade.unlocalizedName);
|
String strDisplayName = StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine." + enumForceFieldUpgrade.unlocalizedName);
|
||||||
if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) {
|
if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) {
|
||||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine.none",
|
return StatCollector.translateToLocalFormatted("warpdrive.upgrade.statusLine.none",
|
||||||
strDisplayName);
|
strDisplayName);
|
||||||
} else {
|
} else {
|
||||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine.valid",
|
return StatCollector.translateToLocalFormatted("warpdrive.upgrade.statusLine.valid",
|
||||||
strDisplayName);
|
strDisplayName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@ package cr0s.warpdrive.item;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import cr0s.warpdrive.block.energy.BlockEnergyBank;
|
||||||
import cr0s.warpdrive.data.EnumComponentType;
|
import cr0s.warpdrive.data.EnumComponentType;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -12,6 +14,7 @@ import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import cr0s.warpdrive.WarpDrive;
|
import cr0s.warpdrive.WarpDrive;
|
||||||
import cr0s.warpdrive.api.IAirCanister;
|
import cr0s.warpdrive.api.IAirCanister;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class ItemComponent extends Item implements IAirCanister {
|
public class ItemComponent extends Item implements IAirCanister {
|
||||||
private IIcon[] icons;
|
private IIcon[] icons;
|
||||||
|
@ -100,6 +103,12 @@ public class ItemComponent extends Item implements IAirCanister {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) {
|
||||||
|
Block block = world.getBlock(x, y, z);
|
||||||
|
return block instanceof BlockEnergyBank || super.doesSneakBypassUse(world, x, y, z, player);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean advancedItemTooltips) {
|
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean advancedItemTooltips) {
|
||||||
super.addInformation(itemStack, entityPlayer, list, advancedItemTooltips);
|
super.addInformation(itemStack, entityPlayer, list, advancedItemTooltips);
|
||||||
|
|
|
@ -2,6 +2,8 @@ package cr0s.warpdrive.item;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import cr0s.warpdrive.block.energy.BlockEnergyBank;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -116,6 +118,12 @@ public class ItemTuningFork extends Item {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) {
|
||||||
|
Block block = world.getBlock(x, y, z);
|
||||||
|
return block instanceof BlockEnergyBank || super.doesSneakBypassUse(world, x, y, z, player);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean advancedItemTooltips) {
|
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean advancedItemTooltips) {
|
||||||
super.addInformation(itemStack, entityPlayer, list, advancedItemTooltips);
|
super.addInformation(itemStack, entityPlayer, list, advancedItemTooltips);
|
||||||
|
|
Loading…
Reference in a new issue