4
4
5
5
package leaf .cosmere .allomancy .common .manifestation ;
6
6
7
+ import leaf .cosmere .allomancy .client .AllomancyKeybindings ;
8
+ import leaf .cosmere .allomancy .common .Allomancy ;
9
+ import leaf .cosmere .allomancy .common .network .packets .EntityAllomancyActivateMessage ;
10
+ import leaf .cosmere .allomancy .common .registries .AllomancyEffects ;
7
11
import leaf .cosmere .api .CosmereAPI ;
8
12
import leaf .cosmere .api .Metals ;
13
+ import leaf .cosmere .api .helpers .EffectsHelper ;
9
14
import leaf .cosmere .api .helpers .EntityHelper ;
15
+ import leaf .cosmere .api .helpers .PlayerHelper ;
10
16
import leaf .cosmere .api .spiritweb .ISpiritweb ;
17
+ import leaf .cosmere .client .Keybindings ;
18
+ import leaf .cosmere .common .config .CosmereConfigs ;
11
19
import net .minecraft .world .entity .LivingEntity ;
12
20
import net .minecraft .world .entity .Mob ;
21
+ import net .minecraft .world .phys .EntityHitResult ;
22
+ import net .minecraft .world .phys .HitResult ;
13
23
14
- import java .util .Arrays ;
15
- import java .util .ConcurrentModificationException ;
16
- import java .util .HashMap ;
17
- import java .util .List ;
24
+ import java .util .*;
18
25
19
26
public class AllomancyBrass extends AllomancyManifestation
20
27
{
21
- private static final HashMap <String , BrassThread > playerThreadMap = new HashMap <>();
28
+ public static final HashMap <String , BrassThread > playerThreadMap = new HashMap <>();
22
29
23
30
public AllomancyBrass (Metals .MetalType metalType )
24
31
{
@@ -27,10 +34,38 @@ public AllomancyBrass(Metals.MetalType metalType)
27
34
28
35
//Dampens Emotions
29
36
@ Override
30
- protected void applyEffectTick (ISpiritweb data )
37
+ public void applyEffectTick (ISpiritweb data )
38
+ {
39
+ if (data .getLiving ().level .isClientSide ())
40
+ {
41
+ if (isActiveTick (data ))
42
+ {
43
+ boolean isSingleTarget = AllomancyKeybindings .ALLOMANCY_SOOTHE .isDown () || (Keybindings .MANIFESTATION_USE_ACTIVE .isDown () && data .getSelectedManifestation ().equals (getManifestation ()));
44
+ int singleTargetEntityId = 0 ;
45
+
46
+ if (isSingleTarget )
47
+ {
48
+ HitResult ray = PlayerHelper .pickWithRange (data .getLiving (), (int ) Math .floor (getRange (data ) * CosmereConfigs .SERVER_CONFIG .EMOTIONAL_POWERS_SINGLE_TARGET_RANGE_MULTIPLIER .get ()));
49
+ if (ray instanceof EntityHitResult entityHitResult )
50
+ {
51
+ singleTargetEntityId = entityHitResult .getEntity ().getId ();
52
+ }
53
+ }
54
+
55
+ Allomancy .packetHandler ().sendToServer (new EntityAllomancyActivateMessage (Metals .MetalType .BRASS , isSingleTarget , singleTargetEntityId ));
56
+ }
57
+ }
58
+ else
59
+ {
60
+ performEffectServer (data );
61
+ }
62
+ }
63
+
64
+ private void performEffectServer (ISpiritweb data )
31
65
{
32
66
int mode = getMode (data );
33
67
String uuid = data .getLiving ().getStringUUID ();
68
+ boolean isSingleTarget = playerThreadMap .get (data .getLiving ().getStringUUID ()).isSingleTarget ;
34
69
35
70
// data processing
36
71
{
@@ -48,25 +83,47 @@ protected void applyEffectTick(ISpiritweb data)
48
83
playerThreadMap .put (uuid , new BrassThread (data ));
49
84
}
50
85
51
- List <LivingEntity > entitiesToAffect = playerThreadMap .get (uuid ).requestEntityList ();
86
+ // don 't remove old code comments yet, still testing
87
+ List <LivingEntity > entitiesToAffect = new ArrayList <>();
88
+
89
+ if (isSingleTarget )
90
+ {
91
+ if (data .getLiving ().level .getEntity (playerThreadMap .get (uuid ).singleTargetEntityID ) instanceof LivingEntity entity )
92
+ {
93
+ entitiesToAffect .add (entity );
94
+ }
95
+ }
96
+ else
97
+ {
98
+ entitiesToAffect .addAll (playerThreadMap .get (uuid ).requestEntityList ());
99
+ }
100
+
52
101
for (LivingEntity e : entitiesToAffect )
53
102
{
54
103
if (e instanceof Mob mob )
55
104
{
56
- mob .setNoAi (mode == 3 && allomanticStrength > 15 );
57
-
58
105
switch (mode )
59
106
{
60
107
case 2 :
108
+ if (allomanticStrength > 15 )
109
+ mob .addEffect (EffectsHelper .getNewEffect (
110
+ AllomancyEffects .ALLOMANTIC_BRASS_STUN .getMobEffect (),
111
+ 0 , // no amplification system in place
112
+ 20 * 5
113
+ ));
61
114
mob .setTarget (null );
62
115
case 1 :
63
116
mob .setAggressive (false );
64
117
default ://stop angry targets from attacking things
65
- e .setLastHurtByMob (null );
118
+ mob .setLastHurtByMob (null );
66
119
}
67
120
}
68
121
}
69
- playerThreadMap .get (uuid ).releaseEntityList ();
122
+
123
+ if (!isSingleTarget )
124
+ {
125
+ playerThreadMap .get (uuid ).releaseEntityList ();
126
+ }
70
127
}
71
128
}
72
129
@@ -99,8 +156,10 @@ public boolean tick(ISpiritweb data)
99
156
return super .tick (data );
100
157
}
101
158
102
- class BrassThread extends AllomancyEntityThread
159
+ public class BrassThread extends AllomancyEntityThread
103
160
{
161
+ public boolean isSingleTarget = false ;
162
+ public int singleTargetEntityID = 0 ;
104
163
105
164
public BrassThread (ISpiritweb data )
106
165
{
0 commit comments