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
|
||||
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() {
|
||||
if (worldObj == null) {
|
||||
return "";
|
||||
|
|
|
@ -132,7 +132,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
|
||||
if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
|
||||
tileEntityForceFieldProjector.dismountUpgrade(enumForceFieldUpgrade);
|
||||
// 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;
|
||||
|
||||
} else {// default to dismount shape
|
||||
|
@ -162,15 +162,15 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
|
||||
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.NONE);
|
||||
// shape dismounted
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.dismounted"));
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.shapeDismounted"));
|
||||
} else {
|
||||
// wrong side
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.wrongSide"));
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.wrongShapeSide"));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
// not enough shape items
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted(
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -206,11 +206,11 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
// mount the new shape item(s)
|
||||
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.get(itemStackHeld.getItemDamage()));
|
||||
// shape mounted
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.mounted"));
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.shapeMounted"));
|
||||
|
||||
} else {
|
||||
// wrong side
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.shape.result.wrongSide"));
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.wrongShapeSide"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -218,12 +218,12 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
// validate type
|
||||
if (tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade) <= 0) {
|
||||
// invalid upgrade type
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.invalidProjectorUpgrade"));
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidProjectorUpgrade"));
|
||||
return true;
|
||||
}
|
||||
if (!tileEntityForceFieldProjector.canUpgrade(enumForceFieldUpgrade)) {
|
||||
// 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)));
|
||||
return true;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
// validate quantity
|
||||
if (itemStackHeld.stackSize < 1) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
// mount the new upgrade item
|
||||
tileEntityForceFieldProjector.mountUpgrade(enumForceFieldUpgrade);
|
||||
// upgrade mounted
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.mounted"));
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumForceFieldUpgrade));
|
||||
}
|
||||
|
||||
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
|
||||
if (entityPlayer.isSneaking()) {
|
||||
if (tileEntityForceFieldRelay.getUpgrade() != EnumForceFieldUpgrade.NONE) {
|
||||
EnumForceFieldUpgrade enumForceFieldUpgrade = tileEntityForceFieldRelay.getUpgrade();
|
||||
if (enumForceFieldUpgrade != EnumForceFieldUpgrade.NONE) {
|
||||
if (!entityPlayer.capabilities.isCreativeMode) {
|
||||
// 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.delayBeforeCanPickup = 0;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
|
@ -96,11 +97,11 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
|||
|
||||
tileEntityForceFieldRelay.setUpgrade(EnumForceFieldUpgrade.NONE);
|
||||
// upgrade dismounted
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.dismounted"));
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumForceFieldUpgrade.name()));
|
||||
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -112,7 +113,7 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
|||
// validate type
|
||||
if (EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()).maxCountOnRelay <= 0) {
|
||||
// invalid upgrade type
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.invalidRelayUpgrade"));
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidRelayUpgrade"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -120,7 +121,7 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
|||
// validate quantity
|
||||
if (itemStackHeld.stackSize < 1) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -137,9 +138,10 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
|||
}
|
||||
|
||||
// mount the new upgrade item
|
||||
tileEntityForceFieldRelay.setUpgrade(EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()));
|
||||
EnumForceFieldUpgrade enumForceFieldUpgrade = EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage());
|
||||
tileEntityForceFieldRelay.setUpgrade(enumForceFieldUpgrade);
|
||||
// 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;
|
||||
|
|
|
@ -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
|
||||
public String getStatus() {
|
||||
return super.getStatus()
|
||||
|
|
|
@ -36,14 +36,15 @@ public class TileEntityForceFieldRelay extends TileEntityAbstractForceField impl
|
|||
markDirty();
|
||||
}
|
||||
|
||||
private String getUpgradeStatus() {
|
||||
@Override
|
||||
public String getUpgradeStatus() {
|
||||
EnumForceFieldUpgrade enumForceFieldUpgrade = getUpgrade();
|
||||
String strDisplayName = StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine." + enumForceFieldUpgrade.unlocalizedName);
|
||||
if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine.none",
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.upgrade.statusLine.none",
|
||||
strDisplayName);
|
||||
} else {
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.statusLine.valid",
|
||||
return StatCollector.translateToLocalFormatted("warpdrive.upgrade.statusLine.valid",
|
||||
strDisplayName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package cr0s.warpdrive.item;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import cr0s.warpdrive.block.energy.BlockEnergyBank;
|
||||
import cr0s.warpdrive.data.EnumComponentType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -12,6 +14,7 @@ import net.minecraft.util.IIcon;
|
|||
import net.minecraft.util.StatCollector;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IAirCanister;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemComponent extends Item implements IAirCanister {
|
||||
private IIcon[] icons;
|
||||
|
@ -100,6 +103,12 @@ public class ItemComponent extends Item implements IAirCanister {
|
|||
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
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean advancedItemTooltips) {
|
||||
super.addInformation(itemStack, entityPlayer, list, advancedItemTooltips);
|
||||
|
|
|
@ -2,6 +2,8 @@ package cr0s.warpdrive.item;
|
|||
|
||||
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.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -116,6 +118,12 @@ public class ItemTuningFork extends Item {
|
|||
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
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean advancedItemTooltips) {
|
||||
super.addInformation(itemStack, entityPlayer, list, advancedItemTooltips);
|
||||
|
|
Loading…
Reference in a new issue