Skip to content

Commit d6d5f44

Browse files
committed
Fixed evo boots not giving 50% speed boost. Also tossed a few values on other boots.
1 parent a322dac commit d6d5f44

File tree

4 files changed

+103
-22
lines changed

4 files changed

+103
-22
lines changed

common/src/main/java/generations/gg/generations/core/generationscore/common/compat/jei/IRksCategoryExtension.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ default int getHeight(RecipeHolder<T> recipeHolder) {
5555
forRemoval = true
5656
)
5757
default void setRecipe(IRecipeLayoutBuilder builder, ICraftingGridHelper craftingGridHelper, IFocusGroup focuses) {
58+
5859
}
5960

6061
/** @deprecated */

common/src/main/java/generations/gg/generations/core/generationscore/common/compat/jei/RksRecipeExtension.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ class RksRecipeExtension<T : RksRecipe> : IRksCategoryExtension<T> {
2424

2525
val width = getWidth(recipeHolder)
2626
val height = getHeight(recipeHolder)
27-
craftingGridHelper.createAndSetOutputs(builder, List.of(resultItem))
28-
craftingGridHelper.createAndSetIngredients(builder, recipe.ingredients, width, height)
27+
craftingGridHelper.createAndSetOutputs(builder, listOf(resultItem))
28+
29+
val inputs = recipe.getRksIngredients().map { it.matchingStacks() }.toList()
30+
31+
craftingGridHelper.createAndSetInputs(builder, inputs, width, height)
2932
}
3033

