Check for energy in tools moved to RC.
This commit is contained in:
parent
e6707b2ddd
commit
0de4110f96
6 changed files with 40 additions and 59 deletions
|
@ -59,7 +59,7 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
|||
super(ToolMaterials.DIAMOND, 1, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1));
|
||||
}
|
||||
|
||||
// ItemPickaxe
|
||||
// PickaxeItem
|
||||
@Override
|
||||
public boolean isEffectiveOn(BlockState state) {
|
||||
if (Items.DIAMOND_PICKAXE.isEffectiveOn(state)) {
|
||||
|
@ -77,7 +77,7 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
|||
}
|
||||
}
|
||||
|
||||
// ItemTool
|
||||
// MiningToolItem
|
||||
@Override
|
||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||
Random rand = new Random();
|
||||
|
@ -87,20 +87,18 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
|||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int getHarvestLevel(ItemStack stack, ToolType toolType, @Nullable PlayerEntity player, @Nullable BlockState blockState) {
|
||||
// if (!stack.hasEnchantments()) {
|
||||
// stack.addEnchantment(Enchantments.SILK_TOUCH, 1);
|
||||
// }
|
||||
// return super.getHarvestLevel(stack, toolType, player, blockState);
|
||||
// }
|
||||
@Override
|
||||
public boolean postHit(ItemStack itemstack, LivingEntity entityliving, LivingEntity entityliving1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Item
|
||||
// ToolItem
|
||||
@Override
|
||||
public boolean canRepair(ItemStack stack, ItemStack stack2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Item
|
||||
@Override
|
||||
public void onCraft(ItemStack stack, World worldIn, PlayerEntity playerIn) {
|
||||
if (!stack.hasEnchantments()) {
|
||||
|
@ -109,18 +107,8 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getDurability(ItemStack stack) {
|
||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurability(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurabilityColor(ItemStack stack) {
|
||||
return PowerSystem.getDisplayPower().colour;
|
||||
public boolean isDamageable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
@ -139,7 +127,23 @@ public class RockCutterItem extends PickaxeItem implements EnergyHolder, ItemDur
|
|||
itemList.add(charged);
|
||||
}
|
||||
|
||||
// IEnergyItemInfo
|
||||
// ItemDurabilityExtensions
|
||||
@Override
|
||||
public double getDurability(ItemStack stack) {
|
||||
return 1 - ItemUtils.getPowerForDurabilityBar(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurability(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurabilityColor(ItemStack stack) {
|
||||
return PowerSystem.getDisplayPower().colour;
|
||||
}
|
||||
|
||||
// EnergyHolder
|
||||
@Override
|
||||
public double getMaxStoredPower() {
|
||||
return maxCharge;
|
||||
|
|
|
@ -121,7 +121,7 @@ public class IndustrialChainsawItem extends ChainsawItem {
|
|||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
if (Energy.of(stack).getEnergy() < cost) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.nanosaberEnergyErrorTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberActivate")));
|
||||
} else {
|
||||
|
@ -131,14 +131,14 @@ public class IndustrialChainsawItem extends ChainsawItem {
|
|||
}
|
||||
stack.getTag().putBoolean("isActive", true);
|
||||
if (world.isClient) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberActive")));
|
||||
}
|
||||
} else {
|
||||
stack.getOrCreateTag().putBoolean("isActive", false);
|
||||
if (world.isClient) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberInactive")));
|
||||
}
|
||||
|
@ -151,14 +151,7 @@ public class IndustrialChainsawItem extends ChainsawItem {
|
|||
|
||||
@Override
|
||||
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
|
||||
if (ItemUtils.isActive(stack) && Energy.of(stack).getEnergy() < cost) {
|
||||
if(entity.world.isClient){
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.nanosaberEnergyError") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberDeactivating")));
|
||||
}
|
||||
stack.getOrCreateTag().putBoolean("isActive", false);
|
||||
}
|
||||
ItemUtils.checkActive(stack, cost, entity.world.isClient, MessageIDs.poweredToolID);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
|
|
@ -173,7 +173,7 @@ public class IndustrialDrillItem extends DrillItem {
|
|||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
if (Energy.of(stack).getEnergy() < cost) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.nanosaberEnergyErrorTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberActivate")));
|
||||
} else {
|
||||
|
@ -183,14 +183,14 @@ public class IndustrialDrillItem extends DrillItem {
|
|||
}
|
||||
stack.getOrCreateTag().putBoolean("isActive", true);
|
||||
if (world.isClient) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberActive")));
|
||||
}
|
||||
} else {
|
||||
stack.getOrCreateTag().putBoolean("isActive", false);
|
||||
if (world.isClient) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberInactive")));
|
||||
}
|
||||
|
@ -203,14 +203,7 @@ public class IndustrialDrillItem extends DrillItem {
|
|||
|
||||
@Override
|
||||
public void usageTick(World world, LivingEntity entity, ItemStack stack, int i) {
|
||||
if (ItemUtils.isActive(stack) && Energy.of(stack).getEnergy() < cost) {
|
||||
if(entity.world.isClient){
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.nanosaberEnergyError") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberDeactivating")));
|
||||
}
|
||||
stack.getOrCreateTag().putBoolean("isActive", false);
|
||||
}
|
||||
ItemUtils.checkActive(stack, cost, entity.world.isClient, MessageIDs.poweredToolID);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
|
|
@ -107,7 +107,7 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
|
|||
final ItemStack stack = player.getStackInHand(hand);
|
||||
if (player.isSneaking()) {
|
||||
if (Energy.of(stack).getEnergy() < cost) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.nanosaberEnergyErrorTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberActivate")));
|
||||
} else {
|
||||
|
@ -117,14 +117,14 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
|
|||
}
|
||||
stack.getTag().putBoolean("isActive", true);
|
||||
if (world.isClient) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberActive")));
|
||||
}
|
||||
} else {
|
||||
stack.getOrCreateTag().putBoolean("isActive", false);
|
||||
if (world.isClient) {
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.poweredToolID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.setTo") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberInactive")));
|
||||
}
|
||||
|
@ -137,14 +137,7 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
|
|||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||
if (ItemUtils.isActive(stack) && Energy.of(stack).getEnergy() < cost) {
|
||||
if(worldIn.isClient){
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.nanosaberEnergyError") + " "
|
||||
+ Formatting.GOLD + StringUtils.t("techreborn.message.nanosaberDeactivating")));
|
||||
}
|
||||
stack.getOrCreateTag().putBoolean("isActive", false);
|
||||
}
|
||||
ItemUtils.checkActive(stack, cost, entityIn.world.isClient, MessageIDs.poweredToolID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,6 @@ public class MessageIDs {
|
|||
public static int freqTransmitterID = 0;
|
||||
public static int fluidPipeID = 1;
|
||||
public static int playerDetectorID = 2;
|
||||
public static int nanosaberID = 3;
|
||||
public static int poweredToolID = 3;
|
||||
public static int alarmID = 4;
|
||||
}
|
||||
|
|
|
@ -596,10 +596,8 @@
|
|||
"techreborn.message.onlyYou": "Only You",
|
||||
"techreborn.message.nanosaberActive": "Active",
|
||||
"techreborn.message.nanosaberActivate": "Activate",
|
||||
"techreborn.message.nanosaberDeactivating": "Deactivating",
|
||||
"techreborn.message.nanosaberInactive": "Inactive",
|
||||
"techreborn.message.nanosaberEnergyErrorTo": "Not Enough Energy to",
|
||||
"techreborn.message.nanosaberEnergyError": "Not Enough Energy:",
|
||||
"techreborn.message.daygen": "Panel in direct sunlight",
|
||||
"techreborn.message.nightgen": "Panel in reduced sunlight",
|
||||
"techreborn.message.zerogen": "Panel obstructed from sky",
|
||||
|
|
Loading…
Add table
Reference in a new issue