Skip to content

Commit 290fd8c

Browse files
authored
Merge pull request #80
Allomantic Brass TLC
2 parents 77a2e9e + 4f42076 commit 290fd8c

File tree

76 files changed

+319
-40
lines changed

Some content is hidden

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

76 files changed

+319
-40
lines changed

src/allomancy/java/leaf/cosmere/allomancy/client/AllomancyKeybindings.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@
1818
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = Allomancy.MODID, bus = Bus.MOD)
1919
public class AllomancyKeybindings
2020
{
21-
public static KeyMapping ALLOMANCY_PUSH;
22-
public static KeyMapping ALLOMANCY_PULL;
21+
public static KeyMapping ALLOMANCY_STEEL_PUSH;
22+
public static KeyMapping ALLOMANCY_IRON_PULL;
23+
public static KeyMapping ALLOMANCY_SOOTHE;
24+
public static KeyMapping ALLOMANCY_RIOT;
2325

2426
@SubscribeEvent
2527
public static void register(RegisterKeyMappingsEvent event)
2628
{
27-
event.register(ALLOMANCY_PUSH = new KeyMapping(KEY_ALLOMANCY_PUSH, GLFW.GLFW_KEY_TAB, KEYS_CATEGORY));
28-
event.register(ALLOMANCY_PULL = new KeyMapping(KEY_ALLOMANCY_PULL, GLFW.GLFW_KEY_R, KEYS_CATEGORY));
29+
event.register(ALLOMANCY_STEEL_PUSH = new KeyMapping(KEY_ALLOMANCY_STEEL_PUSH, GLFW.GLFW_KEY_TAB, KEYS_CATEGORY));
30+
event.register(ALLOMANCY_IRON_PULL = new KeyMapping(KEY_ALLOMANCY_IRON_PULL, GLFW.GLFW_KEY_R, KEYS_CATEGORY));
31+
event.register(ALLOMANCY_SOOTHE = new KeyMapping(KEY_ALLOMANCY_SOOTHE, GLFW.GLFW_KEY_UNKNOWN, KEYS_CATEGORY));
32+
event.register(ALLOMANCY_RIOT = new KeyMapping(KEY_ALLOMANCY_RIOT, GLFW.GLFW_KEY_UNKNOWN, KEYS_CATEGORY));
2933
}
3034

3135
}

src/allomancy/java/leaf/cosmere/allomancy/common/Allomancy.java

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public Allomancy()
4747
AllomancyItems.ITEMS.register(modBus);
4848
AllomancyAttributes.ATTRIBUTES.register(modBus);
4949
AllomancyEffects.EFFECTS.register(modBus);
50+
AllomancyEffects.MOB_EFFECTS.register(modBus);
5051
AllomancyEntityTypes.ENTITY_TYPES.register(modBus);
5152
AllomancyManifestations.MANIFESTATIONS.register(modBus);
5253
AllomancyMenuTypes.MENU_TYPES.register(modBus);

src/allomancy/java/leaf/cosmere/allomancy/common/capabilities/AllomancySpiritwebSubmodule.java

