Skip to content

Commit ab6ae7d

Browse files
committed
add client side check for all tool effects and armor effects. Attempt reenabling speed
1 parent ec6a562 commit ab6ae7d

21 files changed

+187
-241
lines changed

common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/GenerationsArmor.kt

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import generations.gg.generations.core.generationscore.common.GenerationsCore
66
import generations.gg.generations.core.generationscore.common.world.item.armor.ArmorEffect
77
import generations.gg.generations.core.generationscore.common.world.item.armor.GenerationsArmorItem
88
import generations.gg.generations.core.generationscore.common.world.item.armor.GenerationsArmorMaterials
9-
import generations.gg.generations.core.generationscore.common.world.item.armor.effects.DoubleSpeedArmorEffect
109
import generations.gg.generations.core.generationscore.common.world.item.armor.effects.EnchantmentArmorEffect
1110
import generations.gg.generations.core.generationscore.common.world.item.armor.effects.PotionArmorEffect
1211
import generations.gg.generations.core.generationscore.common.world.item.armor.effects.SpeedModifier
@@ -49,71 +48,71 @@ object GenerationsArmor {
4948
}
5049

5150
val AETHER: ArmorSet = ArmorSet.create("aether", GenerationsArmorMaterials.AETHER) {
52-
speed(0.5f)
51+
speed(0.5)
5352
}
5453

5554
val AQUA: ArmorSet = ArmorSet.create("aqua", GenerationsArmorMaterials.AQUA)
5655
val FLARE: ArmorSet = ArmorSet.create("flare", GenerationsArmorMaterials.FLARE)
5756
val GALACTIC: ArmorSet = ArmorSet.create("galactic", GenerationsArmorMaterials.GALACTIC) {
58-
speed(0.5f)
57+
speed(0.5)
5958
}
6059
val ULTRITE: ArmorSet = ArmorSet.create("ultrite", GenerationsArmorMaterials.ULTRITE)
6160
val MAGMA: ArmorSet = ArmorSet.create("magma", GenerationsArmorMaterials.MAGMA)
6261
val NEO_PLASMA: ArmorSet = ArmorSet.create("neo_plasma", GenerationsArmorMaterials.NEO_PLASMA)
6362
val PLASMA: ArmorSet = ArmorSet.create("plasma", GenerationsArmorMaterials.PLASMA)
6463
val ROCKET: ArmorSet = ArmorSet.create("rocket", GenerationsArmorMaterials.ROCKET)
6564
val SKULL: ArmorSet = ArmorSet.create("skull", GenerationsArmorMaterials.SKULL) {
66-
speed(0.5f)
65+
speed(0.5)
6766
}
6867
val ULTRA: ArmorSet = ArmorSet.create("ultra", GenerationsArmorMaterials.ULTRA) {
6968
potion(MobEffects.MOVEMENT_SPEED, 1)
70-
speed(0.25f)
69+
speed(0.25)
7170
}
7271
val CRYSTALLIZED: ArmorSet = ArmorSet.create("crystallized", GenerationsArmorMaterials.CRYSTAL) {
7372
potion(MobEffects.MOVEMENT_SPEED, 1)
74-
speed(0.1f)
73+
speed(0.1)
7574
}
7675
val DAWN_STONE: ArmorSet = ArmorSet.create("dawn_stone", GenerationsArmorMaterials.DAWN_STONE) {
7776
potion(MobEffects.JUMP, 3)
78-
speed(0.5f)
77+
speed(0.5)
7978
}
8079
val DUSK_STONE: ArmorSet = ArmorSet.create("dusk_stone", GenerationsArmorMaterials.DUSK_STONE) {
8180
potion(MobEffects.SATURATION, 4)
82-
speed(0.5f)
81+
speed(0.5)
8382
}
8483
val FIRE_STONE: ArmorSet = ArmorSet.create("fire_stone", GenerationsArmorMaterials.FIRE_STONE) {
8584
enchantment(Enchantments.FIRE_PROTECTION, 2)
8685
potion(MobEffects.FIRE_RESISTANCE, 1)
87-
speed(0.5f)
86+
speed(0.5)
8887
}
8988

