Skip to content

Commit 0361027

Browse files
committed
Update to 1.21
MOJANG DELETED THE ENCHANTMENT CLASS! This update completely rebuilds the entire Combat+ enchantment infrastructure from the ground up. All enchantment types from Combat+ have been removed, their tags are still there and should be used instead. Exclusive-set tags have also been added. Combat+ enchantment hooks have been remade as components that act the same way. Combat+ components take two entities and are heavily inspired by Apoli's bientity actions. Combat+ now also implements double entity conditions (also inspired by Apoli) and a small collection of single/double enchantment conditions to aid modders (and datapack makers now, I guess) in creating unique enchantments. Combat+ now also implements a data generator for enchantments and several registries (including one that allows enchantment to perform code execution).
1 parent ff25d95 commit 0361027

File tree

98 files changed

+1940
-620
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1940
-620
lines changed

gradle.properties

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ org.gradle.parallel=true
44

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.20.6
8-
yarn_mappings=1.20.6+build.1
7+
minecraft_version=1.21
8+
yarn_mappings=1.21+build.2
99
loader_version=0.15.11
1010

1111
# Mod Properties
12-
mod_version=2.0.1
12+
mod_version=3.0.0
1313
maven_group=com.provismet
1414
archives_base_name=combatplus-core
1515
modid=combat-plus-core
1616

1717
# Dependencies
18-
fabric_version=0.98.0+1.20.6
19-
lilylib_version=1.1.3-mc1.20.6
18+
fabric_version=0.100.1+1.21
19+
lilylib_version=1.1.3-mc1.21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"fabric:load_conditions": [
3+
{
4+
"condition": "combat-plus:developer_mode"
5+
}
6+
],
7+
"anvil_cost": 1,
8+
"description": {
9+
"translate": "enchantment.combat-plus.logger"
10+
},
11+
"effects": {
12+
"combat-plus:post_charged_attack": [
13+
{
14+
"effect": {
15+
"type": "combat-plus:code_execution_double_entity",
16+
"function": "combat-plus:log-charged"
17+
}
18+
}
19+
],
20+
"combat-plus:post_critical_attack": [
21+
{
22+
"effect": {
23+
"type": "combat-plus:code_execution_double_entity",
24+
"function": "combat-plus:log-critical"
25+
}
26+
}
27+
],
28+
"combat-plus:post_kill": [
29+
{
30+
"effect": {
31+
"type": "combat-plus:code_execution_double_entity",
32+
"function": "combat-plus:log-kill"
33+
}
34+
}
35+
]
36+
},
37+
"max_cost": {
38+
"base": 1,
39+
"per_level_above_first": 0
40+
},
41+
"max_level": 1,
42+
"min_cost": {
43+
"base": 1,
44+
"per_level_above_first": 0
45+
},
46+
"slots": [
47+
"mainhand"
48+
],
49+
"supported_items": "#combat-plus:enchantable/damage",
50+
"weight": 1
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"values": [
3+
{
4+
"id": "#combat-plus:additional_damage",
5+
"required": false
6+
},
7+
{
8+
"id": "#combat-plus:offhand",
9+
"required": false
10+
}
11+
]
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"values": [
3+
{
4+
"id": "#combat-plus:exclusive_set/aspect_offhand",
5+
"required": false
6+
},
7+
{
8+
"id": "#combat-plus:offhand",
9+
"required": false
10+
}
11+
]
12+
}

src/main/generated/data/combat-plus/tags/items/breaks_shields.json src/main/generated/data/combat-plus/tags/enchantment/exclusive_set/aspect_offhand.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"values": [
33
{
4-
"id": "#minecraft:axes",
4+
"id": "#combat-plus:aspect",
55
"required": false
66
}
77
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"values": [
3+
{
4+
"id": "#combat-plus:additional_damage",
5+
"required": false
6+
},
7+
{
8+
"id": "#c:weapon_damage_enhancements",
9+
"required": false
10+
}
11+
]
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"values": [
3+
{
4+
"id": "#combat-plus:offhand",
5+
"required": false
6+
},
7+
{
8+
"id": "#combat-plus:exclusive_set/weapon_utility_offhand",
9+
"required": false
10+
}
11+
]
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"values": [
3+
{
4+
"id": "#combat-plus:weapon_utility",
5+
"required": false
6+
}
7+
]
8+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"values": [
3-
"minecraft:sweeping_edge"
3+
"minecraft:sweeping_edge",
4+
"minecraft:wind_burst"
45
]
56
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"values": [
3+
{
4+
"id": "#minecraft:axes",
5+
"required": false
6+
},
7+
{
8+
"id": "combat-plus:debugger",
9+
"required": false
10+
}
11+
]
12+
}

