21
21
import net .minecraft .sounds .SoundEvents ;
22
22
import net .minecraft .sounds .SoundSource ;
23
23
import net .minecraft .world .InteractionHand ;
24
- import net .minecraft .world .InteractionResult ;
24
+ import net .minecraft .world .ItemInteractionResult ;
25
25
import net .minecraft .world .entity .decoration .ItemFrame ;
26
26
import net .minecraft .world .entity .item .ItemEntity ;
27
27
import net .minecraft .world .entity .player .Player ;
37
37
import net .minecraft .world .level .block .state .BlockState ;
38
38
import net .minecraft .world .level .block .state .properties .Property ;
39
39
import net .minecraft .world .level .chunk .ChunkAccess ;
40
- import net .minecraft .world .level .chunk .ChunkStatus ;
40
+ import net .minecraft .world .level .chunk .status . ChunkStatus ;
41
41
import net .minecraft .world .phys .AABB ;
42
42
import net .minecraft .world .phys .Vec3 ;
43
43
import net .neoforged .api .distmarker .Dist ;
46
46
import net .neoforged .neoforge .capabilities .ICapabilityProvider ;
47
47
import net .neoforged .neoforge .items .IItemHandler ;
48
48
import net .neoforged .neoforge .items .IItemHandlerModifiable ;
49
- import top .theillusivec4 .curios .api .CuriosApi ;
50
- import top .theillusivec4 .curios .api .SlotResult ;
51
49
52
50
import java .lang .reflect .Modifier ;
53
51
import java .util .List ;
@@ -116,7 +114,7 @@ public static int blendColors(int c1, int c2, float ratio) {
116
114
}
117
115
118
116
public static boolean areItemsEqual (ItemStack first , ItemStack second , boolean nbt ) {
119
- return nbt ? ItemStack .isSameItemSameTags (first , second ) : ItemStack .isSameItem (first , second );
117
+ return nbt ? ItemStack .isSameItemSameComponents (first , second ) : ItemStack .isSameItem (first , second );
120
118
}
121
119
122
120
@ OnlyIn (Dist .CLIENT )
@@ -132,34 +130,34 @@ public static void renderItemInGui(GuiGraphics graphics, ItemStack stack, int x,
132
130
}
133
131
134
132
@ OnlyIn (Dist .CLIENT )
135
- public static void renderWeirdBox (VertexConsumer buffer , double x , double y , double z , double width , double height , double depth , float r , float g , float b , float a ) {
136
- buffer .vertex (x , y + height , z ).color (r , g , b , a ). endVertex ( );
137
- buffer .vertex (x + width , y + height , z ).color (r , g , b , a ). endVertex ( );
138
- buffer .vertex (x + width , y , z ).color (r , g , b , a ). endVertex ( );
139
- buffer .vertex (x , y , z ).color (r , g , b , a ). endVertex ( );
140
- buffer .vertex (x + width , y , z + depth ).color (r , g , b , a ). endVertex ( );
141
- buffer .vertex (x + width , y , z ).color (r , g , b , a ). endVertex ( );
142
- buffer .vertex (x + width , y + height , z ).color (r , g , b , a ). endVertex ( );
143
- buffer .vertex (x + width , y + height , z + depth ).color (r , g , b , a ). endVertex ( );
144
- buffer .vertex (x + width , y + height , z + depth ).color (r , g , b , a ). endVertex ( );
145
- buffer .vertex (x , y + height , z + depth ).color (r , g , b , a ). endVertex ( );
146
- buffer .vertex (x , y , z + depth ).color (r , g , b , a ). endVertex ( );
147
- buffer .vertex (x + width , y , z + depth ).color (r , g , b , a ). endVertex ( );
148
- buffer .vertex (x , y + height , z + depth ).color (r , g , b , a ). endVertex ( );
149
- buffer .vertex (x , y + height , z ).color (r , g , b , a ). endVertex ( );
150
- buffer .vertex (x , y , z ).color (r , g , b , a ). endVertex ( );
151
- buffer .vertex (x , y , z + depth ).color (r , g , b , a ). endVertex ( );
152
- buffer .vertex (x , y + height , z ).color (r , g , b , a ). endVertex ( );
153
- buffer .vertex (x , y + height , z + depth ).color (r , g , b , a ). endVertex ( );
154
- buffer .vertex (x + width , y + height , z + depth ).color (r , g , b , a ). endVertex ( );
155
- buffer .vertex (x + width , y + height , z ).color (r , g , b , a ). endVertex ( );
156
- buffer .vertex (x + width , y , z ).color (r , g , b , a ). endVertex ( );
157
- buffer .vertex (x + width , y , z + depth ).color (r , g , b , a ). endVertex ( );
158
- buffer .vertex (x , y , z + depth ).color (r , g , b , a ). endVertex ( );
159
- buffer .vertex (x , y , z ).color (r , g , b , a ). endVertex ( );
133
+ public static void renderWeirdBox (VertexConsumer buffer , float x , float y , float z , float width , float height , float depth , float r , float g , float b , float a ) {
134
+ buffer .addVertex (x , y + height , z ).setColor (r , g , b , a );
135
+ buffer .addVertex (x + width , y + height , z ).setColor (r , g , b , a );
136
+ buffer .addVertex (x + width , y , z ).setColor (r , g , b , a );
137
+ buffer .addVertex (x , y , z ).setColor (r , g , b , a );
138
+ buffer .addVertex (x + width , y , z + depth ).setColor (r , g , b , a );
139
+ buffer .addVertex (x + width , y , z ).setColor (r , g , b , a );
140
+ buffer .addVertex (x + width , y + height , z ).setColor (r , g , b , a );
141
+ buffer .addVertex (x + width , y + height , z + depth ).setColor (r , g , b , a );
142
+ buffer .addVertex (x + width , y + height , z + depth ).setColor (r , g , b , a );
143
+ buffer .addVertex (x , y + height , z + depth ).setColor (r , g , b , a );
144
+ buffer .addVertex (x , y , z + depth ).setColor (r , g , b , a );
145
+ buffer .addVertex (x + width , y , z + depth ).setColor (r , g , b , a );
146
+ buffer .addVertex (x , y + height , z + depth ).setColor (r , g , b , a );
147
+ buffer .addVertex (x , y + height , z ).setColor (r , g , b , a );
148
+ buffer .addVertex (x , y , z ).setColor (r , g , b , a );
149
+ buffer .addVertex (x , y , z + depth ).setColor (r , g , b , a );
150
+ buffer .addVertex (x , y + height , z ).setColor (r , g , b , a );
151
+ buffer .addVertex (x , y + height , z + depth ).setColor (r , g , b , a );
152
+ buffer .addVertex (x + width , y + height , z + depth ).setColor (r , g , b , a );
153
+ buffer .addVertex (x + width , y + height , z ).setColor (r , g , b , a );
154
+ buffer .addVertex (x + width , y , z ).setColor (r , g , b , a );
155
+ buffer .addVertex (x + width , y , z + depth ).setColor (r , g , b , a );
156
+ buffer .addVertex (x , y , z + depth ).setColor (r , g , b , a );
157
+ buffer .addVertex (x , y , z ).setColor (r , g , b , a );
160
158
}
161
159
162
- public static InteractionResult putStackOnTile (Player player , InteractionHand hand , BlockPos pos , int slot , boolean sound ) {
160
+ public static ItemInteractionResult putStackOnTile (Player player , InteractionHand hand , BlockPos pos , int slot , boolean sound ) {
163
161
var tile = player .level ().getBlockEntity (pos );
164
162
if (tile instanceof BlockEntityImpl ) {
165
163
var handler = (IItemHandlerModifiable ) tile .getLevel ().getCapability (Capabilities .ItemHandler .BLOCK , tile .getBlockPos (), tile .getBlockState (), tile , null );
@@ -170,17 +168,17 @@ public static InteractionResult putStackOnTile(Player player, InteractionHand ha
170
168
if (!ItemStack .matches (remain , handStack )) {
171
169
if (sound )
172
170
player .level ().playSound (player , pos .getX () + 0.5 , pos .getY () + 0.5 , pos .getZ () + 0.5 ,
173
- SoundEvents .ITEM_FRAME_ADD_ITEM , SoundSource .PLAYERS , 0.75F , 1F );
171
+ SoundEvents .ITEM_FRAME_ADD_ITEM , SoundSource .PLAYERS , 0.75F , 1F );
174
172
if (!player .level ().isClientSide )
175
173
player .setItemInHand (hand , remain );
176
- return InteractionResult .SUCCESS ;
174
+ return ItemInteractionResult .SUCCESS ;
177
175
}
178
176
}
179
177
180
178
if (!handler .getStackInSlot (slot ).isEmpty ()) {
181
179
if (sound )
182
180
player .level ().playSound (player , pos .getX () + 0.5 , pos .getY () + 0.5 , pos .getZ () + 0.5 ,
183
- SoundEvents .ITEM_FRAME_REMOVE_ITEM , SoundSource .PLAYERS , 0.75F , 1F );
181
+ SoundEvents .ITEM_FRAME_REMOVE_ITEM , SoundSource .PLAYERS , 0.75F , 1F );
184
182
if (!player .level ().isClientSide ) {
185
183
var stack = handler .getStackInSlot (slot );
186
184
if (!player .addItem (stack )) {
@@ -189,11 +187,11 @@ public static InteractionResult putStackOnTile(Player player, InteractionHand ha
189
187
}
190
188
handler .setStackInSlot (slot , ItemStack .EMPTY );
191
189
}
192
- return InteractionResult .SUCCESS ;
190
+ return ItemInteractionResult .SUCCESS ;
193
191
}
194
192
}
195
193
}
196
- return InteractionResult . CONSUME ;
194
+ return ItemInteractionResult . PASS_TO_DEFAULT_BLOCK_INTERACTION ;
197
195
}
198
196
199
197
public static ICapabilityProvider <ItemStack , Void , IAuraRecharge > makeRechargeProvider (boolean needsSelected ) {
@@ -215,7 +213,7 @@ public static boolean rechargeAuraItem(ItemStack stack, IAuraContainer container
215
213
216
214
public static BlockState getStateFromString (String raw ) {
217
215
var split = raw .split ("\\ [" );
218
- var block = BuiltInRegistries .BLOCK .get (new ResourceLocation (split [0 ]));
216
+ var block = BuiltInRegistries .BLOCK .get (ResourceLocation . parse (split [0 ]));
219
217
if (block != null ) {
220
218
var state = block .defaultBlockState ();
221
219
if (split .length > 1 ) {
@@ -284,7 +282,7 @@ public static <T> void populateObjectHolders(Class<?> clazz, Registry<T> registr
284
282
for (var entry : clazz .getFields ()) {
285
283
if (!Modifier .isStatic (entry .getModifiers ()))
286
284
continue ;
287
- var location = new ResourceLocation (NaturesAura .MOD_ID , entry .getName ().toLowerCase (Locale .ROOT ));
285
+ var location = ResourceLocation . fromNamespaceAndPath (NaturesAura .MOD_ID , entry .getName ().toLowerCase (Locale .ROOT ));
288
286
if (!registry .containsKey (location )) {
289
287
NaturesAura .LOGGER .fatal ("Couldn't find entry named " + location + " in registry" );
290
288
continue ;
@@ -298,14 +296,15 @@ public static <T> void populateObjectHolders(Class<?> clazz, Registry<T> registr
298
296
}
299
297
300
298
public static ItemStack getEquippedItem (Predicate <ItemStack > predicate , Player player , boolean hotbarOnly ) {
301
- if (Compat .hasCompat ("curios" )) {
299
+ // TODO curios?
300
+ /* if (Compat.hasCompat("curios")) {
302
301
var inventory = CuriosApi.getCuriosInventory(player);
303
302
if (inventory.isPresent()) {
304
303
var stack = inventory.get().findFirstCurio(predicate).map(SlotResult::stack);
305
304
if (stack.isPresent())
306
305
return stack.get();
307
306
}
308
- }
307
+ }*/
309
308
var invSize = hotbarOnly ? 9 : player .getInventory ().getContainerSize ();
310
309
for (var i = 0 ; i < invSize ; i ++) {
311
310
var slot = player .getInventory ().getItem (i );
0 commit comments