9089
val LEAF_STONE: ArmorSet = ArmorSet.create("leaf_stone", GenerationsArmorMaterials.LEAF_STONE) {
9190
enchantment(Enchantments.FEATHER_FALLING, 3)
9291
enchantment(Enchantments.THORNS, 3)
93-
speed(0.5f)
92+
speed(0.5)
9493
}
9594
val ICE_STONE: ArmorSet = ArmorSet.create("ice_stone", GenerationsArmorMaterials.ICE_STONE) {
9695
enchantment(Enchantments.FROST_WALKER, 2)
97-
speed(0.5f)
96+
speed(0.5)
9897
}
9998
val MOON_STONE: ArmorSet = ArmorSet.create("moon_stone", GenerationsArmorMaterials.MOON_STONE) {
10099
enchantment(Enchantments.PROTECTION, 4)
101100
enchantment(Enchantments.PROJECTILE_PROTECTION, 4)
102-
speed(0.5f)
101+
speed(0.5)
103102
}
104103
val SUN_STONE: ArmorSet = ArmorSet.create("sun_stone", GenerationsArmorMaterials.SUN_STONE) {
105104
enchantment(Enchantments.PROTECTION, 4)
106105
enchantment(Enchantments.PROJECTILE_PROTECTION, 4)
107-
speed(0.5f)
106+
speed(0.5)
108107
}
109108
val THUNDER_STONE: ArmorSet = ArmorSet.create("thunder_stone", GenerationsArmorMaterials.THUNDER_STONE) {
110109
potion(MobEffects.DIG_SPEED, 1)
111-
speed(0.5f)
110+
speed(0.5)
112111
}
113112
val WATER_STONE: ArmorSet = ArmorSet.create("water_stone", GenerationsArmorMaterials.WATER_STONE) {
114113
potion(MobEffects.WATER_BREATHING, 1)
115114
enchantment(Enchantments.AQUA_AFFINITY, 2)
116-
speed(0.5f)
115+
speed(0.5)
117116
}
118117

119118
fun of(): Item.Properties {
@@ -156,13 +155,8 @@ object GenerationsArmor {
156155
return this
157156
}
158157

159-
fun speed(speed: Float): Builder {
160-
return speed(speed, false)
161-
}
162-
163-
fun speed(speed: Float, doubleWhenFullSet: Boolean): Builder {
164-
effects.add(SpeedModifier(speed))
165-
if (doubleWhenFullSet) effects.add(DoubleSpeedArmorEffect())
158+
fun speed(speed: Double, speedWhenFull: Double = speed): Builder {
159+
effects.add(SpeedModifier(speed, speedWhenFull))
166160
return this
167161
}
168162

@@ -172,6 +166,8 @@ object GenerationsArmor {
172166
}
173167

174168
companion object {
169+
val MATERIAL_TO_SET = mutableMapOf<Holder<ArmorMaterial>, ArmorSet>()
170+
175171
fun create(name: String, armorMaterial: Holder<ArmorMaterial>, block: Builder.() -> Unit): ArmorSet {
176172
val builder = builder(name, armorMaterial)
177173
block.invoke(builder)
@@ -226,7 +222,7 @@ object GenerationsArmor {
226222
)
227223
},
228224
armorMaterial
229-
)
225+
).also { MATERIAL_TO_SET[armorMaterial] = it }
230226
}
231227

