Skip to content

Commit

Permalink
Fix item components saving invalid values (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swedz authored Dec 29, 2024
1 parent 2adda69 commit 42255fa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public class ElectricArmorItem extends ArmorItem implements ISimpleEnergyItem, I
public ElectricArmorItem(Holder<ArmorMaterial> material, Type type, Properties properties,
long energyCapacity, long damageCostEnergy)
{
super(material, type, properties.stacksTo(1));
super(material, type, properties
.stacksTo(1)
.component(EIComponents.HIDE_BAR, false)
.component(MIComponents.ENERGY, 0L));
this.energyCapacity = energyCapacity;
this.damageCostEnergy = damageCostEnergy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ public boolean canDo3by3()

public ElectricToolItem(Properties properties, Type toolType)
{
super(properties.stacksTo(1).rarity(Rarity.UNCOMMON));
super(properties
.stacksTo(1)
.rarity(Rarity.UNCOMMON)
.component(EIComponents.HIDE_BAR, false)
.component(EIComponents.ELECTRIC_TOOL_SPEED, SPEED_MAX)
.component(MIComponents.SILK_TOUCH, false)
.component(MIComponents.ENERGY, 0L));
this.toolType = toolType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public final class PhotovoltaicCellItem extends Item

public PhotovoltaicCellItem(Properties properties, CableTier tier, int euPerTick, int durationTicks)
{
super(properties.stacksTo(1).durability(0));
super(properties
.stacksTo(1)
.durability(0)
.component(EIComponents.SOLAR_TICKS, 0));
this.tier = tier;
this.euPerTick = euPerTick;
this.durationTicks = durationTicks;
Expand Down Expand Up @@ -101,7 +104,7 @@ else if(time > 8000)
{
efficiency = (-1f / 16000000f) * time * time + (1f / 1000f) * time - 3f;
}
energyProduced += (euPerTick * efficiency);
energyProduced += (int) (euPerTick * efficiency);
}
return energyProduced;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ public boolean canInsert(ItemVariant item)

public SteamChainsawItem(Item.Properties settings)
{
super(settings.stacksTo(1).rarity(Rarity.UNCOMMON));
super(settings
.stacksTo(1)
.rarity(Rarity.UNCOMMON)
.component(MIComponents.SILK_TOUCH, true)
.component(MIComponents.STEAM_DRILL_FUEL, SteamDrillFuel.EMPTY)
.component(MIComponents.WATER, 0));
}

private static boolean isNotSilkTouch(ItemStack stack)
Expand Down

0 comments on commit 42255fa

Please sign in to comment.