Skip to content

Commit b47130b

Browse files
committed
fix some bugs
add element system
1 parent 8744685 commit b47130b

File tree

66 files changed

+1533
-492
lines changed

Some content is hidden

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

66 files changed

+1533
-492
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ repositories {
170170

171171
dependencies {
172172
/* other minecraft dependencies are here */
173-
173+
implementation fg.deobf("curse.maven:inventory-hud-forge-357540:5639966")
174174
// compile against the JEI API but do not include it at runtime
175175
// compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}"))
176176
// at runtime, use the full JEI jar for Forge

src/main/java/net/exmo/exmodifier/Config.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ public class Config {
6868
public static final ForgeConfigSpec.BooleanValue ELEMENT_DEBUG = BUILDER
6969
.comment("Enable ELEMENT_DEBUG")
7070
.define("ELEMENT_DEBUG", false);
71+
public static final ForgeConfigSpec.IntValue MAX_REFINE = BUILDER
72+
.comment("refine max count")
73+
.defineInRange("MAX_REFINE", 5,0,Integer.MAX_VALUE);
74+
public static final ForgeConfigSpec.DoubleValue REFINE_EFFECT = BUILDER
75+
.comment("refine max count")
76+
.defineInRange("REFINE_EFFECT", 0.1,0,Double.MAX_VALUE);
77+
public static final ForgeConfigSpec.BooleanValue REFINE_SYSTEM = BUILDER
78+
.comment("open refine system")
79+
.define("REFINE_SYSTEM", false);
80+
public static final ForgeConfigSpec.BooleanValue REFINE_ALAWAYS_DISPLAY_TOOLTIP = BUILDER
81+
.comment("alaways display star tooltip")
82+
.define("REFINE_ALAWAYS_DISPLAY_TOOLTIP", false);
83+
public static final ForgeConfigSpec.BooleanValue REFINE_NEED_SAME_STAR = BUILDER
84+
.comment("refine need same star")
85+
.define("REFINE_NEED_SAME_STAR", false);
7186
static final ForgeConfigSpec SPEC = BUILDER.build();
7287

7388
// 配置值缓存
@@ -87,6 +102,11 @@ public class Config {
87102
public static boolean entryUnderLine;
88103
public static boolean entryShowUnderLevel;
89104
public static boolean element_debug;
105+
public static int max_refine;
106+
public static double refine_effect;
107+
public static boolean refine_system;
108+
public static boolean alaways_display_modifier_name_under_item_name;
109+
public static boolean refine_need_same_star;
90110

91111

92112

@@ -109,5 +129,10 @@ public static void onLoad(final ModConfigEvent event) {
109129
entryFold = ENTRY_FOLD.get();
110130
entryUnderLine = ENTRY_UNDER_LINE.get();
111131
entryShowUnderLevel = ENTRY_SHOW_UNDER_LEVEL.get();
132+
max_refine = MAX_REFINE.get() ;
133+
refine_effect = REFINE_EFFECT.get();
134+
alaways_display_modifier_name_under_item_name = REFINE_ALAWAYS_DISPLAY_TOOLTIP.get();
135+
refine_system = REFINE_SYSTEM.get();
136+
refine_need_same_star = REFINE_NEED_SAME_STAR.get();
112137
}
113138
}

src/main/java/net/exmo/exmodifier/Exmodifier.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import com.mojang.logging.LogUtils;
44
import net.exmo.exmodifier.compat.compat.apoth.ApothCompat;
5+
import net.exmo.exmodifier.content.attributeEffect.modern.EffectSyncPacket;
56
import net.exmo.exmodifier.content.client.EntryItemRender;
67
import net.exmo.exmodifier.content.modifier.*;
78
import net.exmo.exmodifier.content.type.ExTypeHandle;
89
import net.exmo.exmodifier.content.type.ItemType;
910
import net.exmo.exmodifier.init.RegisterOther;
1011
import net.exmo.exmodifier.network.*;
11-
import net.exmo.exmodifier.util.ColorUtil;
1212
import net.exmo.exmodifier.util.WeightedUtil;
1313
import net.minecraft.core.registries.Registries;
1414
import net.minecraft.data.DataGenerator;
@@ -44,7 +44,6 @@
4444
import net.minecraftforge.registries.RegistryObject;
4545
import org.slf4j.Logger;
4646

47-
import java.awt.*;
4847
import java.io.IOException;
4948
import java.util.ArrayList;
5049
import java.util.HashMap;
@@ -127,6 +126,10 @@ public Exmodifier() {
127126
PACKET_HANDLER.registerMessage(messageID++, SyncEntityElementMessage.class, SyncEntityElementMessage::encode, SyncEntityElementMessage::decode, SyncEntityElementMessage::handle);
128127
PACKET_HANDLER.registerMessage(messageID++, SyncEntityElementRemovedMessage.class, SyncEntityElementRemovedMessage::encode, SyncEntityElementRemovedMessage::decode, SyncEntityElementRemovedMessage::handle);
129128
PACKET_HANDLER.registerMessage(messageID++, AskSyncEntityElementMessage.class, AskSyncEntityElementMessage::encode, AskSyncEntityElementMessage::decode, AskSyncEntityElementMessage::handle);
129+
PACKET_HANDLER.registerMessage(messageID++, RefineItemMessage.class, RefineItemMessage::encode, RefineItemMessage::decode, RefineItemMessage::handle);
130+
PACKET_HANDLER.registerMessage(messageID++, EffectSyncPacket.class,
131+
EffectSyncPacket::encode, EffectSyncPacket::new,
132+
EffectSyncPacket::handle);
130133

131134
ITEMS.register(modEventBus);
132135
try {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package net.exmo.exmodifier.compat;
2+
3+
import mods.flammpfeil.slashblade.item.ItemSlashBlade;
4+
import net.exmo.exmodifier.events.ExCanRefineEvent;
5+
import net.minecraftforge.eventbus.api.SubscribeEvent;
6+
import net.minecraftforge.fml.ModList;
7+
import net.minecraftforge.fml.common.Mod;
8+
9+
@Mod.EventBusSubscriber
10+
public class SlashBladeCompat {
11+
@SubscribeEvent
12+
public static void onRefine(ExCanRefineEvent event){
13+
if (ModList.get().isLoaded("slashblade")){
14+
if (event.originalItemStack.getItem() instanceof ItemSlashBlade itemSlashBlade){
15+
if (event.targetItemStack.getItem() instanceof ItemSlashBlade itemSlashBlade1){
16+
event.canRefine = (event.originalItemStack.getTag().getCompound("bladeState").getString("translationKey").equals(event.targetItemStack.getTag().getCompound("bladeState").getString("translationKey")));
17+
}
18+
}
19+
}
20+
}
21+
}

src/main/java/net/exmo/exmodifier/compat/compat/apoth/ApothCompat.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void SkinAttr(GatherSkippedAttributeTooltipsEvent e) {
3131
List<Multimap<Attribute, AttributeModifier>> mapList = new ArrayList<>();
3232

3333
EquipmentSlot[] var3 = EquipmentSlot.values();
34-
int var4 = var3.length;
34+
//int var4 = var3.length;
3535

3636
for (EquipmentSlot equipmentSlot : var3) {
3737
mapList.add(stack.getAttributeModifiers(equipmentSlot));
@@ -42,8 +42,12 @@ public void SkinAttr(GatherSkippedAttributeTooltipsEvent e) {
4242
for (Multimap<Attribute, AttributeModifier> map : mapList) {
4343
for (ModifierEntry modifier : modifiers) {
4444
for (AttributeModifier m : map.values()) {
45+
if (m.getName().equals("exmodifier_refine")){
46+
e.skipUUID(m.getId());
47+
continue;
48+
}
4549
for (ModifierAttriGether modifierEntry : modifier.attriGether) {
46-
if (m.getName().equals(modifierEntry.modifier.getName())) {
50+
if (m.getName().equals(modifierEntry.modifier.getName()) ) {
4751
e.skipUUID(m.getId());
4852
}
4953
}
Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,39 @@
11
package net.exmo.exmodifier.compat;
22

3-
import net.exmo.exmodifier.content.event.MainEvent;
4-
import net.exmo.exmodifier.util.AttriGether;
5-
import net.exmo.exmodifier.util.ItemAttrUtil;
6-
import net.minecraft.world.entity.EquipmentSlot;
7-
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
8-
import net.minecraft.world.entity.player.Player;
9-
import net.minecraft.world.item.ArmorItem;
10-
import net.minecraft.world.item.BowItem;
11-
import net.minecraft.world.item.ItemStack;
12-
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
13-
import net.minecraftforge.eventbus.api.SubscribeEvent;
14-
import net.minecraftforge.fml.ModList;
153
import net.minecraftforge.fml.common.Mod;
164

17-
import java.util.UUID;
18-
195
@Mod.EventBusSubscriber
206
public class weponlevelingCompat {
21-
private static final UUID AttackDamageUUID = UUID.fromString("867fad31-78e1-4a62-8d10-a9e3fd78ef0b");
22-
private static AttriGether AttackDamage(double amout) {
23-
return new AttriGether(net.minecraft.world.entity.ai.attributes.Attributes.ATTACK_DAMAGE, new AttributeModifier(AttackDamageUUID, "WeaponLeveling Attack Damage", amout, AttributeModifier.Operation.ADDITION), EquipmentSlot.MAINHAND);
24-
}
25-
26-
@SubscribeEvent
27-
public static void atChange(LivingEquipmentChangeEvent event) {
28-
if (ModList.get().isLoaded("weaponleveling")) {
29-
// Exmodifier.LOGGER.info("Load ca");
30-
if (event.getEntity() instanceof Player player) {
31-
ItemStack stack = event.getTo();
32-
if (stack.getItem() instanceof ArmorItem) return;
33-
if (stack.getItem() instanceof BowItem) return;
34-
if (MainEvent.CommonEvent.hasAttrOrBow(stack)){
35-
if (stack.getTag() ==null)return;
36-
if (stack.getTag().contains("level")) {
37-
if (stack.getTag().getInt("level") != stack.getTag().getInt("Oldlevel")) {
38-
AttriGether attriGether1 = AttackDamage(((stack.getTag().getInt("level"))-1)*0.5);
39-
40-
// Exmodifier.LOGGER.info("WeaponLeveling Compat");
41-
ItemAttrUtil.removeAttributeModifier(stack, attriGether1.attribute, attriGether1.modifier, attriGether1.slot);
42-
AttriGether attriGether = AttackDamage((stack.getTag().getInt("level"))*0.5);
43-
stack.getTag().putInt("Oldlevel", stack.getTag().getInt("level"));
44-
45-
ItemAttrUtil.addItemAttributeModifier2(stack, attriGether.attribute, attriGether.modifier, attriGether.slot);
46-
}
47-
}
48-
}
49-
}
50-
}
51-
}
7+
// private static final UUID AttackDamageUUID = UUID.fromString("867fad31-78e1-4a62-8d10-a9e3fd78ef0b");
8+
// private static AttriGether AttackDamage(double amout) {
9+
// return new AttriGether(net.minecraft.world.entity.ai.attributes.Attributes.ATTACK_DAMAGE, new AttributeModifier(AttackDamageUUID, "WeaponLeveling Attack Damage", amout, AttributeModifier.Operation.ADDITION), EquipmentSlot.MAINHAND);
10+
// }
11+
//
12+
// @SubscribeEvent
13+
// public static void atChange(LivingEquipmentChangeEvent event) {
14+
// if (ModList.get().isLoaded("weaponleveling")) {
15+
// // Exmodifier.LOGGER.info("Load ca");
16+
// if (event.getEntity() instanceof Player player) {
17+
// ItemStack stack = event.getTo();
18+
// if (stack.getItem() instanceof ArmorItem) return;
19+
// if (stack.getItem() instanceof BowItem) return;
20+
// if (MainEvent.CommonEvent.hasAttrOrBow(stack)){
21+
// if (stack.getTag() ==null)return;
22+
// if (stack.getTag().contains("level")) {
23+
// if (stack.getTag().getInt("level") != stack.getTag().getInt("Oldlevel")) {
24+
// AttriGether attriGether1 = AttackDamage(((stack.getTag().getInt("level"))-1)*0.5);
25+
//
26+
// // Exmodifier.LOGGER.info("WeaponLeveling Compat");
27+
// ItemAttrUtil.removeAttributeModifier(stack, attriGether1.attribute, attriGether1.modifier, attriGether1.slot);
28+
// AttriGether attriGether = AttackDamage((stack.getTag().getInt("level"))*0.5);
29+
// stack.getTag().putInt("Oldlevel", stack.getTag().getInt("level"));
30+
//
31+
// ItemAttrUtil.addItemAttributeModifier2(stack, attriGether.attribute, attriGether.modifier, attriGether.slot);
32+
// }
33+
// }
34+
// }
35+
// }
36+
// }
37+
// }
5238

5339
}

src/main/java/net/exmo/exmodifier/content/attributeEffect/AttriGetherEffect.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.exmo.exmodifier.content.attributeEffect;
22

33
import net.exmo.exmodifier.Exmodifier;
4-
import net.exmo.exmodifier.util.AttriGether;
4+
import net.exmo.exmodifier.util.gether.AttrGether;
55
import net.minecraft.core.particles.SimpleParticleType;
66
import net.minecraft.resources.ResourceLocation;
77
import net.minecraft.world.BossEvent;
@@ -31,8 +31,8 @@ public void setLocalDescription(String localDescription) {
3131

3232
private String localDescription;
3333
private boolean visible;
34-
private List<AttriGether> attriGethers;
35-
public AttriGetherEffect(BossEvent.BossBarColor bossBarColor,BossEvent.BossBarOverlay bossBarOverlay,String bossBarName,boolean visible,ResourceLocation id ,List<AttriGether> attriGethers) {
34+
private List<AttrGether> attriGethers;
35+
public AttriGetherEffect(BossEvent.BossBarColor bossBarColor,BossEvent.BossBarOverlay bossBarOverlay,String bossBarName,boolean visible,ResourceLocation id ,List<AttrGether> attriGethers) {
3636
this.bossBarColor = bossBarColor;
3737
this.bossBarOverlay = bossBarOverlay;
3838
this.id = id;
@@ -68,11 +68,11 @@ public void setVisible(boolean visible) {
6868
this.visible = visible;
6969
}
7070

71-
public List<AttriGether> getAttriGethers() {
71+
public List<AttrGether> getAttriGethers() {
7272
return attriGethers;
7373
}
7474

75-
public void setAttriGethers(List<AttriGether> attriGethers) {
75+
public void setAttriGethers(List<AttrGether> attriGethers) {
7676
this.attriGethers = attriGethers;
7777
}
7878

src/main/java/net/exmo/exmodifier/content/attributeEffect/AttriGetherEffectHandle.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.google.gson.JsonObject;
44
import net.exmo.exmodifier.network.ExModifiervaV;
5-
import net.exmo.exmodifier.util.AttriGether;
5+
import net.exmo.exmodifier.util.gether.AttrGether;
66
import net.exmo.exmodifier.util.EntityAttrUtil;
77
import net.minecraft.network.chat.Component;
88
import net.minecraft.resources.ResourceLocation;
@@ -50,11 +50,11 @@ public static ServerBossEvent findBossBar(UUID uuid) {
5050

5151
@SubscribeEvent
5252
public static void init(FMLCommonSetupEvent event){
53-
registerEffect(new AttriGetherEffect(BossEvent.BossBarColor.BLUE, BossEvent.BossBarOverlay.PROGRESS,"§6睡眠之力",true,new ResourceLocation("exmodifier","sleep"), List.of(new AttriGether(Attributes.MAX_HEALTH, new AttributeModifier(UUID.fromString("7f7f7f7f-7f7f-7f7f-7f7f-7f7f7f7f7f7f"), "sleep", 10, AttributeModifier.Operation.ADDITION)))).setRandomAttrUUID(true));
53+
registerEffect(new AttriGetherEffect(BossEvent.BossBarColor.BLUE, BossEvent.BossBarOverlay.PROGRESS,"§6睡眠之力",true,new ResourceLocation("exmodifier","sleep"), List.of(new AttrGether(Attributes.MAX_HEALTH, new AttributeModifier(UUID.fromString("7f7f7f7f-7f7f-7f7f-7f7f-7f7f7f7f7f7f"), "sleep", 10, AttributeModifier.Operation.ADDITION)))).setRandomAttrUUID(true));
5454
registerEffect(new AttriGetherEffect(BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_6,"§4暴怒",true,new ResourceLocation("exmodifier","angry"), List.of(
55-
new AttriGether(Attributes.MAX_HEALTH, new AttributeModifier(UUID.fromString("7f7f7f7f-7f7f-7f7f-7f7f-7f7f7f7f7f6f"), "angry", 0.5, AttributeModifier.Operation.MULTIPLY_TOTAL)),
56-
new AttriGether(Attributes.ATTACK_DAMAGE, new AttributeModifier(UUID.fromString("7f7f7f7f-7f7f-7f7f-7f7f-7f7f7f7f7f5f"), "angry1", 0.5, AttributeModifier.Operation.MULTIPLY_TOTAL)),
57-
new AttriGether(Attributes.MOVEMENT_SPEED, new AttributeModifier(UUID.fromString("7f7f7f7f-7f7f-7f7f-7f7f-7f7f7f7f7f7f"), "angry2", 0.2, AttributeModifier.Operation.MULTIPLY_TOTAL))
55+
new AttrGether(Attributes.MAX_HEALTH, new AttributeModifier(UUID.fromString("7f7f7f7f-7f7f-7f7f-7f7f-7f7f7f7f7f6f"), "angry", 0.5, AttributeModifier.Operation.MULTIPLY_TOTAL)),
56+
new AttrGether(Attributes.ATTACK_DAMAGE, new AttributeModifier(UUID.fromString("7f7f7f7f-7f7f-7f7f-7f7f-7f7f7f7f7f5f"), "angry1", 0.5, AttributeModifier.Operation.MULTIPLY_TOTAL)),
57+
new AttrGether(Attributes.MOVEMENT_SPEED, new AttributeModifier(UUID.fromString("7f7f7f7f-7f7f-7f7f-7f7f-7f7f7f7f7f7f"), "angry2", 0.2, AttributeModifier.Operation.MULTIPLY_TOTAL))
5858
)).setRandomAttrUUID(true));
5959
}
6060
public static ServerBossEvent genBossBar(JsonObject jsonObject) {
@@ -92,18 +92,18 @@ public static UUID GenEffectModifierUUID(AttriGetherEffectInstance attriGetherEf
9292
return UUID.nameUUIDFromBytes((attriGetherEffectInstance.getUuid().toString()+uuid.toString()).getBytes());
9393
}
9494
public static void removeAttriGetherEffect(AttriGetherEffectInstance attriGetherEffectInstance, Player player) {
95-
for (AttriGether attriGether : attriGetherEffectInstance.getAttriGetherEffect().getAttriGethers()){
95+
for (AttrGether attriGether : attriGetherEffectInstance.getAttriGetherEffect().getAttriGethers()){
9696
if (attriGetherEffectInstance.randomAttrUUID){
97-
EntityAttrUtil.entityAddAttrTF(new AttriGether(attriGether.getAttribute(), attriGether.getModifier()).setModifierUUID(GenEffectModifierUUID(attriGetherEffectInstance, attriGether.modifier.getId())), player, EntityAttrUtil.WearOrTake.TAKE);
97+
EntityAttrUtil.entityAddAttrTF(new AttrGether(attriGether.getAttribute(), attriGether.getModifier()).setModifierUUID(GenEffectModifierUUID(attriGetherEffectInstance, attriGether.getModifier().getId())), player, EntityAttrUtil.WearOrTake.TAKE);
9898
}else EntityAttrUtil.entityAddAttrTF(attriGether, player, EntityAttrUtil.WearOrTake.TAKE);
9999
}
100100

101101
}
102102
public static void addEffectAttriGether(AttriGetherEffectInstance attriGetherEffectInstance, Player player) {
103-
for (AttriGether attriGether : attriGetherEffectInstance.getAttriGetherEffect().getAttriGethers())
103+
for (AttrGether attriGether : attriGetherEffectInstance.getAttriGetherEffect().getAttriGethers())
104104
{
105105
if (attriGetherEffectInstance.randomAttrUUID){
106-
EntityAttrUtil.entityAddAttrTF(new AttriGether(attriGether.getAttribute(), attriGether.getModifier()).setModifierUUID(GenEffectModifierUUID(attriGetherEffectInstance,attriGether.modifier.getId())), player, EntityAttrUtil.WearOrTake.WEAR);
106+
EntityAttrUtil.entityAddAttrTF(new AttrGether(attriGether.getAttribute(), attriGether.getModifier()).setModifierUUID(GenEffectModifierUUID(attriGetherEffectInstance,attriGether.getModifier().getId())), player, EntityAttrUtil.WearOrTake.WEAR);
107107
}
108108
else EntityAttrUtil.entityAddAttrTF(attriGether, player, EntityAttrUtil.WearOrTake.WEAR);
109109
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package net.exmo.exmodifier.content.attributeEffect.modern;
2+
3+
import net.exmo.exmodifier.Exmodifier;
4+
import net.minecraft.world.entity.LivingEntity;
5+
import net.minecraftforge.network.PacketDistributor;
6+
7+
8+
9+
public class CEEffectUtils {
10+
public static void applyEffect(LivingEntity entity, CustomEffectInstance effect) {
11+
entity.getCapability(CapabilityRegistration.CUSTOM_EFFECTS_CAP).ifPresent(cap -> {
12+
if (cap.getEffects().stream().anyMatch(e -> e.getEffectId().equals(effect.getEffectId())))cap.removeEffect(effect.getEffectId());
13+
cap.addEffect(effect);
14+
effect.applyAttributes(entity);
15+
// 同步到客户端
16+
Exmodifier.PACKET_HANDLER.send(PacketDistributor.TRACKING_ENTITY.with(() -> entity),
17+
new EffectSyncPacket(entity.getId(), EffectEventHandler.serializeNBT(effect), true));
18+
});
19+
}
20+
}

0 commit comments

Comments
 (0)