+23-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
import leaf.cosmere.allomancy.common.Allomancy;
1111
import leaf.cosmere.allomancy.common.config.AllomancyConfigs;
1212
import leaf.cosmere.allomancy.common.items.MetalVialItem;
13-
import leaf.cosmere.allomancy.common.manifestation.AllomancyIronSteel;
14-
import leaf.cosmere.allomancy.common.manifestation.AllomancyManifestation;
15-
import leaf.cosmere.allomancy.common.manifestation.AllomancyTin;
13+
import leaf.cosmere.allomancy.common.manifestation.*;
1614
import leaf.cosmere.allomancy.common.registries.AllomancyItems;
1715
import leaf.cosmere.allomancy.common.registries.AllomancyManifestations;
1816
import leaf.cosmere.api.ISpiritwebSubmodule;
@@ -94,6 +92,28 @@ public void tickClient(ISpiritweb spiritweb)
9492
tin.applyEffectTick(spiritweb);
9593
}
9694
}
95+
96+
//brass allomancy
97+
{
98+
AllomancyBrass brass = (AllomancyBrass) AllomancyManifestations.ALLOMANCY_POWERS.get(Metals.MetalType.BRASS).get();
99+
final boolean brassActive = brass.isActive(spiritweb);
100+
101+
if (brassActive && !brass.isCompounding(spiritweb))
102+
{
103+
brass.applyEffectTick(spiritweb);
104+
}
105+
}
106+
107+
//brass allomancy
108+
{
109+
AllomancyZinc zinc = (AllomancyZinc) AllomancyManifestations.ALLOMANCY_POWERS.get(Metals.MetalType.ZINC).get();
110+
final boolean zincActive = zinc.isActive(spiritweb);
111+
112+
if (zincActive && !zinc.isCompounding(spiritweb))
113+
{
114+
zinc.applyEffectTick(spiritweb);
115+
}
116+
}
97117
}
98118

99119
@Override