src/main/generated/data/combat-plus/tags/items/melee_weapon.json src/main/generated/data/combat-plus/tags/item/melee_weapon.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{
88
"id": "#minecraft:axes",
99
"required": false
10-
}
10+
},
11+
"minecraft:mace"
1112
]
1213
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"values": [
3+
{
4+
"id": "#combat-plus:additional_damage",
5+
"required": false
6+
},
7+
{
8+
"id": "#combat-plus:offhand",
9+
"required": false
10+
}
11+
]
12+
}

src/main/java/com/provismet/CombatPlusCore/CPCMain.java

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
package com.provismet.CombatPlusCore;
22

3-
import com.provismet.CombatPlusCore.debug.registries.CPCDebugEnchantments;
43
import com.provismet.CombatPlusCore.debug.registries.CPCDebugItems;
5-
import com.provismet.CombatPlusCore.utility.CPCItemGroups;
4+
import com.provismet.CombatPlusCore.enchantment.component.CPCEnchantmentComponents;
5+
import com.provismet.CombatPlusCore.registries.CPCDoubleEntityLootConditionTypes;
6+
import com.provismet.CombatPlusCore.registries.CPCEnchantmentDoubleEntityEffects;
7+
import com.provismet.CombatPlusCore.registries.CPCEnchantmentSingleEntityEffects;
8+
import com.provismet.CombatPlusCore.registries.CPCSingleEntityLootConditionTypes;
9+
import com.provismet.CombatPlusCore.registries.LambdaRegistry;
10+
import com.provismet.CombatPlusCore.utility.item.CPCItemGroups;
11+
import com.provismet.CombatPlusCore.utility.CPCRegistries;
12+
import com.provismet.CombatPlusCore.utility.resource.CPCResourceConditions;
613
import org.slf4j.Logger;
714
import org.slf4j.LoggerFactory;
815

916
import com.provismet.CombatPlusCore.api.CombatPlusEntrypoint;
1017
import com.provismet.CombatPlusCore.interfaces.mixin.IMixinItemStack;
1118
import com.provismet.CombatPlusCore.utility.CPCEnchantmentHelper;
12-
import com.provismet.CombatPlusCore.utility.CombatGameRules;
19+
import com.provismet.CombatPlusCore.utility.CPCGameRules;
1320

1421
import net.fabricmc.api.ModInitializer;
1522
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents;
@@ -28,19 +35,26 @@ public static Identifier identifier (String path) {
2835

2936
@Override
3037
public void onInitialize () {
31-
CombatGameRules.register();
38+
CPCRegistries.init();
39+
CPCEnchantmentComponents.init();
40+
CPCSingleEntityLootConditionTypes.init();
41+
CPCDoubleEntityLootConditionTypes.init();
42+
CPCResourceConditions.register();
43+
CPCEnchantmentDoubleEntityEffects.register();
44+
LambdaRegistry.register();
45+
CPCGameRules.register();
3246
CPCItemGroups.register();
47+
CPCEnchantmentSingleEntityEffects.register();
3348

3449
if (FabricLoader.getInstance().isDevelopmentEnvironment()) {
3550
LOGGER.warn("Combat+ Core development code is running. If you see this, you should be in a development environment.");
3651
CPCDebugItems.register();
37-
CPCDebugEnchantments.register();
3852
}
3953

4054
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, entity, target) -> {
4155
if (entity instanceof LivingEntity user) {
4256
((IMixinItemStack)(Object)user.getMainHandStack()).CPC_postKill(user, target);
43-
CPCEnchantmentHelper.postKill(user, target, EquipmentSlot.MAINHAND);
57+
CPCEnchantmentHelper.postKill(world, user, target, EquipmentSlot.MAINHAND);
4458
}
4559
});
4660

src/main/java/com/provismet/CombatPlusCore/debug/enchantments/LoggerEnchantment.java

-38
This file was deleted.

