Skip to content

Commit

Permalink
Merge branch 'master' into mc/1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Oct 20, 2023
2 parents 2ad2ff2 + ae2fe60 commit 5507a0f
Show file tree
Hide file tree
Showing 13 changed files with 211 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"item.mininggadgets.upgrade_battery_1": "Upgrade: Battery, Tier 1",
"item.mininggadgets.upgrade_battery_2": "Upgrade: Battery, Tier 2",
"item.mininggadgets.upgrade_battery_3": "Upgrade: Battery, Tier 3",
"item.mininggadgets.upgrade_battery_creative": "Upgrade: Battery, Creative",
"item.mininggadgets.upgrade_efficiency_1": "Upgrade: Efficiency, Tier 1",
"item.mininggadgets.upgrade_efficiency_2": "Upgrade: Efficiency, Tier 2",
"item.mininggadgets.upgrade_efficiency_3": "Upgrade: Efficiency, Tier 3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "mininggadgets:item/upgrade_battery_creative"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ public static boolean insertButton(ModificationTableContainer container, ItemSta
// Did we just insert a battery upgrade?
if(card.getBaseName().equals(Upgrade.BATTERY_1.getBaseName())) {
UpgradeBatteryLevels.getBatteryByLevel(card.getTier()).ifPresent(power -> {
laser.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> ((EnergisedItem) e).updatedMaxEnergy(power.getPower()));
laser.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> {
((EnergisedItem) e).updatedMaxEnergy(power.getPower());
if (card.getTier() == Upgrade.BATTERY_CREATIVE.getTier()) {
e.receiveEnergy(e.getMaxEnergyStored() - e.getEnergyStored(), false);
}
});
});
MiningProperties.setBatteryTier(laser, card.getTier());
}

return true;
Expand Down Expand Up @@ -98,8 +104,10 @@ public static void extractButton(ModificationTableContainer container, ServerPla
MiningProperties.setBeamMaxRange(laser, UpgradeTools.getMaxBeamRange(0));
}