src/allomancy/java/leaf/cosmere/allomancy/common/effects/AllomancyBoostEffect.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public AllomancyBoostEffect()
2424
{
2525
addAttributeModifier(
2626
AllomancyAttributes.ALLOMANCY_ATTRIBUTES.get(metalType).get(),
27-
0.334D,// todo config - Need to figure out an alternative to config boost amount //AllomancyConfigs.SERVER.boostAmount.get(),
27+
0.223,// todo config - Need to figure out an alternative to config boost amount //AllomancyConfigs.SERVER.boostAmount.get(),
2828
AttributeModifier.Operation.MULTIPLY_TOTAL);
2929
//todo boost other manifestation types
3030

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package leaf.cosmere.allomancy.common.effects;
2+
3+
import net.minecraft.world.effect.MobEffect;
4+
import net.minecraft.world.effect.MobEffectCategory;
5+
import net.minecraft.world.entity.LivingEntity;
6+
import net.minecraft.world.entity.Mob;
7+
import net.minecraft.world.entity.ai.attributes.AttributeMap;
8+
9+
public class BrassStunEffect extends MobEffect
10+
{
11+
public BrassStunEffect(MobEffectCategory category, int color)
12+
{
13+
super(category, color);
14+
}
15+
16+
@Override
17+
public void addAttributeModifiers(LivingEntity pLivingEntity, AttributeMap pAttributeMap, int pAmplifier)
18+
{
19+
if (pLivingEntity instanceof Mob mob)
20+
{
21+
mob.setNoAi(true);
22+
}
23+
super.addAttributeModifiers(pLivingEntity, pAttributeMap, pAmplifier);
24+
}
25+
26+
@Override
27+
public void removeAttributeModifiers(LivingEntity pLivingEntity, AttributeMap pAttributeMap, int pAmplifier)
28+
{
29+
if (pLivingEntity instanceof Mob mob)
30+
{
31+
mob.setNoAi(false);
32+
}
33+
super.removeAttributeModifiers(pLivingEntity, pAttributeMap, pAmplifier);
34+
}
35+
}

src/allomancy/java/leaf/cosmere/allomancy/common/items/CoinPouchItem.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera
9191
NetworkHooks.openScreen((ServerPlayer) player, container, buf -> buf.writeBoolean(true));
9292
}
9393
}
94-
else if (player.level.isClientSide && AllomancyKeybindings.ALLOMANCY_PUSH.isDown())
94+
else if (player.level.isClientSide && AllomancyKeybindings.ALLOMANCY_STEEL_PUSH.isDown())
9595
{
9696
//assume they wanna shoot a projectile
9797
//so let them tell the server

src/allomancy/java/leaf/cosmere/allomancy/common/manifestation/AllomancyBrass.java

+71-12
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,28 @@
44

55
package leaf.cosmere.allomancy.common.manifestation;
66

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;
711
import leaf.cosmere.api.CosmereAPI;
812
import leaf.cosmere.api.Metals;
13+
import leaf.cosmere.api.helpers.EffectsHelper;
914
import leaf.cosmere.api.helpers.EntityHelper;
15+
import leaf.cosmere.api.helpers.PlayerHelper;
1016
import leaf.cosmere.api.spiritweb.ISpiritweb;
17+
import leaf.cosmere.client.Keybindings;
18+
import leaf.cosmere.common.config.CosmereConfigs;
1119
import net.minecraft.world.entity.LivingEntity;
1220
import net.minecraft.world.entity.Mob;
21+
import net.minecraft.world.phys.EntityHitResult;
22+
import net.minecraft.world.phys.HitResult;
1323

14-
import java.util.Arrays;
15-
import java.util.ConcurrentModificationException;
16-
import java.util.HashMap;
17-
import java.util.List;
24+
import java.util.*;
1825

1926
public class AllomancyBrass extends AllomancyManifestation
2027
{
21-
private static final HashMap<String, BrassThread> playerThreadMap = new HashMap<>();
28+
public static final HashMap<String, BrassThread> playerThreadMap = new HashMap<>();
2229

2330
public AllomancyBrass(Metals.MetalType metalType)
2431
{
@@ -27,10 +34,38 @@ public AllomancyBrass(Metals.MetalType metalType)
2734

2835
//Dampens Emotions
2936
@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)
3165
{
3266
int mode = getMode(data);
3367
String uuid = data.getLiving().getStringUUID();
68+
boolean isSingleTarget = playerThreadMap.get(data.getLiving().getStringUUID()).isSingleTarget;
3469

3570
// data processing
3671
{
@@ -48,25 +83,47 @@ protected void applyEffectTick(ISpiritweb data)
4883
playerThreadMap.put(uuid, new BrassThread(data));
4984
}
5085

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+
52101
for (LivingEntity e : entitiesToAffect)
53102
{
54103
if (e instanceof Mob mob)
55104
{
56-
mob.setNoAi(mode == 3 && allomanticStrength > 15);
57-
58105
switch (mode)
59106
{
60107
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+
));
61114
mob.setTarget(null);
62115
case 1:
63116
mob.setAggressive(false);
64117
default://stop angry targets from attacking things
65-
e.setLastHurtByMob(null);
118+
mob.setLastHurtByMob(null);
66119
}
67120
}
68121
}
69-
playerThreadMap.get(uuid).releaseEntityList();
122+
123+
if (!isSingleTarget)
124+
{
125+
playerThreadMap.get(uuid).releaseEntityList();
126+
}
70127
}
71128
}
72129

@@ -99,8 +156,10 @@ public boolean tick(ISpiritweb data)
99156
return super.tick(data);
100157
}
101158

102-
class BrassThread extends AllomancyEntityThread
159+
public class BrassThread extends AllomancyEntityThread
103160
{
161+
public boolean isSingleTarget = false;
162+
public int singleTargetEntityID = 0;
104163

105164
public BrassThread(ISpiritweb data)
106165
{

src/allomancy/java/leaf/cosmere/allomancy/common/manifestation/AllomancyManifestation.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@ protected KeyMapping getKeyBinding()
235235
{
236236
if (getMetalType().isPullMetal())
237237
{
238-
return AllomancyKeybindings.ALLOMANCY_PULL;
238+
return AllomancyKeybindings.ALLOMANCY_IRON_PULL;
239239
}
240240
else if (getMetalType().isPushMetal())
241241
{
242-
return AllomancyKeybindings.ALLOMANCY_PUSH;
242+
return AllomancyKeybindings.ALLOMANCY_STEEL_PUSH;
243243
}
244244

245245
return null;

0 commit comments

Comments
 (0)