修复激光在切换物品后依旧存在的bug,调整充电机制
This commit is contained in:
parent
335500e070
commit
8c286596eb
21 changed files with 279 additions and 45 deletions
|
@ -19,6 +19,7 @@ public class ClientRenderHandler {
|
||||||
event.register(ShotgunImageComponent.class, ClientShotgunImageTooltip::new);
|
event.register(ShotgunImageComponent.class, ClientShotgunImageTooltip::new);
|
||||||
event.register(BocekImageComponent.class, ClientBocekImageTooltip::new);
|
event.register(BocekImageComponent.class, ClientBocekImageTooltip::new);
|
||||||
event.register(EnergyImageComponent.class, ClientEnergyImageTooltip::new);
|
event.register(EnergyImageComponent.class, ClientEnergyImageTooltip::new);
|
||||||
|
event.register(CellImageComponent.class, ClientCellImageTooltip::new);
|
||||||
event.register(SentinelImageComponent.class, ClientSentinelImageTooltip::new);
|
event.register(SentinelImageComponent.class, ClientSentinelImageTooltip::new);
|
||||||
event.register(LauncherImageComponent.class, ClientLauncherImageTooltip::new);
|
event.register(LauncherImageComponent.class, ClientLauncherImageTooltip::new);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
package com.atsuishio.superbwarfare.client.tooltip;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class ClientCellImageTooltip extends ClientGunImageTooltip {
|
||||||
|
|
||||||
|
public ClientCellImageTooltip(GunImageComponent tooltip) {
|
||||||
|
super(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderImage(@NotNull Font font, int x, int y, GuiGraphics guiGraphics) {
|
||||||
|
guiGraphics.pose().pushPose();
|
||||||
|
if (shouldRenderEnergyTooltip()) {
|
||||||
|
renderEnergyTooltip(font, guiGraphics, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
guiGraphics.pose().popPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean shouldRenderEnergyTooltip() {
|
||||||
|
return stack.getCapability(ForgeCapabilities.ENERGY).isPresent() && stack.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void renderEnergyTooltip(Font font, GuiGraphics guiGraphics, int x, int y) {
|
||||||
|
guiGraphics.drawString(font, getEnergyComponent(), x, y, 0xFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Component getEnergyComponent() {
|
||||||
|
assert stack.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
||||||
|
var storage = stack.getCapability(ForgeCapabilities.ENERGY).resolve().get();
|
||||||
|
int energy = storage.getEnergyStored();
|
||||||
|
int maxEnergy = storage.getMaxEnergyStored();
|
||||||
|
float percentage = Mth.clamp((float) energy / maxEnergy, 0, 1);
|
||||||
|
MutableComponent component = Component.literal("");
|
||||||
|
|
||||||
|
ChatFormatting format;
|
||||||
|
if (percentage <= .2f) {
|
||||||
|
format = ChatFormatting.RED;
|
||||||
|
} else if (percentage <= .6f) {
|
||||||
|
format = ChatFormatting.YELLOW;
|
||||||
|
} else {
|
||||||
|
format = ChatFormatting.GREEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = (int) (percentage * 50);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
component.append(Component.literal("|").withStyle(format));
|
||||||
|
}
|
||||||
|
component.append(Component.literal("").withStyle(ChatFormatting.RESET));
|
||||||
|
for (int i = 0; i < 50 - count; i++) {
|
||||||
|
component.append(Component.literal("|").withStyle(ChatFormatting.GRAY));
|
||||||
|
}
|
||||||
|
|
||||||
|
component.append(Component.literal(" " + energy + "/" + maxEnergy + " FE").withStyle(ChatFormatting.GRAY));
|
||||||
|
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
int height = super.getHeight();
|
||||||
|
if (shouldRenderEnergyTooltip()) height -= 10;
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth(@NotNull Font font) {
|
||||||
|
int width = super.getWidth(font);
|
||||||
|
if (shouldRenderEnergyTooltip())
|
||||||
|
width = Math.max(width, font.width(getEnergyComponent().getVisualOrderText()) + 10);
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.atsuishio.superbwarfare.client.tooltip.component;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
public class CellImageComponent extends GunImageComponent {
|
||||||
|
|
||||||
|
public int width;
|
||||||
|
public int height;
|
||||||
|
public ItemStack stack;
|
||||||
|
|
||||||
|
public CellImageComponent(int width, int height, ItemStack stack) {
|
||||||
|
super(width, height, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CellImageComponent(ItemStack stack) {
|
||||||
|
this(32, 16, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -197,11 +197,6 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit
|
||||||
this.discard();
|
this.discard();
|
||||||
return InteractionResult.sidedSuccess(this.level().isClientSide());
|
return InteractionResult.sidedSuccess(this.level().isClientSide());
|
||||||
}
|
}
|
||||||
if (player.getMainHandItem().is(ModItems.SHIELD_CELL.get())) {
|
|
||||||
this.entityData.set(ENERGY, (float) Mth.clamp(this.entityData.get(ENERGY) + 1000000, 0, CannonConfig.ANNIHILATOR_MAX_ENERGY.get()));
|
|
||||||
player.displayClientMessage(Component.literal("Energy:" + new java.text.DecimalFormat("##").format(this.entityData.get(ENERGY))), true);
|
|
||||||
return InteractionResult.sidedSuccess(this.level().isClientSide());
|
|
||||||
}
|
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
} else {
|
} else {
|
||||||
if (this.getFirstPassenger() == null) {
|
if (this.getFirstPassenger() == null) {
|
||||||
|
|
|
@ -875,11 +875,30 @@ public class GunEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("sentinel_charge_time") == 17) {
|
if (tag.getInt("sentinel_charge_time") == 17) {
|
||||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
|
||||||
iEnergyStorage -> iEnergyStorage.receiveEnergy(24000, false)
|
|
||||||
);
|
|
||||||
|
|
||||||
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.SHIELD_CELL.get(), 1, player.inventoryMenu.getCraftSlots());
|
for (var cell : player.getInventory().items) {
|
||||||
|
if (cell.is(ModItems.CELL.get())) {
|
||||||
|
assert stack.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
||||||
|
var stackStorage = stack.getCapability(ForgeCapabilities.ENERGY).resolve().get();
|
||||||
|
int stackMaxEnergy = stackStorage.getMaxEnergyStored();
|
||||||
|
int stackEnergy = stackStorage.getEnergyStored();
|
||||||
|
|
||||||
|
assert cell.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
||||||
|
var cellStorage = cell.getCapability(ForgeCapabilities.ENERGY).resolve().get();
|
||||||
|
int cellEnergy = cellStorage.getEnergyStored();
|
||||||
|
|
||||||
|
int stackEnergyNeed = Math.min(cellEnergy, stackMaxEnergy - stackEnergy);
|
||||||
|
|
||||||
|
if (cellEnergy > 0) {
|
||||||
|
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
|
iEnergyStorage -> iEnergyStorage.receiveEnergy(stackEnergyNeed, false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
cell.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
|
cEnergy -> cEnergy.extractEnergy(stackEnergyNeed, false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.getInt("sentinel_charge_time") == 1) {
|
if (tag.getInt("sentinel_charge_time") == 1) {
|
||||||
|
|
|
@ -302,6 +302,8 @@ public class LivingEventHandler {
|
||||||
ItemStack oldStack = event.getFrom();
|
ItemStack oldStack = event.getFrom();
|
||||||
ItemStack newStack = event.getTo();
|
ItemStack newStack = event.getTo();
|
||||||
|
|
||||||
|
player.getCapability(ModCapabilities.LASER_CAPABILITY).ifPresent(LaserCapability.ILaserCapability::stop);
|
||||||
|
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
if (player instanceof ServerPlayer serverPlayer) {
|
||||||
if (newStack.getItem() != oldStack.getItem()
|
if (newStack.getItem() != oldStack.getItem()
|
||||||
|| newStack.getTag() == null || oldStack.getTag() == null
|
|| newStack.getTag() == null || oldStack.getTag() == null
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class ModItems {
|
||||||
public static final RegistryObject<Item> SCHEELITE = ITEMS.register("scheelite", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> SCHEELITE = ITEMS.register("scheelite", () -> new Item(new Item.Properties()));
|
||||||
public static final RegistryObject<Item> RAW_SILVER = ITEMS.register("raw_silver", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> RAW_SILVER = ITEMS.register("raw_silver", () -> new Item(new Item.Properties()));
|
||||||
public static final RegistryObject<Item> DOG_TAG = ITEMS.register("dog_tag", DogTag::new);
|
public static final RegistryObject<Item> DOG_TAG = ITEMS.register("dog_tag", DogTag::new);
|
||||||
public static final RegistryObject<Item> SHIELD_CELL = ITEMS.register("shield_cell", () -> new Item(new Item.Properties().rarity(Rarity.RARE)));
|
public static final RegistryObject<Item> CELL = ITEMS.register("cell", Cell::new);
|
||||||
public static final RegistryObject<Item> TRANSCRIPT = ITEMS.register("transcript", Transcript::new);
|
public static final RegistryObject<Item> TRANSCRIPT = ITEMS.register("transcript", Transcript::new);
|
||||||
public static final RegistryObject<Item> FIRING_PARAMETERS = ITEMS.register("firing_parameters", FiringParameters::new);
|
public static final RegistryObject<Item> FIRING_PARAMETERS = ITEMS.register("firing_parameters", FiringParameters::new);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ModPerks {
|
||||||
public static final RegistryObject<Perk> FOURTH_TIMES_CHARM = FUNC_PERKS.register("fourth_times_charm", () -> new Perk("fourth_times_charm", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> FOURTH_TIMES_CHARM = FUNC_PERKS.register("fourth_times_charm", () -> new Perk("fourth_times_charm", Perk.Type.FUNCTIONAL));
|
||||||
public static final RegistryObject<Perk> SUBSISTENCE = FUNC_PERKS.register("subsistence", () -> new Perk("subsistence", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> SUBSISTENCE = FUNC_PERKS.register("subsistence", () -> new Perk("subsistence", Perk.Type.FUNCTIONAL));
|
||||||
public static final RegistryObject<Perk> FIELD_DOCTOR = FUNC_PERKS.register("field_doctor", () -> new Perk("field_doctor", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> FIELD_DOCTOR = FUNC_PERKS.register("field_doctor", () -> new Perk("field_doctor", Perk.Type.FUNCTIONAL));
|
||||||
public static final RegistryObject<Perk> SUPER_RECHARGE = FUNC_PERKS.register("super_recharge", () -> new Perk("super_recharge", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> REGENERATION = FUNC_PERKS.register("regeneration", () -> new Perk("regeneration", Perk.Type.FUNCTIONAL));
|
||||||
public static final RegistryObject<Perk> TURBO_CHARGER = FUNC_PERKS.register("turbo_charger", () -> new Perk("turbo_charger", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> TURBO_CHARGER = FUNC_PERKS.register("turbo_charger", () -> new Perk("turbo_charger", Perk.Type.FUNCTIONAL));
|
||||||
public static final RegistryObject<Perk> POWERFUL_ATTRACTION = FUNC_PERKS.register("powerful_attraction", () -> new Perk("powerful_attraction", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> POWERFUL_ATTRACTION = FUNC_PERKS.register("powerful_attraction", () -> new Perk("powerful_attraction", Perk.Type.FUNCTIONAL));
|
||||||
public static final RegistryObject<Perk> INTELLIGENT_CHIP = FUNC_PERKS.register("intelligent_chip", () -> new Perk("intelligent_chip", Perk.Type.FUNCTIONAL));
|
public static final RegistryObject<Perk> INTELLIGENT_CHIP = FUNC_PERKS.register("intelligent_chip", () -> new Perk("intelligent_chip", Perk.Type.FUNCTIONAL));
|
||||||
|
|
85
src/main/java/com/atsuishio/superbwarfare/item/Cell.java
Normal file
85
src/main/java/com/atsuishio/superbwarfare/item/Cell.java
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
package com.atsuishio.superbwarfare.item;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.capability.energy.ItemEnergyProvider;
|
||||||
|
import com.atsuishio.superbwarfare.client.tooltip.component.CellImageComponent;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class Cell extends Item {
|
||||||
|
|
||||||
|
public static final int MAX_ENERGY = 24000;
|
||||||
|
|
||||||
|
private final Supplier<Integer> energyCapacity;
|
||||||
|
|
||||||
|
public Cell() {
|
||||||
|
super(new Properties().stacksTo(1));
|
||||||
|
this.energyCapacity = () -> MAX_ENERGY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBarVisible(ItemStack pStack) {
|
||||||
|
if (!pStack.getCapability(ForgeCapabilities.ENERGY).isPresent()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AtomicInteger energy = new AtomicInteger(0);
|
||||||
|
pStack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
|
e -> energy.set(e.getEnergyStored())
|
||||||
|
);
|
||||||
|
return energy.get() != MAX_ENERGY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBarWidth(ItemStack pStack) {
|
||||||
|
AtomicInteger energy = new AtomicInteger(0);
|
||||||
|
pStack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
|
e -> energy.set(e.getEnergyStored())
|
||||||
|
);
|
||||||
|
|
||||||
|
return Math.round((float) energy.get() * 13.0F / MAX_ENERGY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag tag) {
|
||||||
|
return new ItemEnergyProvider(stack, energyCapacity.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBarColor(ItemStack pStack) {
|
||||||
|
return 0xFFFF00;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
|
super.inventoryTick(stack, world, entity, slot, selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static ItemStack getGunInstance() {
|
||||||
|
ItemStack stack = new ItemStack(ModItems.TASER.get());
|
||||||
|
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
|
energy -> energy.receiveEnergy(MAX_ENERGY, false)
|
||||||
|
);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Optional<TooltipComponent> getTooltipImage(@NotNull ItemStack pStack) {
|
||||||
|
return Optional.of(new CellImageComponent(pStack));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -60,7 +60,7 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
public SentinelItem() {
|
public SentinelItem() {
|
||||||
super(new Item.Properties().stacksTo(1).rarity(RarityTool.LEGENDARY));
|
super(new Item.Properties().stacksTo(1).rarity(RarityTool.LEGENDARY));
|
||||||
|
|
||||||
this.energyCapacity = () -> 240000;
|
this.energyCapacity = () -> 24000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,7 +83,7 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
e -> energy.set(e.getEnergyStored())
|
e -> energy.set(e.getEnergyStored())
|
||||||
);
|
);
|
||||||
|
|
||||||
return Math.round((float) energy.get() * 13.0F / 240000F);
|
return Math.round((float) energy.get() * 13.0F / 24000F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -185,7 +185,7 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
energy -> {
|
energy -> {
|
||||||
int energyStored = energy.getEnergyStored();
|
int energyStored = energy.getEnergyStored();
|
||||||
if (energyStored > 0) {
|
if (energyStored > 0) {
|
||||||
energy.extractEnergy(5, false);
|
energy.extractEnergy(1, false);
|
||||||
tag.putDouble("sentinelChargeDamage", 0.2857142857142857 * tag.getDouble("damage"));
|
tag.putDouble("sentinelChargeDamage", 0.2857142857142857 * tag.getDouble("damage"));
|
||||||
} else {
|
} else {
|
||||||
tag.putDouble("sentinelChargeDamage", 0);
|
tag.putDouble("sentinelChargeDamage", 0);
|
||||||
|
|
|
@ -54,7 +54,7 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
public class TaserItem extends GunItem implements GeoItem, AnimatedItem {
|
public class TaserItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
|
|
||||||
public static final int MAX_ENERGY = 12000;
|
public static final int MAX_ENERGY = 6000;
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
public static ItemDisplayContext transformType;
|
public static ItemDisplayContext transformType;
|
||||||
|
@ -186,10 +186,36 @@ public class TaserItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
stack.getOrCreateTag().putInt("max_ammo", getAmmoCount(player));
|
stack.getOrCreateTag().putInt("max_ammo", getAmmoCount(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.SUPER_RECHARGE.get(), stack);
|
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.REGENERATION.get(), stack);
|
||||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
energy -> energy.receiveEnergy(10 + 10 * perkLevel, false)
|
energy -> energy.receiveEnergy(perkLevel, false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (entity instanceof Player player) {
|
||||||
|
for (var cell : player.getInventory().items) {
|
||||||
|
if (cell.is(ModItems.CELL.get())) {
|
||||||
|
assert stack.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
||||||
|
var stackStorage = stack.getCapability(ForgeCapabilities.ENERGY).resolve().get();
|
||||||
|
int stackMaxEnergy = stackStorage.getMaxEnergyStored();
|
||||||
|
int stackEnergy = stackStorage.getEnergyStored();
|
||||||
|
|
||||||
|
assert cell.getCapability(ForgeCapabilities.ENERGY).resolve().isPresent();
|
||||||
|
var cellStorage = cell.getCapability(ForgeCapabilities.ENERGY).resolve().get();
|
||||||
|
int cellEnergy = cellStorage.getEnergyStored();
|
||||||
|
|
||||||
|
int stackEnergyNeed = Math.min(cellEnergy, stackMaxEnergy - stackEnergy);
|
||||||
|
|
||||||
|
if (cellEnergy > 0) {
|
||||||
|
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
|
iEnergyStorage -> iEnergyStorage.receiveEnergy(stackEnergyNeed, false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
cell.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
|
cEnergy -> cEnergy.extractEnergy(stackEnergyNeed, false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean check(ItemStack stack) {
|
protected static boolean check(ItemStack stack) {
|
||||||
|
@ -223,7 +249,7 @@ public class TaserItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
public boolean canApplyPerk(Perk perk) {
|
public boolean canApplyPerk(Perk perk) {
|
||||||
return switch (perk.type) {
|
return switch (perk.type) {
|
||||||
case AMMO -> perk == ModPerks.LONGER_WIRE.get();
|
case AMMO -> perk == ModPerks.LONGER_WIRE.get();
|
||||||
case FUNCTIONAL -> perk == ModPerks.SUPER_RECHARGE.get() || perk == ModPerks.POWERFUL_ATTRACTION.get() || perk == ModPerks.INTELLIGENT_CHIP.get();
|
case FUNCTIONAL -> perk == ModPerks.REGENERATION.get() || perk == ModPerks.POWERFUL_ATTRACTION.get() || perk == ModPerks.INTELLIGENT_CHIP.get();
|
||||||
case DAMAGE -> perk == ModPerks.VOLT_OVERLOAD.get();
|
case DAMAGE -> perk == ModPerks.VOLT_OVERLOAD.get();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,7 @@ public class FireMessage {
|
||||||
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.VOLT_OVERLOAD.get(), stack);
|
int perkLevel = PerkHelper.getItemPerkLevel(ModPerks.VOLT_OVERLOAD.get(), stack);
|
||||||
AtomicBoolean flag = new AtomicBoolean(false);
|
AtomicBoolean flag = new AtomicBoolean(false);
|
||||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
iEnergyStorage -> flag.set(iEnergyStorage.getEnergyStored() > 2000 + 200 * perkLevel)
|
iEnergyStorage -> flag.set(iEnergyStorage.getEnergyStored() >= 400 + 100 * perkLevel)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getInt("ammo") > 0
|
if (!player.getCooldowns().isOnCooldown(stack.getItem()) && stack.getOrCreateTag().getInt("ammo") > 0
|
||||||
|
@ -351,7 +351,7 @@ public class FireMessage {
|
||||||
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
|
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
|
||||||
|
|
||||||
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
stack.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
energy -> energy.extractEnergy(2000 + 200 * perkLevel, false)
|
energy -> energy.extractEnergy(400 + 100 * perkLevel, false)
|
||||||
);
|
);
|
||||||
|
|
||||||
stack.getOrCreateTag().putBoolean("shoot", true);
|
stack.getOrCreateTag().putBoolean("shoot", true);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.atsuishio.superbwarfare.network.message;
|
package com.atsuishio.superbwarfare.network.message;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.tools.GunsTool;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -14,8 +14,10 @@ import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class FireModeMessage {
|
public class FireModeMessage {
|
||||||
|
@ -104,15 +106,18 @@ public class FireModeMessage {
|
||||||
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
&& GunsTool.getGunIntTag(stack, "ReloadTime") == 0
|
||||||
&& !stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
|
&& !stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
|
||||||
|
|
||||||
int count = 0;
|
for (var cell : player.getInventory().items) {
|
||||||
for (var inv : player.getInventory().items) {
|
if (cell.is(ModItems.CELL.get())) {
|
||||||
if (inv.is(ModItems.SHIELD_CELL.get())) {
|
AtomicBoolean flag = new AtomicBoolean(false);
|
||||||
count++;
|
cell.getCapability(ForgeCapabilities.ENERGY).ifPresent(
|
||||||
}
|
iEnergyStorage -> flag.set(iEnergyStorage.getEnergyStored() >= 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (flag.get()) {
|
||||||
|
tag.putBoolean("start_sentinel_charge", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > 0) {
|
}
|
||||||
tag.putBoolean("start_sentinel_charge", true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class TraceTool {
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
Vec3 viewVec = player.getViewVector(1.0F);
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
||||||
AABB aabb = player.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
AABB aabb = player.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, p -> !p.isSpectator(), distance);
|
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, p -> !p.isSpectator() && p.isAlive(), distance);
|
||||||
if (entityhitresult != null) {
|
if (entityhitresult != null) {
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
Vec3 targetPos = entityhitresult.getLocation();
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
||||||
|
|
|
@ -178,7 +178,7 @@
|
||||||
"item.superbwarfare.cannon_core": "Cannon Core",
|
"item.superbwarfare.cannon_core": "Cannon Core",
|
||||||
"item.superbwarfare.dog_tag": "Dog Tag",
|
"item.superbwarfare.dog_tag": "Dog Tag",
|
||||||
"curios.identifier.dog_tag": "Dog Tag",
|
"curios.identifier.dog_tag": "Dog Tag",
|
||||||
"item.superbwarfare.shield_cell": "Cell",
|
"item.superbwarfare.cell": "Cell",
|
||||||
"item.superbwarfare.drone": "Drone",
|
"item.superbwarfare.drone": "Drone",
|
||||||
"item.superbwarfare.monitor": "Monitor",
|
"item.superbwarfare.monitor": "Monitor",
|
||||||
"item.superbwarfare.propeller": "Propeller",
|
"item.superbwarfare.propeller": "Propeller",
|
||||||
|
@ -271,14 +271,14 @@
|
||||||
"des.superbwarfare.subsistence": "Defeating targets partially reloads the magazine from reserves",
|
"des.superbwarfare.subsistence": "Defeating targets partially reloads the magazine from reserves",
|
||||||
"item.superbwarfare.field_doctor": "Field Doctor",
|
"item.superbwarfare.field_doctor": "Field Doctor",
|
||||||
"des.superbwarfare.field_doctor": "Bullets can heal teammate when shooting without the scope",
|
"des.superbwarfare.field_doctor": "Bullets can heal teammate when shooting without the scope",
|
||||||
"item.superbwarfare.super_recharge": "Super Recharge",
|
"item.superbwarfare.regeneration": "Regeneration",
|
||||||
"des.superbwarfare.super_recharge": "Increases the recharge speed of Taser Gun",
|
"des.superbwarfare.regeneration": "泰瑟枪会缓慢自动回复能量",
|
||||||
"item.superbwarfare.turbo_charger": "Turbocharger",
|
"item.superbwarfare.turbo_charger": "Turbocharger",
|
||||||
"des.superbwarfare.turbo_charger": "Reduces auto fire spin-up time for compatible weapons",
|
"des.superbwarfare.turbo_charger": "Reduces auto fire spin-up time for compatible weapons",
|
||||||
"item.superbwarfare.powerful_attraction": "Powerful Attraction",
|
"item.superbwarfare.powerful_attraction": "Powerful Attraction",
|
||||||
"des.superbwarfare.powerful_attraction": "Transfer items and experience dropped by killed targets to your inventory",
|
"des.superbwarfare.powerful_attraction": "Transfer items and experience dropped by killed targets to your inventory",
|
||||||
"item.superbwarfare.intelligent_chip": "Intelligent Chip",
|
"item.superbwarfare.intelligent_chip": "Intelligent Chip",
|
||||||
"des.superbwarfare.intelligent_chip": "自动瞄准敌人(请勿在PVP环境下使用此模组)",
|
"des.superbwarfare.intelligent_chip": "自动瞄准敌人(请勿在PVP使用此模组)",
|
||||||
|
|
||||||
"item.superbwarfare.kill_clip": "Kill Clip",
|
"item.superbwarfare.kill_clip": "Kill Clip",
|
||||||
"des.superbwarfare.kill_clip": "Increases the damage of weapon after dealing a final blow",
|
"des.superbwarfare.kill_clip": "Increases the damage of weapon after dealing a final blow",
|
||||||
|
|
|
@ -178,7 +178,7 @@
|
||||||
"item.superbwarfare.cannon_core": "火炮核心",
|
"item.superbwarfare.cannon_core": "火炮核心",
|
||||||
"item.superbwarfare.dog_tag": "狗牌",
|
"item.superbwarfare.dog_tag": "狗牌",
|
||||||
"curios.identifier.dog_tag": "狗牌",
|
"curios.identifier.dog_tag": "狗牌",
|
||||||
"item.superbwarfare.shield_cell": "电池",
|
"item.superbwarfare.cell": "电池",
|
||||||
"item.superbwarfare.drone": "无人机",
|
"item.superbwarfare.drone": "无人机",
|
||||||
"item.superbwarfare.monitor": "遥控器",
|
"item.superbwarfare.monitor": "遥控器",
|
||||||
"item.superbwarfare.propeller": "螺旋桨",
|
"item.superbwarfare.propeller": "螺旋桨",
|
||||||
|
@ -271,14 +271,14 @@
|
||||||
"des.superbwarfare.subsistence": "消灭目标会使弹药从备弹中转移并填装部分弹匣",
|
"des.superbwarfare.subsistence": "消灭目标会使弹药从备弹中转移并填装部分弹匣",
|
||||||
"item.superbwarfare.field_doctor": "役医师",
|
"item.superbwarfare.field_doctor": "役医师",
|
||||||
"des.superbwarfare.field_doctor": "腰射时发射的子弹可以治疗队友",
|
"des.superbwarfare.field_doctor": "腰射时发射的子弹可以治疗队友",
|
||||||
"item.superbwarfare.super_recharge": "超级快充",
|
"item.superbwarfare.regeneration": "再生",
|
||||||
"des.superbwarfare.super_recharge": "增加泰瑟枪充能的速度",
|
"des.superbwarfare.regeneration": "泰瑟枪会缓慢自动回复能量",
|
||||||
"item.superbwarfare.turbo_charger": "涡轮增压器",
|
"item.superbwarfare.turbo_charger": "涡轮增压器",
|
||||||
"des.superbwarfare.turbo_charger": "装配后减少武器自动射击所需的缓冲时间",
|
"des.superbwarfare.turbo_charger": "装配后减少武器自动射击所需的缓冲时间",
|
||||||
"item.superbwarfare.powerful_attraction": "强力吸引",
|
"item.superbwarfare.powerful_attraction": "强力吸引",
|
||||||
"des.superbwarfare.powerful_attraction": "击杀目标后掉落的物品和经验会直接转移到自身",
|
"des.superbwarfare.powerful_attraction": "击杀目标后掉落的物品和经验会直接转移到自身",
|
||||||
"item.superbwarfare.intelligent_chip": "智慧芯片",
|
"item.superbwarfare.intelligent_chip": "智慧芯片",
|
||||||
"des.superbwarfare.intelligent_chip": "自动瞄准敌人(请勿在PVP环境下使用此模组)",
|
"des.superbwarfare.intelligent_chip": "自动瞄准敌人(请勿在PVP使用此模组)",
|
||||||
|
|
||||||
"item.superbwarfare.kill_clip": "杀戮弹匣",
|
"item.superbwarfare.kill_clip": "杀戮弹匣",
|
||||||
"des.superbwarfare.kill_clip": "完成击杀后填装可提升武器伤害",
|
"des.superbwarfare.kill_clip": "完成击杀后填装可提升武器伤害",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"credit": "Made with Blockbench",
|
"credit": "Made with Blockbench",
|
||||||
"texture_size": [32, 32],
|
"texture_size": [32, 32],
|
||||||
"textures": {
|
"textures": {
|
||||||
"1": "superbwarfare:item/shield_cell"
|
"1": "superbwarfare:item/cell"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "superbwarfare:item/perk/regeneration"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "item/generated",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "superbwarfare:item/perk/super_recharge"
|
|
||||||
}
|
|
||||||
}
|
|
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 830 B |
Loading…
Add table
Reference in a new issue