src/main/java/com/provismet/CombatPlusCore/debug/items/DebuggerItem.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public DebuggerItem(Settings settings) {
2121

2222
public static AttributeModifiersComponent createSimpleAttributes () {
2323
return AttributeModifiersComponent.builder()
24-
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", 3f, EntityAttributeModifier.Operation.ADD_VALUE), AttributeModifierSlot.MAINHAND)
25-
.add(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Weapon modifier", -2.4f, EntityAttributeModifier.Operation.ADD_VALUE), AttributeModifierSlot.MAINHAND)
24+
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(BASE_ATTACK_DAMAGE_MODIFIER_ID, 3f, EntityAttributeModifier.Operation.ADD_VALUE), AttributeModifierSlot.MAINHAND)
25+
.add(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(BASE_ATTACK_SPEED_MODIFIER_ID, -2.4f, EntityAttributeModifier.Operation.ADD_VALUE), AttributeModifierSlot.MAINHAND)
2626
.build();
2727
}
2828

src/main/java/com/provismet/CombatPlusCore/debug/registries/CPCDebugEnchantments.java

-17
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.provismet.CombatPlusCore.enchantment.component;
2+
3+
import com.provismet.CombatPlusCore.CPCMain;
4+
import com.provismet.CombatPlusCore.enchantment.effect.CPCEnchantmentEntityEffect;
5+
import com.provismet.CombatPlusCore.enchantment.loot.context.CPCLootContextTypes;
6+
import net.minecraft.component.ComponentType;
7+
import net.minecraft.enchantment.effect.EnchantmentEffectEntry;
8+
import net.minecraft.registry.Registries;
9+
import net.minecraft.registry.Registry;
10+
11+
import java.util.List;
12+
import java.util.function.UnaryOperator;
13+
14+
public class CPCEnchantmentComponents {
15+
public static final ComponentType<List<EnchantmentEffectEntry<CPCEnchantmentEntityEffect>>> POST_CHARGED_ATTACK = register("post_charged_attack", builder -> builder.codec(EnchantmentEffectEntry.createCodec(CPCEnchantmentEntityEffect.CODEC, CPCLootContextTypes.DOUBLE_ENTITY).listOf()));
16+
public static final ComponentType<List<EnchantmentEffectEntry<CPCEnchantmentEntityEffect>>> POST_CRITICAL_ATTACK = register("post_critical_attack", builder -> builder.codec(EnchantmentEffectEntry.createCodec(CPCEnchantmentEntityEffect.CODEC, CPCLootContextTypes.DOUBLE_ENTITY).listOf()));
17+
public static final ComponentType<List<EnchantmentEffectEntry<CPCEnchantmentEntityEffect>>> POST_KILL = register("post_kill", builder -> builder.codec(EnchantmentEffectEntry.createCodec(CPCEnchantmentEntityEffect.CODEC, CPCLootContextTypes.DOUBLE_ENTITY).listOf()));
18+
19+
public static void init () {}
20+
21+
private static <T> ComponentType<T> register (String name, UnaryOperator<ComponentType.Builder<T>> builderOperator) {
22+
return Registry.register(Registries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, CPCMain.identifier(name), (builderOperator.apply(ComponentType.builder())).build());
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.provismet.CombatPlusCore.enchantment.effect;
2+
3+
import com.mojang.serialization.Codec;
4+
import com.mojang.serialization.MapCodec;
5+
import com.provismet.CombatPlusCore.registries.CPCEnchantmentDoubleEntityEffects;
6+
import com.provismet.CombatPlusCore.utility.CPCRegistries;
7+
import net.minecraft.enchantment.EnchantmentEffectContext;
8+
import net.minecraft.entity.Entity;
9+
import net.minecraft.server.world.ServerWorld;
10+
11+
import java.util.function.Function;
12+
13+
/**
14+
* Combat+ Enchantment Effect for effects that can look at both the attacker and the target simultaneously.
15+
*
16+
* @see CPCEnchantmentDoubleEntityEffects
17+
*/
18+
public interface CPCEnchantmentEntityEffect {
19+
public static final Codec<CPCEnchantmentEntityEffect> CODEC = CPCRegistries.ENCHANTMENT_DUAL_ENTITY_EFFECT_TYPE.getCodec().dispatch(CPCEnchantmentEntityEffect::getCodec, Function.identity());
20+
21+
public void apply (ServerWorld world, int level, EnchantmentEffectContext context, Entity attacker, Entity target);
22+
23+
public MapCodec<? extends CPCEnchantmentEntityEffect> getCodec();
24+
}

0 commit comments

Comments
 (0)