1
1
package wayoftime .bloodmagic .compat ;
2
2
3
3
import net .minecraft .core .NonNullList ;
4
+ import net .minecraft .world .entity .ai .attributes .AttributeModifier ;
4
5
import net .minecraft .world .entity .player .Player ;
5
6
import net .minecraft .world .item .ItemStack ;
6
- import net .minecraftforge .fml .InterModComms ;
7
- import net .minecraftforge .fml .event .lifecycle .InterModEnqueueEvent ;
8
- import net .minecraftforge .items .IItemHandler ;
7
+ import net .minecraftforge .items .IItemHandlerModifiable ;
9
8
import top .theillusivec4 .curios .api .CuriosApi ;
10
- import top .theillusivec4 .curios .api .SlotTypeMessage ;
11
- import top .theillusivec4 .curios .api .SlotTypePreset ;
12
- import top .theillusivec4 .curios .api .type .util .ISlotHelper ;
13
- import wayoftime .bloodmagic .BloodMagic ;
9
+ import top .theillusivec4 .curios .api .type .inventory .ICurioStacksHandler ;
14
10
import wayoftime .bloodmagic .core .LivingArmorRegistrar ;
15
11
import wayoftime .bloodmagic .core .living .LivingStats ;
16
12
import wayoftime .bloodmagic .core .living .LivingUtil ;
17
13
import wayoftime .bloodmagic .impl .BloodMagicAPI ;
14
+ import java .util .Map ;
18
15
19
16
public class CuriosCompat
20
17
{
21
- public void setupSlots (InterModEnqueueEvent evt )
22
- {
23
- InterModComms .sendTo ("curios" , SlotTypeMessage .REGISTER_TYPE , () -> SlotTypePreset .NECKLACE .getMessageBuilder ().build ());
24
- InterModComms .sendTo ("curios" , SlotTypeMessage .REGISTER_TYPE , () -> SlotTypePreset .CHARM .getMessageBuilder ().build ());
25
- InterModComms .sendTo ("curios" , SlotTypeMessage .REGISTER_TYPE , () -> new SlotTypeMessage .Builder ("living_armour_socket" ).size (0 ).icon (BloodMagic .rl ("item/curios_empty_living_armour_socket" )).build ());
26
- }
27
-
28
18
public void registerInventory ()
29
19
{
30
20
BloodMagicAPI .INSTANCE .registerInventoryProvider ("curiosInventory" , player -> getCuriosInventory (player ));
@@ -33,8 +23,7 @@ public void registerInventory()
33
23
34
24
public NonNullList <ItemStack > getCuriosInventory (Player player )
35
25
{
36
- IItemHandler itemHandler = CuriosApi .getCuriosHelper ().getEquippedCurios (player ).resolve ().get ();
37
-
26
+ IItemHandlerModifiable itemHandler = CuriosApi .getCuriosInventory (player ).resolve ().get ().getEquippedCurios ();
38
27
NonNullList <ItemStack > inventory = NonNullList .create ();
39
28
for (int i = 0 ; i < itemHandler .getSlots (); i ++)
40
29
{
@@ -45,26 +34,20 @@ public NonNullList<ItemStack> getCuriosInventory(Player player)
45
34
46
35
public int recalculateCuriosSlots (Player player )
47
36
{
48
- ISlotHelper slotHelper = CuriosApi .getSlotHelper ( );
37
+ ICurioStacksHandler livingArmourSockets = CuriosApi .getCuriosInventory ( player ). resolve (). get (). getCurios (). get ( "living_armour_socket" );
49
38
if (LivingUtil .hasFullSet (player ))
50
39
{
51
40
LivingStats stats = LivingStats .fromPlayer (player );
52
-
53
- int curiosLevel = stats != null ? stats .getLevel (LivingArmorRegistrar .UPGRADE_CURIOS_SOCKET .get ().getKey ())
54
- : 0 ;
55
-
56
- if (curiosLevel == 0 )
57
- {
58
- slotHelper .setSlotsForType ("living_armour_socket" , player , 0 );
59
- } else
41
+ int curiosLevel = (stats != null ) ? stats .getLevel (LivingArmorRegistrar .UPGRADE_CURIOS_SOCKET .get ().getKey ()) : 0 ;
42
+ livingArmourSockets .removeModifier (player .getUUID ());
43
+ if (curiosLevel != 0 )
60
44
{
61
- int slotCount = LivingArmorRegistrar .UPGRADE_CURIOS_SOCKET .get ().getBonusValue ("slots" , curiosLevel ).intValue ();
62
- slotHelper .setSlotsForType ("living_armour_socket" , player , slotCount );
45
+ livingArmourSockets .addTransientModifier (new AttributeModifier (player .getUUID (), "legacy" , Double .valueOf (LivingArmorRegistrar .UPGRADE_CURIOS_SOCKET .get ().getBonusValue ("slots" , curiosLevel ).intValue ()), AttributeModifier .Operation .ADDITION ));
63
46
}
64
47
return curiosLevel ;
65
48
} else
66
49
{
67
- slotHelper . setSlotsForType ( "living_armour_socket" , player , 0 );
50
+ livingArmourSockets . removeModifier ( player . getUUID () );
68
51
return 0 ;
69
52
}
70
53
}
0 commit comments