232228
fun register(

common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/GenerationsTools.java

Lines changed: 32 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -21,161 +21,58 @@ public class GenerationsTools {
2121
/**
2222
* Tools
2323
*/
24-
public static final ToolSet CHARGE_STONE = ToolSet.create("charge_stone", () -> GenerationsTiers.CHARGE_STONE,
25-
0,
26-
0,
27-
0,
28-
0,
29-
0,
30-
0);
31-
32-
public static final ToolSet VOLCANIC_STONE = ToolSet.create("volcanic_stone", () -> GenerationsTiers.CHARGE_STONE,
33-
0,
34-
0,
35-
0,
36-
0,
37-
0,
38-
0);
39-
40-
public static final ToolSet AMETHYST = ToolSet.create("amethyst", () -> GenerationsTiers.AMETHYST,
41-
1,
42-
2,
43-
3,
44-
2,
45-
2,
46-
4);
47-
48-
public static final ToolSet CRYSTAL = ToolSet.create("crystal", () -> GenerationsTiers.CRYSTAL,
49-
1,
50-
2,
51-
3,
52-
-2,
53-
2,
54-
4);
24+
public static final ToolSet CHARGE_STONE = ToolSet.create("charge_stone", () -> GenerationsTiers.CHARGE_STONE);
25+
26+
public static final ToolSet VOLCANIC_STONE = ToolSet.create("volcanic_stone", () -> GenerationsTiers.CHARGE_STONE);
27+
28+
public static final ToolSet AMETHYST = ToolSet.create("amethyst", () -> GenerationsTiers.AMETHYST);
29+
30+
public static final ToolSet CRYSTAL = ToolSet.create("crystal", () -> GenerationsTiers.CRYSTAL);
5531

5632
public static final ToolSet DAWN_STONE = ToolSet.create("dawn_stone", () -> GenerationsTiers.DAWN_STONE,
57-
1,
58-
2,
59-
3,
60-
0,
61-
2,
62-
4,
6333
new PotionToolEffect(MobEffects.HEALTH_BOOST, 0, 6000, 1));
6434

6535
public static final ToolSet DUSK_STONE = ToolSet.create("dusk_stone", () -> GenerationsTiers.DUSK_STONE,
66-
1,
67-
2,
68-
3,
69-
0,
70-
2,
71-
4,
7236
new PotionToolEffect(MobEffects.INVISIBILITY, 0, 6000, 1));
7337

7438
public static final ToolSet FIRE_STONE = ToolSet.create("fire_stone", () -> GenerationsTiers.FIRE_STONE,
75-
1,
76-
2,
77-
3,
78-
-3,
79-
2,
80-
4,
8139
true,
8240
new TransformToolEffect(Blocks.WATER, Blocks.OBSIDIAN, 1));
8341

8442
public static final ToolSet ICE_STONE = ToolSet.create("ice_stone", () -> GenerationsTiers.ICE_STONE,
85-
4,
86-
5,
87-
6,
88-
0,
89-
5,
90-
7,
9143
new TransformToolEffect(Blocks.WATER, Blocks.ICE, 1));
9244

9345
public static final ToolSet LEAF_STONE = ToolSet.create("leaf_stone", () -> GenerationsTiers.LEAF_STONE,
94-
1,
95-
2,
96-
3,
97-
-2,
98-
2,
99-
4,
10046
new BoneMealToolEffect(12));
10147

10248
public static final ToolSet MOON_STONE = ToolSet.create("moon_stone", () -> GenerationsTiers.MOON_STONE,
103-
1,
104-
2,
105-
3,
106-
0,
107-
2,
108-
4,
10949
new PotionToolEffect(MobEffects.NIGHT_VISION, 0, 6000, 1));
11050

111-
public static final ToolSet RUBY = ToolSet.create("ruby", () -> GenerationsTiers.RUBY,
112-
1,
113-
2,
114-
3,
115-
-2,
116-
2,
117-
4);
118-
119-
public static final ToolSet SAPPHIRE = ToolSet.create("sapphire", () -> GenerationsTiers.SAPPHIRE,
120-
1,
121-
2,
122-
3,
123-
-2,
124-
2,
125-
4);
126-
127-
public static final ToolSet SILICON = ToolSet.create("silicon", () -> GenerationsTiers.SILICON,
128-
0,
129-
0,
130-
0,
131-
0,
132-
6,
133-
0);
51+
public static final ToolSet RUBY = ToolSet.create("ruby", () -> GenerationsTiers.RUBY);
52+
53+
public static final ToolSet SAPPHIRE = ToolSet.create("sapphire", () -> GenerationsTiers.SAPPHIRE);
54+
55+
public static final ToolSet SILICON = ToolSet.create("silicon", () -> GenerationsTiers.SILICON);
13456

13557
public static final ToolSet SUN_STONE = ToolSet.create("sun_stone", () -> GenerationsTiers.SUN_STONE,
136-
1,
137-
2,
138-
3,
139-
0,
140-
2,
141-
4,
14258
true,
14359
new PlaceItemToolEffect((BlockItem) Items.TORCH, 5)); //TODO: Replace with temp light source derived from tinker's construct's light source
14460

14561
public static final ToolSet THUNDER_STONE = ToolSet.create("thunder_stone", () -> GenerationsTiers.THUNDER_STONE,
146-
1,
147-
2,
148-
3,
149-
0,
150-
2,
151-
4,
15262
new EnchantmentToolEffect(Enchantments.EFFICIENCY, 3, 1));
15363

15464
public static final ToolSet WATER_STONE = ToolSet.create("water_stone", () -> GenerationsTiers.WATER_STONE,
155-
1,
156-
2,
157-
3,
158-
-3,
159-
2,
160-
4,
16165
new EnchantmentToolEffect(Enchantments.EFFICIENCY, 3, 1));
16266

163-
public static final ToolSet ULTRITE = ToolSet.create("ultrite", () -> GenerationsTiers.ULTRITE,
164-
1.5f,
165-
1,
166-
5,
167-
-5,
168-
2,
169-
3,
170-
true);
171-
172-
public static final RegistrySupplier<Item> DIAMOND_HAMMER = register("diamond_hammer", properties -> new GenerationsHammerItem(Tiers.DIAMOND, 5.0F, -3.0F, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
173-
public static final RegistrySupplier<Item> GOLDEN_HAMMER = register("golden_hammer", properties -> new GenerationsHammerItem(Tiers.GOLD, 6.0F, -3.0F, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
174-
public static final RegistrySupplier<Item> IRON_HAMMER = register("iron_hammer", properties -> new GenerationsHammerItem(Tiers.IRON, 6.0F, -3.1F, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
175-
public static final RegistrySupplier<Item> NETHERITE_HAMMER = register("netherite_hammer", properties -> new GenerationsHammerItem(Tiers.NETHERITE, 5.0F, -3.0F, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
67+
public static final ToolSet ULTRITE = ToolSet.create("ultrite", () -> GenerationsTiers.ULTRITE, true);
68+
69+
public static final RegistrySupplier<Item> DIAMOND_HAMMER = register("diamond_hammer", properties -> new GenerationsHammerItem(Tiers.DIAMOND, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
70+
public static final RegistrySupplier<Item> GOLDEN_HAMMER = register("golden_hammer", properties -> new GenerationsHammerItem(Tiers.GOLD, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
71+
public static final RegistrySupplier<Item> IRON_HAMMER = register("iron_hammer", properties -> new GenerationsHammerItem(Tiers.IRON, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
72+
public static final RegistrySupplier<Item> NETHERITE_HAMMER = register("netherite_hammer", properties -> new GenerationsHammerItem(Tiers.NETHERITE, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
17673
// public static final RegistrySupplier<Item> ULTRITE_HAMMER = register("ultrite_hammer", properties -> new GenerationsHammerItem(GenerationsTiers.ULTRITE, 4.0F, -3.0F, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
177-
public static final RegistrySupplier<Item> STONE_HAMMER = register("stone_hammer", properties -> new GenerationsHammerItem(Tiers.STONE, 7.0F, -3.2F, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
178-
public static final RegistrySupplier<Item> WOODEN_HAMMER = register("wooden_hammer", properties -> new GenerationsHammerItem(Tiers.WOOD, 6.0F, -3.2F, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
74+
public static final RegistrySupplier<Item> STONE_HAMMER = register("stone_hammer", properties -> new GenerationsHammerItem(Tiers.STONE, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
75+
public static final RegistrySupplier<Item> WOODEN_HAMMER = register("wooden_hammer", properties -> new GenerationsHammerItem(Tiers.WOOD, properties), CreativeModeTabs.TOOLS_AND_UTILITIES);
17976

18077
private static <T extends Item> RegistrySupplier<T> register(String name, Function<Item.Properties, T> function, ResourceKey<CreativeModeTab> tab) {
18178
return TOOLS.register(name, () -> function.apply(of().arch$tab(tab)));
@@ -192,28 +89,28 @@ public static void init() {
19289
}
19390

19491
public record ToolSet(RegistrySupplier<GenerationsShovelItem> shovel, RegistrySupplier<GenerationsPickaxeItem> pickaxe, RegistrySupplier<GenerationsAxeItem> axe, RegistrySupplier<GenerationsHoeItem> hoe, RegistrySupplier<GenerationsHammerItem> hammer, RegistrySupplier<GenerationsSwordItem> sword) {
195-
public static ToolSet create(String name, Supplier<Tier> tier, float shovelDamage, float pickaxeDamage, float axeDamage, float hoeDamage, float hammerDamage, float swordDamage, ToolEffect... toolEffects) {
196-
return create(name, tier, shovelDamage, pickaxeDamage, axeDamage, hoeDamage, hammerDamage, swordDamage, false, toolEffects);
92+
public static ToolSet create(String name, Supplier<Tier> tier, ToolEffect... toolEffects) {
93+
return create(name, tier, false, toolEffects);
19794
}
19895

199-
public static ToolSet create(String name, Supplier<Tier> tier, float shovelDamage, float pickaxeDamage, float axeDamage, float hoeDamage, float hammerDamage, float swordDamage, boolean fireProof, ToolEffect... toolEffects) {
96+
public static ToolSet create(String name, Supplier<Tier> tier, boolean fireProof, ToolEffect... toolEffects) {
20097
return new ToolSet(
201-
register(name + "_shovel", GenerationsShovelItem::new, tier, shovelDamage, -3.0F, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
202-
register(name + "_pickaxe", GenerationsPickaxeItem::new, tier, pickaxeDamage, -2.8F, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
203-
register(name + "_axe", GenerationsAxeItem::new, tier, axeDamage, -3.0F, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
204-
register(name + "_hoe", GenerationsHoeItem::new, tier, hoeDamage, -1.0F, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
205-
register(name + "_hammer", GenerationsHammerItem::new, tier, hammerDamage, -3.1F, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
206-
register(name + "_sword", GenerationsSwordItem::new, tier, swordDamage, -2.4F, CreativeModeTabs.COMBAT, fireProof, toolEffects));
98+
register(name + "_shovel", GenerationsShovelItem::new, tier, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
99+
register(name + "_pickaxe", GenerationsPickaxeItem::new, tier, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
100+
register(name + "_axe", GenerationsAxeItem::new, tier, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
101+
register(name + "_hoe", GenerationsHoeItem::new, tier, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
102+
register(name + "_hammer", GenerationsHammerItem::new, tier, CreativeModeTabs.TOOLS_AND_UTILITIES, fireProof, toolEffects),
103+
register(name + "_sword", GenerationsSwordItem::new, tier, CreativeModeTabs.COMBAT, fireProof, toolEffects));
207104
}
208-
private static <T extends Item & ToolEffectHolder<T>> RegistrySupplier<T> register(String name, ToolSupplier<T> supplier, Supplier<Tier> tier, float attackDamage, float attackSpeed, ResourceKey<CreativeModeTab> tab, boolean fireProof, ToolEffect... toolEffects) {
105+
private static <T extends Item & ToolEffectHolder<T>> RegistrySupplier<T> register(String name, ToolSupplier<T> supplier, Supplier<Tier> tier, ResourceKey<CreativeModeTab> tab, boolean fireProof, ToolEffect... toolEffects) {
209106
return GenerationsTools.register(name, properties -> {
210107
if(fireProof) properties.fireResistant();
211-
return supplier.create(tier.get(), attackDamage, attackSpeed, properties).addToolEffects(toolEffects);
108+
return supplier.create(tier.get(), properties).addToolEffects(toolEffects);
212109
}, tab);
213110
}
214111

215112
private interface ToolSupplier<T extends Item> {
216-
T create(Tier tier, float attackDamage, float attackSpeed, Item.Properties properties);
113+
T create(Tier tier, Item.Properties properties);
217114
}
218115
}
219116
}

common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/armor/ArmorTickEffect.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ interface ArmorTickEffect : ArmorEffect {
2828

2929
val equippedItemStack = player.getItemBySlot(equipmentSlot)
3030
if (equippedItemStack.item !is ArmorItem) return false
31-
if ((equippedItemStack.item as ArmorItem).material.`is` { resourceKey: ResourceKey<ArmorMaterial?>? ->
32-
material.`is`(
33-
resourceKey
34-
)
35-
}) return false
31+
if ((equippedItemStack.item as ArmorItem).material.`is`(material::`is`)) return false
3632
}
3733

3834
return true

0 commit comments

Comments
 (0)