3134
override fun getWidth(recipeHolder: RecipeHolder<T>): Int {

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

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package generations.gg.generations.core.generationscore.common.world.item
22

33
import generations.gg.generations.core.generationscore.common.GenerationsCore
4+
import generations.gg.generations.core.generationscore.common.generationsResource
45
import generations.gg.generations.core.generationscore.common.tab
56
import generations.gg.generations.core.generationscore.common.util.ItemPlatformRegistry
67
import generations.gg.generations.core.generationscore.common.world.item.armor.ArmorEffect
@@ -11,8 +12,13 @@ import generations.gg.generations.core.generationscore.common.world.item.armor.e
1112
import generations.gg.generations.core.generationscore.common.world.item.armor.effects.SpeedModifier
1213
import net.minecraft.core.Holder
1314
import net.minecraft.resources.ResourceKey
15+
import net.minecraft.resources.ResourceLocation
1416
import net.minecraft.world.effect.MobEffect
1517
import net.minecraft.world.effect.MobEffects
18+
import net.minecraft.world.entity.EquipmentSlotGroup
19+
import net.minecraft.world.entity.ai.attributes.Attribute
20+
import net.minecraft.world.entity.ai.attributes.AttributeModifier
21+
import net.minecraft.world.entity.ai.attributes.Attributes
1622
import net.minecraft.world.item.*
1723
import net.minecraft.world.item.enchantment.Enchantment
1824
import net.minecraft.world.item.enchantment.Enchantments
@@ -29,71 +35,71 @@ object GenerationsArmor: ItemPlatformRegistry() {
2935
): Holder<Item> = create(name, { function.invoke(of()).tab(tab) })
3036

3137
val AETHER: ArmorSet = ArmorSet.create("aether", GenerationsArmorMaterials.AETHER) {
32-
speed(0.5)
38+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
3339
}
3440

3541
val AQUA: ArmorSet = ArmorSet.create("aqua", GenerationsArmorMaterials.AQUA)
3642
val FLARE: ArmorSet = ArmorSet.create("flare", GenerationsArmorMaterials.FLARE)
3743
val GALACTIC: ArmorSet = ArmorSet.create("galactic", GenerationsArmorMaterials.GALACTIC) {
38-
speed(0.5)
44+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
3945
}
4046
val ULTRITE: ArmorSet = ArmorSet.create("ultrite", GenerationsArmorMaterials.ULTRITE)
4147
val MAGMA: ArmorSet = ArmorSet.create("magma", GenerationsArmorMaterials.MAGMA)
4248
val NEO_PLASMA: ArmorSet = ArmorSet.create("neo_plasma", GenerationsArmorMaterials.NEO_PLASMA)
4349
val PLASMA: ArmorSet = ArmorSet.create("plasma", GenerationsArmorMaterials.PLASMA)
4450
val ROCKET: ArmorSet = ArmorSet.create("rocket", GenerationsArmorMaterials.ROCKET)
4551
val SKULL: ArmorSet = ArmorSet.create("skull", GenerationsArmorMaterials.SKULL) {
46-
speed(0.5)
52+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
4753
}
4854
val ULTRA: ArmorSet = ArmorSet.create("ultra", GenerationsArmorMaterials.ULTRA) {
4955
potion(MobEffects.MOVEMENT_SPEED, 1)
50-
speed(0.25)
56+
speedAttribute(EquipmentSlotGroup.FEET, 0.25)
5157
}
5258
val CRYSTALLIZED: ArmorSet = ArmorSet.create("crystallized", GenerationsArmorMaterials.CRYSTAL) {
5359
potion(MobEffects.MOVEMENT_SPEED, 1)
54-
speed(0.1)
60+
speedAttribute(EquipmentSlotGroup.FEET, 0.1)
5561
}
5662
val DAWN_STONE: ArmorSet = ArmorSet.create("dawn_stone", GenerationsArmorMaterials.DAWN_STONE) {
5763
potion(MobEffects.JUMP, 3)
58-
speed(0.5)
64+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
5965
}
6066
val DUSK_STONE: ArmorSet = ArmorSet.create("dusk_stone", GenerationsArmorMaterials.DUSK_STONE) {
6167
potion(MobEffects.SATURATION, 4)
62-
speed(0.5)
68+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
6369
}
6470
val FIRE_STONE: ArmorSet = ArmorSet.create("fire_stone", GenerationsArmorMaterials.FIRE_STONE) {
6571
enchantment(Enchantments.FIRE_PROTECTION, 2)
6672
potion(MobEffects.FIRE_RESISTANCE, 1)
67-
speed(0.5)
73+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
6874
}
6975

7076
val LEAF_STONE: ArmorSet = ArmorSet.create("leaf_stone", GenerationsArmorMaterials.LEAF_STONE) {
7177
enchantment(Enchantments.FEATHER_FALLING, 3)
7278
enchantment(Enchantments.THORNS, 3)
73-
speed(0.5)
79+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
7480
}
7581
val ICE_STONE: ArmorSet = ArmorSet.create("ice_stone", GenerationsArmorMaterials.ICE_STONE) {
7682
enchantment(Enchantments.FROST_WALKER, 2)
77-
speed(0.5)
83+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
7884
}
7985
val MOON_STONE: ArmorSet = ArmorSet.create("moon_stone", GenerationsArmorMaterials.MOON_STONE) {
8086
enchantment(Enchantments.PROTECTION, 4)
8187
enchantment(Enchantments.PROJECTILE_PROTECTION, 4)
82-
speed(0.5)
88+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
8389
}
8490
val SUN_STONE: ArmorSet = ArmorSet.create("sun_stone", GenerationsArmorMaterials.SUN_STONE) {
8591
enchantment(Enchantments.PROTECTION, 4)
8692
enchantment(Enchantments.PROJECTILE_PROTECTION, 4)
87-
speed(0.5)
93+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
8894
}
8995
val THUNDER_STONE: ArmorSet = ArmorSet.create("thunder_stone", GenerationsArmorMaterials.THUNDER_STONE) {
9096
potion(MobEffects.DIG_SPEED, 1)
91-
speed(0.5)
97+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
9298
}
9399
val WATER_STONE: ArmorSet = ArmorSet.create("water_stone", GenerationsArmorMaterials.WATER_STONE) {
94100
potion(MobEffects.WATER_BREATHING, 1)
95101
enchantment(Enchantments.AQUA_AFFINITY, 2)
96-
speed(0.5)
102+
speedAttribute(EquipmentSlotGroup.FEET, 0.5)
97103
}
98104

99105
fun of(): Item.Properties {
@@ -124,6 +130,7 @@ object GenerationsArmor: ItemPlatformRegistry() {
124130

125131
class Builder(private val name: String, private val armormaterial: Holder<ArmorMaterial>) {
126132
private val effects: MutableList<ArmorEffect> = ArrayList()
133+
private val data: MutableMap<EquipmentSlotGroup, MutableList<Pair<Holder<Attribute>, AttributeModifier>>> = mutableMapOf()
127134

128135
fun enchantment(enchantment: ResourceKey<Enchantment>, level: Int): Builder {
129136
effects.add(EnchantmentArmorEffect(enchantment, level))
@@ -140,8 +147,17 @@ object GenerationsArmor: ItemPlatformRegistry() {
140147
return this
141148
}
142149

150+
fun attributeModifier(slot: EquipmentSlotGroup, holder: Holder<Attribute>, id: ResourceLocation, amount: Double, operation: AttributeModifier.Operation): Builder {
151+
data.computeIfAbsent(slot) { mutableListOf() } += holder to AttributeModifier(id, amount, operation)
152+
return this
153+
}
154+
143155
fun build(): ArmorSet {
144-
return create(name, armormaterial, *effects.toTypedArray())
156+
return create(name, armormaterial, data, *effects.toTypedArray())
157+
}
158+
159+
fun speedAttribute(slot: EquipmentSlotGroup, amount: Double) {
160+
attributeModifier(slot, Attributes.MOVEMENT_SPEED, "50_speed".generationsResource(), amount, AttributeModifier.Operation.ADD_MULTIPLIED_BASE)
145161
}
146162
}
147163

@@ -158,47 +174,62 @@ object GenerationsArmor: ItemPlatformRegistry() {
158174
return Builder(name, armorMaterial)
159175
}
160176

177+
178+
161179
fun create(
162180
name: String,
163181
armorMaterial: Holder<ArmorMaterial>,
182+
attributeModifiers: Map<EquipmentSlotGroup, List<Pair<Holder<Attribute>, AttributeModifier>>> = mutableMapOf(),
164183
vararg armorEffects: ArmorEffect
165184
): ArmorSet {
166-
167185
return ArmorSet(
168186
register(
169187
name + "_helmet"
170188
) { properties: Item.Properties ->
189+
val list = attributeModifiers.getOrDefault(EquipmentSlotGroup.HEAD, listOf())
190+
171191
GenerationsArmorItem(
172192
armorMaterial,
173193
ArmorItem.Type.HELMET,
174-
properties
194+
195+
properties,
196+
list
175197
)
176198
},
177199
register(
178200
name + "_chestplate"
179201
) { properties: Item.Properties ->
202+
val list = attributeModifiers.getOrDefault(EquipmentSlotGroup.CHEST, listOf())
203+
180204
GenerationsArmorItem(
181205
armorMaterial,
182206
ArmorItem.Type.CHESTPLATE,
183-
properties
207+
properties,
208+
list
184209
)
185210
},
186211
register(
187212
name + "_leggings"
188213
) { properties: Item.Properties ->
214+
val list = attributeModifiers.getOrDefault(EquipmentSlotGroup.LEGS, listOf())
215+
189216
GenerationsArmorItem(
190217
armorMaterial,
191218
ArmorItem.Type.LEGGINGS,
192-
properties
219+
properties,
220+
list
193221
)
194222
},
195223
register(
196224
name + "_boots"
197225
) { properties: Item.Properties ->
226+
val list = attributeModifiers.getOrDefault(EquipmentSlotGroup.FEET, listOf())
227+
198228
GenerationsArmorItem(
199229
armorMaterial,
200230
ArmorItem.Type.BOOTS,
201231
properties,
232+
list,
202233
*armorEffects
203234
)
204235
},

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

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,68 @@
11
package generations.gg.generations.core.generationscore.common.world.item.armor
22

3+
import com.google.common.base.Supplier
4+
import com.google.common.base.Suppliers
35
import generations.gg.generations.core.generationscore.common.client.render.rarecandy.instanceOrNull
46
import net.minecraft.core.Holder
7+
import net.minecraft.resources.ResourceLocation
58
import net.minecraft.world.entity.Entity
9+
import net.minecraft.world.entity.EquipmentSlotGroup
610
import net.minecraft.world.entity.LivingEntity
11+
import net.minecraft.world.entity.ai.attributes.Attribute
12+
import net.minecraft.world.entity.ai.attributes.AttributeModifier
13+
import net.minecraft.world.entity.ai.attributes.Attributes
714
import net.minecraft.world.item.ArmorItem
815
import net.minecraft.world.item.ArmorMaterial
916
import net.minecraft.world.item.ItemStack
17+
import net.minecraft.world.item.component.ItemAttributeModifiers
1018
import net.minecraft.world.level.Level
1119
import java.util.function.Consumer
1220

1321
class GenerationsArmorItem(
1422
armorMaterial: Holder<ArmorMaterial>,
1523
equipmentSlot: Type,
1624
properties: Properties,
17-
vararg armorEffects: ArmorEffect?
25+
additionalModfier: List<Pair<Holder<Attribute>, AttributeModifier>>,
26+
vararg armorEffects: ArmorEffect?,
1827
) :
1928
ArmorItem(armorMaterial, equipmentSlot, properties) {
29+
private var attributeModifiers: Supplier<ItemAttributeModifiers> = Suppliers.memoize<ItemAttributeModifiers>(Supplier {
30+
val i = (material.value() as ArmorMaterial).getDefense(type)
31+
val f = (material.value() as ArmorMaterial).toughness()
32+
val builder = ItemAttributeModifiers.builder()
33+
val equipmentSlotGroup = EquipmentSlotGroup.bySlot(type.getSlot())
34+
val resourceLocation = ResourceLocation.withDefaultNamespace("armor." + type.getName())
35+
builder.add(
36+
Attributes.ARMOR,
37+
AttributeModifier(resourceLocation, i.toDouble(), AttributeModifier.Operation.ADD_VALUE),
38+
equipmentSlotGroup
39+
)
40+
builder.add(
41+
Attributes.ARMOR_TOUGHNESS,
42+
AttributeModifier(resourceLocation, f.toDouble(), AttributeModifier.Operation.ADD_VALUE),
43+
equipmentSlotGroup
44+
)
45+
val g = (material.value() as ArmorMaterial).knockbackResistance()
46+
if (g > 0.0f) {
47+
builder.add(
48+
Attributes.KNOCKBACK_RESISTANCE,
49+
AttributeModifier(resourceLocation, g.toDouble(), AttributeModifier.Operation.ADD_VALUE),
50+
equipmentSlotGroup
51+
)
52+
}
53+
54+
additionalModfier.forEach {
55+
56+
builder.add(it.first, it.second, EquipmentSlotGroup.bySlot(type.slot))}
57+
58+
builder.build()
59+
})
60+
2061
val armorEffects: MutableSet<ArmorTickEffect> = HashSet()
2162
val customAttributeModifiers: MutableSet<CustomAttributeModifier> = HashSet()
2263

2364
init {
65+
2466
for (armorEffect in armorEffects) {
2567
if (armorEffect is ArmorTickEffect) {
2668
this.armorEffects.add(armorEffect)
@@ -70,4 +112,8 @@ class GenerationsArmorItem(
70112
)
71113
})
72114
}
115+
116+
override fun getDefaultAttributeModifiers(): ItemAttributeModifiers? {
117+
return attributeModifiers.get();
118+
}
73119
}

0 commit comments

Comments
 (0)