if (upgrade.getBaseName().equals(Upgrade.BATTERY_1.getBaseName()))
if (upgrade.getBaseName().equals(Upgrade.BATTERY_1.getBaseName())) {
MiningProperties.setBatteryTier(laser, 0);
laser.getCapability(ForgeCapabilities.ENERGY).ifPresent(e -> ((EnergisedItem) e).updatedMaxEnergy(UpgradeBatteryLevels.BATTERY.getPower()));
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected void addTranslations() {
addItem(ModItems.BATTERY_1, "Upgrade: Battery, Tier 1");
addItem(ModItems.BATTERY_2, "Upgrade: Battery, Tier 2");
addItem(ModItems.BATTERY_3, "Upgrade: Battery, Tier 3");
addItem(ModItems.BATTERY_CREATIVE, "Upgrade: Creative Battery");

// Upgrade tooltips :D
add("tooltop.mininggadgets.empty", "Used to craft other upgrades");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private static int getMaxCapacity(ItemStack stack, int capacity) {
public void updatedMaxEnergy(int max) {
stack.getOrCreateTag().putInt("max_energy", max);
this.capacity = max;
this.energy = Math.min(max, this.energy);

// Ensure the current stored energy is up to date with the new max.
this.receiveEnergy(1, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public int getMaxDamage(ItemStack stack) {

@Override
public boolean isBarVisible(ItemStack stack) {
if (MiningProperties.getBatteryTier(stack) == Upgrade.BATTERY_CREATIVE.getTier())
return false;

IEnergyStorage energy = stack.getCapability(ForgeCapabilities.ENERGY, null).orElse(null);
return (energy.getEnergyStored() < energy.getMaxEnergyStored());
}
Expand All @@ -111,13 +114,19 @@ public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundT

@Override
public int getBarWidth(ItemStack stack) {
if (MiningProperties.getBatteryTier(stack) == Upgrade.BATTERY_CREATIVE.getTier())
return 13;

return stack.getCapability(ForgeCapabilities.ENERGY, null)
.map(e -> Math.min(13 * e.getEnergyStored() / e.getMaxEnergyStored(), 13))
.orElse(0);
}

@Override
public int getBarColor(ItemStack stack) {
if (MiningProperties.getBatteryTier(stack) == Upgrade.BATTERY_CREATIVE.getTier())
return Mth.color(0, 1, 0);

return stack.getCapability(ForgeCapabilities.ENERGY)
.map(e -> Mth.hsvToRgb(Math.max(0.0F, (float) e.getEnergyStored() / (float) e.getMaxEnergyStored()) / 3.0F, 1.0F, 1.0F))
.orElse(super.getBarColor(stack));
Expand Down Expand Up @@ -189,6 +198,9 @@ public static void changeRange(ItemStack tool) {
}

public static boolean canMine(ItemStack tool) {
if (MiningProperties.getBatteryTier(tool) == Upgrade.BATTERY_CREATIVE.getTier())
return true;

IEnergyStorage energy = tool.getCapability(ForgeCapabilities.ENERGY, null).orElse(null);
int cost = getEnergyCost(tool);

Expand Down Expand Up @@ -503,6 +515,9 @@ else if (g > 0 && b == 1)
}

public static int getEnergyCost(ItemStack stack) {
if (MiningProperties.getBatteryTier(stack) == Upgrade.BATTERY_CREATIVE.getTier())
return 0;

int cost = Config.MININGGADGET_BASECOST.get();
List<Upgrade> upgrades = UpgradeTools.getActiveUpgrades(stack);
if (upgrades.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class ModItems {
public static final RegistryObject<Item> BATTERY_1 = UPGRADE_ITEMS.register("upgrade_battery_1", () -> new UpgradeCard(Upgrade.BATTERY_1));
public static final RegistryObject<Item> BATTERY_2 = UPGRADE_ITEMS.register("upgrade_battery_2", () -> new UpgradeCard(Upgrade.BATTERY_2));
public static final RegistryObject<Item> BATTERY_3 = UPGRADE_ITEMS.register("upgrade_battery_3", () -> new UpgradeCard(Upgrade.BATTERY_3));
public static final RegistryObject<Item> BATTERY_CREATIVE = UPGRADE_ITEMS.register("upgrade_battery_creative", () -> new UpgradeCard(Upgrade.BATTERY_CREATIVE));
public static final RegistryObject<Item> EFFICIENCY_1 = UPGRADE_ITEMS.register("upgrade_efficiency_1", () -> new UpgradeCard(Upgrade.EFFICIENCY_1));
public static final RegistryObject<Item> EFFICIENCY_2 = UPGRADE_ITEMS.register("upgrade_efficiency_2", () -> new UpgradeCard(Upgrade.EFFICIENCY_2));
public static final RegistryObject<Item> EFFICIENCY_3 = UPGRADE_ITEMS.register("upgrade_efficiency_3", () -> new UpgradeCard(Upgrade.EFFICIENCY_3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private MiningProperties() {}
private static final String PRECISION_MODE = "precisionMode";
private static final String VOLUME = "volume";
private static final String FREEZE_PARTICLE_DELAY = "freeze_particle_delay";
private static final String KEY_BATTERY_TIER = "battery_tier";

public static final String KEY_FILTERS = "filters";
public static final String COLOR_RED = "colorRed";
Expand Down Expand Up @@ -220,6 +221,16 @@ public static int getFreezeDelay(ItemStack gadget) {
return !compound.contains(FREEZE_PARTICLE_DELAY) ? setFreezeDelay(gadget, 0) : compound.getInt(FREEZE_PARTICLE_DELAY);
}

public static int setBatteryTier(ItemStack gadget, int tier) {
gadget.getOrCreateTag().putInt(KEY_BATTERY_TIER, tier);
return tier;
}

public static int getBatteryTier(ItemStack gadget) {
CompoundTag compound = gadget.getOrCreateTag();
return !compound.contains(KEY_BATTERY_TIER) ? setBatteryTier(gadget, 0) : compound.getInt(KEY_BATTERY_TIER);
}

/**
* So this is a bit fun, because we only need the items in our list we're ditching half the data
* that the `Items` actually contains.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public enum Upgrade {
BATTERY_1("battery_1", ModItems.BATTERY_1, 1, () -> 0),
BATTERY_2("battery_2", ModItems.BATTERY_2, 2, () -> 0),
BATTERY_3("battery_3", ModItems.BATTERY_3, 3, () -> 0),
BATTERY_CREATIVE("battery_CREATIVE", ModItems.BATTERY_CREATIVE, 4, () -> 0),

RANGE_1("range_1", ModItems.RANGE_1, 1, () -> 0),
RANGE_2("range_2", ModItems.RANGE_2, 2, () -> 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public enum UpgradeBatteryLevels {
BATTERY(0, Config.MININGGADGET_MAXPOWER.get()),
BATTERY_1(1, Config.UPGRADECOST_BATTERY1.get()),
BATTERY_2(2, Config.UPGRADECOST_BATTERY2.get()),
BATTERY_3(3, Config.UPGRADECOST_BATTERY3.get());
BATTERY_3(3, Config.UPGRADECOST_BATTERY3.get()),
BATTERY_CREATIVE(4, Integer.MAX_VALUE);

private int level;
private int power;
Expand Down
81 changes: 81 additions & 0 deletions src/main/resources/assets/mininggadgets/lang/fr_fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"block.mininggadgets.minerslight": "Lumière de mineur",
"block.mininggadgets.modificationtable": "Tableau des modifications",
"block.mininggadgets.renderblock": "Bloc de rendu (ne pas utiliser)",
"block.mininggadgets.renderblock.name": "Peu importe ce qu'il veut être !",
"item.mininggadgets.mininggadget": "Gadget minier MK3",
"item.mininggadgets.mininggadget_fancy": "Gadget minier MK2",
"item.mininggadgets.mininggadget_simple": "Gadget minier MK1",
"item.mininggadgets.upgrade_battery_1": "Mise à niveau : Batterie, Niveau 1",
"item.mininggadgets.upgrade_battery_2": "Mise à niveau : Batterie, Niveau 2",
"item.mininggadgets.upgrade_battery_3": "Mise à niveau : Batterie, Niveau 3",
"item.mininggadgets.upgrade_efficiency_1": "Mise à niveau : Efficacité, Niveau 1",
"item.mininggadgets.upgrade_efficiency_2": "Mise à niveau : Efficacité, Niveau 2",
"item.mininggadgets.upgrade_efficiency_3": "Mise à niveau : Efficacité, Niveau 3",
"item.mininggadgets.upgrade_efficiency_4": "Mise à niveau : Efficacité, Niveau 4",
"item.mininggadgets.upgrade_efficiency_5": "Mise à niveau : Efficacité, Niveau 5",
"item.mininggadgets.upgrade_empty": "Module de mise à niveau vierge",
"item.mininggadgets.upgrade_fortune_1": "Mise à niveau : Fortune, Niveau 1",
"item.mininggadgets.upgrade_fortune_2": "Mise à niveau : Fortune, Niveau 2",
"item.mininggadgets.upgrade_fortune_3": "Mise à niveau : Fortune, Niveau 3",
"item.mininggadgets.upgrade_freezing": "Mise à niveau : Geler",
"item.mininggadgets.upgrade_light_placer": "Mise à niveau : Placeur de lumière",
"item.mininggadgets.upgrade_magnet": "Mise à niveau : Aimant",
"item.mininggadgets.upgrade_range_1": "Mise à niveau : Portée, Niveau 1",
"item.mininggadgets.upgrade_range_2": "Mise à niveau : Portée, Niveau 2",
"item.mininggadgets.upgrade_range_3": "Mise à niveau : Portée, Niveau 3",
"item.mininggadgets.upgrade_silk": "Mise à niveau : Toucher de soie",
"item.mininggadgets.upgrade_three_by_three": "Mise à niveau : 3x3",
"item.mininggadgets.upgrade_void_junk": "Mise à niveau : Poubelle du vide",
"itemGroup.mininggadgets": "Gadgets miniers",
"mininggadgets.gadget.energy": "Énergie : %d/%d",
"mininggadgets.gadget.range_change": "Changement de portée: %1$d x %1$d",
"mininggadgets.text.empty_table_helper": "Maj-cliquez pour insérer à partir de vos emplacements\nou déposez la mise à niveau sur cet écran.\on\onCliquez sur la mise à niveau pour supprimer.",
"mininggadgets.text.modification_table": "Tableau des modifications",
"mininggadgets.text.open_gui": "Ouvrir les paramètres du gadget minier",
"mininggadgets.tooltip.item.battery_boost": "Boost de batterie : %1$d",
"mininggadgets.tooltip.item.break_cost": "Coût par bloc : %1$d",
"mininggadgets.tooltip.item.show_upgrades": "Maintenez Maj pour afficher les mises à niveau",
"mininggadgets.tooltip.item.upgrade_cost": "Coût de mise à niveau : %1$d",
"mininggadgets.tooltip.item.upgrades": "Mises à niveau actuelles :",
"mininggadgets.tooltip.item.use_cost": "+%1$d FE par utilisation",
"mininggadgets.tooltip.screen.beam_preview": "Aperçu du faisceau",
"mininggadgets.tooltip.screen.blacklist": "Liste noire active",
"mininggadgets.tooltip.screen.block_break_style": "Style de rupture",
"mininggadgets.tooltip.screen.blue": "Bleu",
"mininggadgets.tooltip.screen.delay_explain": "Contrôle la fréquence à laquelle une particule de gel est générée\npar défaut, il s'agit d'une particule à chaque tick, pour réduire\nla quantité de particules, ajouter plus de retard.",
"mininggadgets.tooltip.screen.edit_filters": "Modifier les filtres",
"mininggadgets.tooltip.screen.fade": "Fondu du bloc",
"mininggadgets.tooltip.screen.freeze_delay": "Délai de gel",
"mininggadgets.tooltip.screen.green": "Vert",
"mininggadgets.tooltip.screen.inner_color": "Couleur du faisceau intérieur",
"mininggadgets.tooltip.screen.mining_gadget": "Paramètres des gadgets",
"mininggadgets.tooltip.screen.no_upgrades": "Aucune mise à niveau disponible",
"mininggadgets.tooltip.screen.outer_color": "Couleur de lueur extérieure",
"mininggadgets.tooltip.screen.precision_mode": "Mode Précision : %1$d",
"mininggadgets.tooltip.screen.range": "Portée ",
"mininggadgets.tooltip.screen.red": "Rouge",
"mininggadgets.tooltip.screen.shrink": "Réduit les blocs",
"mininggadgets.tooltip.screen.size": "Taille : %1$d x %1$d",
"mininggadgets.tooltip.screen.ticks": "ticks",
"mininggadgets.tooltip.screen.toggle_upgrades": "Basculer les mises à niveau",
"mininggadgets.tooltip.screen.visual_settings": "Paramètres visuels",
"mininggadgets.tooltip.screen.visuals_menu": "Modifier les visuels",
"mininggadgets.tooltip.screen.volume": "Volume",
"mininggadgets.tooltip.screen.whitelist": "Liste blanche active",
"mininggadgets.tooltip.single.filters": "Filtres",
"mininggadgets.tooltip.single.insert": "Insérer",
"mininggadgets.upgrade.replacement": "Mise à niveau : ",
"tooltop.mininggadgets.battery": "Améliore les condensateurs internes",
"tooltop.mininggadgets.efficiency": "Applique efficacité au gadget minier",
"tooltop.mininggadgets.empty": "Utilisé pour fabriquer d'autres améliorations",
"tooltop.mininggadgets.fortune": "Applique fortune au gadget minier",
"tooltop.mininggadgets.freezing": "Gèle l'eau et arrête la lave place !",
"tooltop.mininggadgets.light_placer": "Place des torches chaque fois que le niveau d'éclairage environnant est inférieur à 8",
"tooltop.mininggadgets.magnet": "Déconstruit les blocs directement dans votre inventaire",
"tooltop.mininggadgets.paver": "Crée un chemin pour vous pendant que vous minez",
"tooltop.mininggadgets.range": "Prolonge votre portée de 5 fois avec chaque niveau",
"tooltop.mininggadgets.silk": "Applique l'enchantement toucher soie au gadget minier",
"tooltop.mininggadgets.three_by_three": "Permet un rayon minier de 3x3",
"tooltop.mininggadgets.void_junk": "Désintègre les blocs ! (ajoute également un filtrage)"
}
Loading

0 comments on commit 5507a0f

Please sign in to comment.