|
15 | 15 | import net.minecraft.client.gui.GuiGraphics;
|
16 | 16 | import net.minecraft.core.BlockPos;
|
17 | 17 | import net.minecraft.core.Direction;
|
| 18 | +import net.minecraft.core.Registry; |
| 19 | +import net.minecraft.core.registries.BuiltInRegistries; |
18 | 20 | import net.minecraft.resources.ResourceLocation;
|
19 | 21 | import net.minecraft.server.level.ServerChunkCache;
|
20 | 22 | import net.minecraft.server.level.ServerPlayer;
|
|
42 | 44 | import net.minecraft.world.phys.Vec3;
|
43 | 45 | import net.neoforged.api.distmarker.Dist;
|
44 | 46 | import net.neoforged.api.distmarker.OnlyIn;
|
45 |
| -import net.neoforged.neoforge.common.capabilities.Capability; |
46 |
| -import net.neoforged.neoforge.common.util.LazyOptional; |
| 47 | +import net.neoforged.neoforge.capabilities.Capabilities; |
47 | 48 | import net.neoforged.neoforge.items.IItemHandler;
|
48 |
| -import net.neoforged.neoforge.registries.ForgeRegistries; |
49 |
| -import net.neoforged.neoforge.registries.IForgeRegistry; |
50 |
| -import net.neoforged.neoforge.common.capabilities.ICapabilityProvider; |
| 49 | +import net.neoforged.neoforge.items.IItemHandlerModifiable; |
51 | 50 | import top.theillusivec4.curios.api.CuriosApi;
|
52 | 51 | import top.theillusivec4.curios.api.SlotResult;
|
53 | 52 |
|
@@ -167,7 +166,7 @@ public static void renderWeirdBox(VertexConsumer buffer, double x, double y, dou
|
167 | 166 | public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
|
168 | 167 | var tile = player.level().getBlockEntity(pos);
|
169 | 168 | if (tile instanceof BlockEntityImpl) {
|
170 |
| - var handler = ((BlockEntityImpl) tile).getItemHandler(); |
| 169 | + var handler = (IItemHandlerModifiable) tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null); |
171 | 170 | if (handler != null) {
|
172 | 171 | var handStack = player.getItemInHand(hand);
|
173 | 172 | if (!handStack.isEmpty()) {
|
@@ -230,7 +229,7 @@ public static boolean rechargeAuraItem(ItemStack stack, IAuraContainer container
|
230 | 229 |
|
231 | 230 | public static BlockState getStateFromString(String raw) {
|
232 | 231 | var split = raw.split("\\[");
|
233 |
| - var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(split[0])); |
| 232 | + var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(split[0])); |
234 | 233 | if (block != null) {
|
235 | 234 | var state = block.defaultBlockState();
|
236 | 235 | if (split.length > 1) {
|
@@ -261,7 +260,7 @@ private static <T extends Comparable<T>> BlockState findProperty(BlockState stat
|
261 | 260 | public static void addAdvancement(Player player, ResourceLocation advancement, String criterion) {
|
262 | 261 | if (!(player instanceof ServerPlayer playerMp))
|
263 | 262 | return;
|
264 |
| - var adv = playerMp.level().getServer().getAdvancements().getAdvancement(advancement); |
| 263 | + var adv = playerMp.level().getServer().getAdvancements().get(advancement); |
265 | 264 | if (adv != null)
|
266 | 265 | playerMp.getAdvancements().award(adv, criterion);
|
267 | 266 | }
|
@@ -295,17 +294,17 @@ public static AABB aabb(Vec3 pos) {
|
295 | 294 | }
|
296 | 295 |
|
297 | 296 | // This is how @ObjectHolder SHOULD work...
|
298 |
| - public static <T> void populateObjectHolders(Class<?> clazz, IForgeRegistry<T> registry) { |
| 297 | + public static <T> void populateObjectHolders(Class<?> clazz, Registry<T> registry) { |
299 | 298 | for (var entry : clazz.getFields()) {
|
300 | 299 | if (!Modifier.isStatic(entry.getModifiers()))
|
301 | 300 | continue;
|
302 | 301 | var location = new ResourceLocation(NaturesAura.MOD_ID, entry.getName().toLowerCase(Locale.ROOT));
|
303 | 302 | if (!registry.containsKey(location)) {
|
304 |
| - NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry " + registry.getRegistryName()); |
| 303 | + NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry"); |
305 | 304 | continue;
|
306 | 305 | }
|
307 | 306 | try {
|
308 |
| - entry.set(null, registry.getValue(location)); |
| 307 | + entry.set(null, registry.get(location)); |
309 | 308 | } catch (IllegalAccessException e) {
|
310 | 309 | NaturesAura.LOGGER.error(e);
|
311 | 310 | }
|
|
0 commit comments