diff --git a/build.gradle b/build.gradle index 0e8b5f9f..248ccbad 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ if (System.getenv('BUILD_NUMBER') != null) { java.toolchain.languageVersion = JavaLanguageVersion.of(17) minecraft { - mappings channel: 'official', version: '1.18.2' + mappings channel: 'official', version: '1.19' runs { client { @@ -102,16 +102,16 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.18.2-40.0.3' + minecraft 'net.minecraftforge:forge:1.19-41.0.45' - compileOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.117:api") - runtimeOnly fg.deobf("mezz.jei:jei-1.18.2:9.4.1.117") + compileOnly fg.deobf("mezz.jei:jei-1.19-common-api:11.0.0.206") + runtimeOnly fg.deobf("mezz.jei:jei-1.19-forge:11.0.0.206") - compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.2-66-SNAPSHOT:api") - runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.2-66-SNAPSHOT") + compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.19-73:api") + runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.19-73") - runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.2-5.0.6.3") - compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.2-5.0.6.3:api") + runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.19-5.1.0.2") + compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.19-5.1.0.2:api") // TODO Enchantability /* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/ diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 8abdb955..63c633f8 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -2,7 +2,6 @@ package de.ellpeck.naturesaura; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.datafixers.util.Either; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; @@ -15,7 +14,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; @@ -36,7 +34,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkStatus; -import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; @@ -47,7 +44,6 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; import org.apache.commons.lang3.tuple.ImmutableTriple; import top.theillusivec4.curios.api.CuriosApi; @@ -56,7 +52,6 @@ import javax.annotation.Nullable; import java.lang.reflect.Modifier; import java.util.List; import java.util.Locale; -import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; @@ -66,7 +61,7 @@ public final class Helper { public static boolean getBlockEntitiesInArea(LevelAccessor level, BlockPos pos, int radius, Function consumer) { for (var x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) { for (var z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) { - var chunk = getLoadedChunk(level, x, z); + var chunk = Helper.getLoadedChunk(level, x, z); if (chunk != null) { for (var tilePos : chunk.getBlockEntitiesPos()) { if (tilePos.distSqr(pos) <= radius * radius) @@ -206,7 +201,7 @@ public final class Helper { return new ICapabilityProvider() { private final LazyOptional recharge = LazyOptional.of(() -> (container, containerSlot, itemSlot, isSelected) -> { if (isSelected || !needsSelected) - return rechargeAuraItem(stack, container, 300); + return Helper.rechargeAuraItem(stack, container, 300); return false; }); @@ -238,7 +233,7 @@ public final class Helper { for (var part : split[1].replace("]", "").split(",")) { var keyValue = part.split("="); for (var prop : state.getProperties()) { - var changed = findProperty(state, prop, keyValue[0], keyValue[1]); + var changed = Helper.findProperty(state, prop, keyValue[0], keyValue[1]); if (changed != null) { state = changed; break; @@ -296,7 +291,7 @@ public final class Helper { } // This is how @ObjectHolder SHOULD work... - public static > void populateObjectHolders(Class clazz, IForgeRegistry registry) { + public static void populateObjectHolders(Class clazz, IForgeRegistry registry) { for (var entry : clazz.getFields()) { if (!Modifier.isStatic(entry.getModifiers())) continue; diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 690d5388..35f8f248 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -31,8 +31,8 @@ public final class NaturesAura { public static final String MOD_ID = NaturesAuraAPI.MOD_ID; public static final String MOD_NAME = "Nature's Aura"; - public static final Logger LOGGER = LogManager.getLogger(MOD_NAME); - public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(MOD_ID) { + public static final Logger LOGGER = LogManager.getLogger(NaturesAura.MOD_NAME); + public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(NaturesAura.MOD_ID) { @Override public ItemStack makeIcon() { return new ItemStack(ModItems.GOLD_LEAF); @@ -44,7 +44,7 @@ public final class NaturesAura { public static IProxy proxy = DistExecutor.unsafeRunForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy()); public NaturesAura() { - instance = this; + NaturesAura.instance = this; FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); var builder = new ForgeConfigSpec.Builder(); @@ -65,7 +65,7 @@ public final class NaturesAura { MinecraftForge.EVENT_BUS.register(new CommonEvents()); - proxy.preInit(event); + NaturesAura.proxy.preInit(event); } private void init(FMLCommonSetupEvent event) { @@ -75,16 +75,16 @@ public final class NaturesAura { ModRegistry.init(); DrainSpotEffects.init(); - proxy.init(event); + NaturesAura.proxy.init(event); } private void postInit(FMLCommonSetupEvent event) { - proxy.postInit(event); + NaturesAura.proxy.postInit(event); - LOGGER.info("-- Nature's Aura Fake Player Information --"); - LOGGER.info("Name: [Minecraft]"); - LOGGER.info("UUID: 41C82C87-7AfB-4024-BA57-13D2C99CAE77"); - LOGGER.info(Strings.padStart("", 43, '-')); + NaturesAura.LOGGER.info("-- Nature's Aura Fake Player Information --"); + NaturesAura.LOGGER.info("Name: [Minecraft]"); + NaturesAura.LOGGER.info("UUID: 41C82C87-7AfB-4024-BA57-13D2C99CAE77"); + NaturesAura.LOGGER.info(Strings.padStart("", 43, '-')); } } diff --git a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java index 73bd1e56..8ad478fd 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java +++ b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java @@ -56,10 +56,10 @@ public final class NaturesAuraAPI { * easily registered using {@link BasicAuraType#register()}. */ public static final Map AURA_TYPES = new HashMap<>(); - public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(MOD_ID, "overworld"), Level.OVERWORLD, 0x89cc37, 0).register(); - public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(MOD_ID, "nether"), Level.NETHER, 0x871c0c, 0).register(); - public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), Level.END, 0x302624, 0).register(); - public static final BasicAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register(); + public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "overworld"), Level.OVERWORLD, 0x89cc37, 0).register(); + public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "nether"), Level.NETHER, 0x871c0c, 0).register(); + public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "end"), Level.END, 0x302624, 0).register(); + public static final BasicAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(NaturesAuraAPI.MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register(); /** * A map of all {@link IDrainSpotEffect} suppliers which are effects that * happen passively at every spot that Aura has been drained from in the @@ -150,7 +150,7 @@ public final class NaturesAuraAPI { * @return The active {@link IInternalHooks} instance */ public static IInternalHooks instance() { - return INSTANCE; + return NaturesAuraAPI.INSTANCE; } /** diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java index 4a353052..f9d87c17 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java @@ -24,7 +24,7 @@ public interface IDrainSpotEffect { return ItemStack.EMPTY; } - public enum ActiveType { + enum ActiveType { INACTIVE, INHIBITED, ACTIVE } } diff --git a/src/main/java/de/ellpeck/naturesaura/api/misc/ILevelData.java b/src/main/java/de/ellpeck/naturesaura/api/misc/ILevelData.java index acd76ede..6408f41c 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/misc/ILevelData.java +++ b/src/main/java/de/ellpeck/naturesaura/api/misc/ILevelData.java @@ -15,8 +15,8 @@ public interface ILevelData extends ICapabilityProvider, INBTSerializable(BlockEntityAncientLeaves::new, this)); + ModRegistry.ALL_ITEMS.add(this); + ModRegistry.ALL_ITEMS.add(new ModTileType(BlockEntityAncientLeaves::new, this)); } @Override @@ -50,7 +51,7 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) { super.animateTick(stateIn, levelIn, pos, rand); if (rand.nextFloat() >= 0.95F && !levelIn.getBlockState(pos.below()).isCollisionShapeFullBlock(levelIn, pos)) { var tile = levelIn.getBlockEntity(pos); @@ -69,7 +70,7 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP } @Override - public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) { super.randomTick(state, levelIn, pos, random); if (!levelIn.isClientSide) { var tile = levelIn.getBlockEntity(pos); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java index 65f792b8..47513057 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java @@ -16,7 +16,7 @@ public class BlockAncientLog extends RotatedPillarBlock implements IModItem, ICu public BlockAncientLog(String baseName) { super(Properties.of(Material.WOOD, MaterialColor.COLOR_PURPLE).strength(2.0F).sound(SoundType.WOOD)); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java index 1321175d..fa46d62c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java @@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.reg.*; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.*; @@ -17,25 +18,24 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.event.ForgeEventFactory; -import java.util.Random; import java.util.function.Supplier; public class BlockAncientSapling extends BushBlock implements BonemealableBlock, IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType { - protected static final VoxelShape SHAPE = box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); + protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); public BlockAncientSapling() { super(Properties.of(Material.GRASS).strength(0.0F).sound(SoundType.GRASS)); - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockAncientSapling.SHAPE; } @Override - public void randomTick(BlockState state, ServerLevel level, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!level.isClientSide) { super.randomTick(state, level, pos, random); @@ -60,12 +60,12 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock, } @Override - public boolean isBonemealSuccess(Level level, Random rand, BlockPos pos, BlockState state) { + public boolean isBonemealSuccess(Level level, RandomSource rand, BlockPos pos, BlockState state) { return level.random.nextFloat() < 0.45F; } @Override - public void performBonemeal(ServerLevel level, Random rand, BlockPos pos, BlockState state) { + public void performBonemeal(ServerLevel level, RandomSource rand, BlockPos pos, BlockState state) { if (state.getValue(SaplingBlock.STAGE) == 0) { level.setBlock(pos, state.cycle(SaplingBlock.STAGE), 4); } else if (ForgeEventFactory.saplingGrowTree(level, rand, pos)) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java index e1707e37..4f591cec 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java @@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; @@ -17,7 +18,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable, ICustomBlockState { - private static final VoxelShape SHAPE = box(5, 0, 5, 11, 13, 11); + private static final VoxelShape SHAPE = Block.box(5, 0, 5, 11, 13, 11); public BlockAnimalContainer() { super("animal_container", BlockEntityAnimalContainer.class, Properties.copy(Blocks.STONE)); @@ -30,7 +31,7 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockAnimalContainer.SHAPE; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java index 4918392b..84b5b9d1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java @@ -39,7 +39,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS super(Properties.of(Material.PLANT).noCollission().strength(0).sound(SoundType.GRASS)); this.baseName = baseName; this.allowedGround = allowedGround; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override @@ -62,7 +62,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { var vec3d = state.getOffset(levelIn, pos); - return SHAPE.move(vec3d.x, vec3d.y, vec3d.z); + return BlockAuraBloom.SHAPE.move(vec3d.x, vec3d.y, vec3d.z); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java index 433524db..affa566e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java @@ -13,6 +13,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -32,7 +33,7 @@ import java.util.function.Supplier; public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockState, ITESRProvider, ICustomRenderType { - private static final VoxelShape SHAPE = box(1, 0, 1, 15, 15, 15); + private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 15, 15); public BlockAuraTimer() { super("aura_timer", BlockEntityAuraTimer.class, Properties.copy(Blocks.SMOOTH_STONE)); @@ -46,7 +47,7 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockAuraTimer.SHAPE; } @Override @@ -75,7 +76,7 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt } @Override - public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) { super.tick(state, levelIn, pos, random); if (state.getValue(BlockStateProperties.POWERED)) levelIn.setBlockAndUpdate(pos, state.setValue(BlockStateProperties.POWERED, false)); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java index 4c1cc228..cf3cc0a3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java @@ -23,12 +23,12 @@ public class BlockAutoCrafter extends BlockContainerImpl implements ICustomBlock @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); - builder.add(FACING); + builder.add(BlockAutoCrafter.FACING); } @Override public BlockState getStateForPlacement(BlockPlaceContext context) { - return super.getStateForPlacement(context).setValue(FACING, context.getPlayer().getDirection()); + return super.getStateForPlacement(context).setValue(BlockAutoCrafter.FACING, context.getPlayer().getDirection()); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java index aa21a732..ab3cc853 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockBlastFurnaceBooster.java @@ -32,18 +32,18 @@ public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICus @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockBlastFurnaceBooster.SHAPE; } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); - builder.add(FACING); + builder.add(BlockBlastFurnaceBooster.FACING); } @Override public BlockState getStateForPlacement(BlockPlaceContext context) { - return super.getStateForPlacement(context).setValue(FACING, context.getHorizontalDirection().getOpposite()); + return super.getStateForPlacement(context).setValue(BlockBlastFurnaceBooster.FACING, context.getHorizontalDirection().getOpposite()); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockCatalyst.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockCatalyst.java index 8f7f44dd..ae23bf92 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockCatalyst.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockCatalyst.java @@ -16,19 +16,19 @@ public class BlockCatalyst extends BlockImpl implements ICustomBlockState { public BlockCatalyst(String baseName, Properties properties) { super(baseName, properties); - this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false)); + this.registerDefaultState(this.defaultBlockState().setValue(BlockCatalyst.NETHER, false)); } @Override public BlockState getStateForPlacement(BlockPlaceContext context) { var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER); - return super.getStateForPlacement(context).setValue(NETHER, nether); + return super.getStateForPlacement(context).setValue(BlockCatalyst.NETHER, nether); } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); - builder.add(NETHER); + builder.add(BlockCatalyst.NETHER); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java index 8cc9314c..6685e8bd 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java @@ -9,8 +9,10 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; @@ -20,11 +22,9 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.Random; - public class BlockChunkLoader extends BlockContainerImpl implements IVisualizable, ICustomBlockState { - private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12); + private static final VoxelShape SHAPE = Block.box(4, 4, 4, 12, 12, 12); public BlockChunkLoader() { super("chunk_loader", BlockEntityChunkLoader.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE)); @@ -43,12 +43,12 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl var range = ((BlockEntityChunkLoader) tile).range(); if (range > 0) { return new AABB( - (pos.getX() - range) >> 4 << 4, + pos.getX() - range >> 4 << 4, 0, - (pos.getZ() - range) >> 4 << 4, - ((pos.getX() + range) >> 4 << 4) + 16, + pos.getZ() - range >> 4 << 4, + (pos.getX() + range >> 4 << 4) + 16, level.getHeight(), - ((pos.getZ() + range) >> 4 << 4) + 16); + (pos.getZ() + range >> 4 << 4) + 16); } } return null; @@ -56,7 +56,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) { if (!ModConfig.instance.chunkLoader.get()) return; var tile = levelIn.getBlockEntity(pos); @@ -78,7 +78,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockChunkLoader.SHAPE; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java index 68c4b786..eab44aca 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java @@ -9,6 +9,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.FluidTags; +import net.minecraft.util.RandomSource; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -48,8 +49,8 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem { this.tileClass = tileClass; this.tileType = new ModTileType<>(this::createBlockEntity, this); - ModRegistry.add(this); - ModRegistry.add(this.tileType); + ModRegistry.ALL_ITEMS.add(this); + ModRegistry.ALL_ITEMS.add(this.tileType); if (this.hasWaterlogging()) this.registerDefaultState(this.stateDefinition.any().setValue(BlockStateProperties.WATERLOGGED, false)); @@ -166,7 +167,7 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem { } @Override - public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) { if (!levelIn.isClientSide) { var tile = levelIn.getBlockEntity(pos); if (tile instanceof BlockEntityImpl impl) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java index e4095e41..0b0ce944 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java @@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.reg.ICustomRenderType; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; @@ -21,7 +22,7 @@ public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState, } @Override - public void tick(BlockState state, ServerLevel level, BlockPos pos, Random random) { + public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!level.isClientSide) { level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java index 28e51fbd..80eb42c4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java @@ -53,7 +53,7 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust this.goalDim = goalDim; this.canUseDims = canUseDims; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } private boolean canUseHere(ResourceKey dimension) { @@ -136,7 +136,7 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust @Override public Property getShapeProperty() { - return SHAPE; + return BlockDimensionRail.SHAPE; } @Override @@ -151,7 +151,7 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { - builder.add(SHAPE, WATERLOGGED); + builder.add(BlockDimensionRail.SHAPE, BaseRailBlock.WATERLOGGED); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java index eb0315a1..861c4633 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java @@ -15,10 +15,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.BushBlock; -import net.minecraft.world.level.block.EntityBlock; -import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -40,19 +37,19 @@ import java.util.function.Supplier; public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockState, ICustomItemModel, ICustomRenderType, EntityBlock { - protected static final VoxelShape SHAPE = box(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D); + protected static final VoxelShape SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D); public BlockEndFlower() { super(Properties.of(Material.GRASS).noCollission().strength(0.5F).sound(SoundType.GRASS)); MinecraftForge.EVENT_BUS.register(this); - ModRegistry.add(this); - ModRegistry.add(new ModTileType<>(BlockEntityEndFlower::new, this)); + ModRegistry.ALL_ITEMS.add(this); + ModRegistry.ALL_ITEMS.add(new ModTileType(BlockEntityEndFlower::new, this)); } @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { var vec3d = state.getOffset(levelIn, pos); - return SHAPE.move(vec3d.x, vec3d.y, vec3d.z); + return BlockEndFlower.SHAPE.move(vec3d.x, vec3d.y, vec3d.z); } @SubscribeEvent diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java index 286b8126..9c73a4a1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java @@ -15,8 +15,8 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -38,7 +38,6 @@ import net.minecraftforge.network.NetworkHooks; import javax.annotation.Nullable; import java.util.List; -import java.util.Random; public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { @@ -56,11 +55,11 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider @OnlyIn(Dist.CLIENT) public static void addEnderNameInfo(ItemStack stack, List tooltip) { - var name = getEnderName(stack); + var name = BlockEnderCrate.getEnderName(stack); if (name != null && !name.isEmpty()) { - tooltip.add(new TextComponent(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name", ChatFormatting.ITALIC + name + ChatFormatting.RESET))); + tooltip.add(Component.literal(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name", ChatFormatting.ITALIC + name + ChatFormatting.RESET))); } else { - tooltip.add(new TextComponent(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name.missing"))); + tooltip.add(Component.literal(ChatFormatting.DARK_PURPLE + I18n.get("info." + NaturesAura.MOD_ID + ".ender_name.missing"))); } } @@ -102,12 +101,12 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider @Override @OnlyIn(Dist.CLIENT) public void appendHoverText(ItemStack stack, @Nullable BlockGetter levelIn, List tooltip, TooltipFlag flagIn) { - addEnderNameInfo(stack, tooltip); + BlockEnderCrate.addEnderNameInfo(stack, tooltip); } @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) { for (var i = 0; i < 3; ++i) { var j = rand.nextInt(2) * 2 - 1; var k = rand.nextInt(2) * 2 - 1; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java index e45e8641..6ff66d72 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java @@ -8,7 +8,8 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ICustomRenderType; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; +import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -52,16 +53,16 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc otherCreator.sendToClients(); compound.remove(key); - player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".connected"), true); + player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".connected"), true); } else - player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".stored_pos_gone"), true); + player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".stored_pos_gone"), true); } else - player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".too_far"), true); + player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".too_far"), true); } else - player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".same_position"), true); + player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".same_position"), true); } else { compound.putLong(key, pos.asLong()); - player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".stored_pos"), true); + player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".stored_pos"), true); } } return InteractionResult.SUCCESS; @@ -71,7 +72,7 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) { var tile = levelIn.getBlockEntity(pos); if (tile instanceof BlockEntityFieldCreator creator && creator.isCharged) { var connected = creator.getConnectedPos(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerPot.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerPot.java index 35d39443..b269732d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerPot.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerPot.java @@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.reg.*; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.FlowerPotBlock; +import net.minecraftforge.registries.ForgeRegistries; import java.util.function.Supplier; @@ -12,19 +13,19 @@ public class BlockFlowerPot extends FlowerPotBlock implements ICustomBlockState, public BlockFlowerPot(Supplier emptyPot, Supplier block, Properties props) { super(emptyPot, block, props); - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models() .withExistingParent(this.getBaseName(), "block/flower_pot_cross") - .texture("plant", "block/" + this.getContent().getRegistryName().getPath())); + .texture("plant", "block/" + ForgeRegistries.BLOCKS.getKey(this.getContent()).getPath())); } @Override public String getBaseName() { - return "potted_" + this.getContent().getRegistryName().getPath(); + return "potted_" + ForgeRegistries.BLOCKS.getKey(this.getContent()).getPath(); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java index e1092dfb..5cbd4a7c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java @@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -21,19 +22,18 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nullable; -import java.util.Random; public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlockState { public static final DirectionProperty FACING = BlockStateProperties.FACING; private static final VoxelShape[] SHAPES = new VoxelShape[]{ - box(2, 12, 2, 14, 16, 14), // Down - box(2, 0, 2, 14, 4, 14), // Up - box(2, 2, 12, 14, 14, 16), // North - box(2, 2, 0, 14, 14, 4), // South - box(12, 2, 2, 16, 14, 14), // West - box(0, 2, 2, 4, 14, 14) // East + Block.box(2, 12, 2, 14, 16, 14), // Down + Block.box(2, 0, 2, 14, 4, 14), // Up + Block.box(2, 2, 12, 14, 14, 16), // North + Block.box(2, 2, 0, 14, 14, 4), // South + Block.box(12, 2, 2, 16, 14, 14), // West + Block.box(0, 2, 2, 4, 14, 14) // East }; public BlockFurnaceHeater() { @@ -47,10 +47,10 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) { var tile = levelIn.getBlockEntity(pos); if (tile instanceof BlockEntityFurnaceHeater heater && heater.isActive) { - var facing = stateIn.getValue(FACING); + var facing = stateIn.getValue(BlockFurnaceHeater.FACING); float x; float y; @@ -64,9 +64,9 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo y = 1F; z = 0.35F + rand.nextFloat() * 0.3F; } else { - x = facing.getStepZ() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getStepX() < 0 ? 1 : 0; + x = facing.getStepZ() != 0 ? 0.35F + rand.nextFloat() * 0.3F : facing.getStepX() < 0 ? 1 : 0; y = 0.35F + rand.nextFloat() * 0.3F; - z = facing.getStepX() != 0 ? (0.35F + rand.nextFloat() * 0.3F) : facing.getStepZ() < 0 ? 1 : 0; + z = facing.getStepX() != 0 ? 0.35F + rand.nextFloat() * 0.3F : facing.getStepZ() < 0 ? 1 : 0; } NaturesAuraAPI.instance().spawnMagicParticle( @@ -80,19 +80,19 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPES[state.getValue(FACING).get3DDataValue()]; + return BlockFurnaceHeater.SHAPES[state.getValue(BlockFurnaceHeater.FACING).get3DDataValue()]; } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); - builder.add(FACING); + builder.add(BlockFurnaceHeater.FACING); } @Nullable @Override public BlockState getStateForPlacement(BlockPlaceContext context) { - return super.getStateForPlacement(context).setValue(FACING, context.getClickedFace()); + return super.getStateForPlacement(context).setValue(BlockFurnaceHeater.FACING, context.getClickedFace()); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java index 1ab19d0e..eee8501e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java @@ -35,19 +35,19 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, public static final EnumProperty EAST = BlockStateProperties.EAST_REDSTONE; public static final EnumProperty SOUTH = BlockStateProperties.SOUTH_REDSTONE; public static final EnumProperty WEST = BlockStateProperties.WEST_REDSTONE; - protected static final VoxelShape[] SHAPES = new VoxelShape[]{box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)}; + protected static final VoxelShape[] SHAPES = new VoxelShape[]{Block.box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)}; public BlockGoldPowder() { super("gold_powder", Properties.copy(Blocks.REDSTONE_WIRE)); - this.registerDefaultState(this.defaultBlockState().setValue(NORTH, RedstoneSide.NONE).setValue(EAST, RedstoneSide.NONE).setValue(SOUTH, RedstoneSide.NONE).setValue(WEST, RedstoneSide.NONE)); + this.registerDefaultState(this.defaultBlockState().setValue(BlockGoldPowder.NORTH, RedstoneSide.NONE).setValue(BlockGoldPowder.EAST, RedstoneSide.NONE).setValue(BlockGoldPowder.SOUTH, RedstoneSide.NONE).setValue(BlockGoldPowder.WEST, RedstoneSide.NONE)); } private static int getShapeIndex(BlockState state) { var i = 0; - var n = state.getValue(NORTH) != RedstoneSide.NONE; - var e = state.getValue(EAST) != RedstoneSide.NONE; - var s = state.getValue(SOUTH) != RedstoneSide.NONE; - var w = state.getValue(WEST) != RedstoneSide.NONE; + var n = state.getValue(BlockGoldPowder.NORTH) != RedstoneSide.NONE; + var e = state.getValue(BlockGoldPowder.EAST) != RedstoneSide.NONE; + var s = state.getValue(BlockGoldPowder.SOUTH) != RedstoneSide.NONE; + var w = state.getValue(BlockGoldPowder.WEST) != RedstoneSide.NONE; if (n || s && !n && !e && !w) { i |= 1 << Direction.NORTH.get2DDataValue(); @@ -66,7 +66,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { - builder.add(NORTH, EAST, SOUTH, WEST); + builder.add(BlockGoldPowder.NORTH, BlockGoldPowder.EAST, BlockGoldPowder.SOUTH, BlockGoldPowder.WEST); } @Override @@ -76,14 +76,14 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPES[getShapeIndex(state)]; + return BlockGoldPowder.SHAPES[BlockGoldPowder.getShapeIndex(state)]; } @Override public BlockState getStateForPlacement(BlockPlaceContext context) { BlockGetter iblockreader = context.getLevel(); var blockpos = context.getClickedPos(); - return this.defaultBlockState().setValue(WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).setValue(EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).setValue(NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).setValue(SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH)); + return this.defaultBlockState().setValue(BlockGoldPowder.WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).setValue(BlockGoldPowder.EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).setValue(BlockGoldPowder.NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).setValue(BlockGoldPowder.SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH)); } @Override @@ -91,7 +91,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, if (facing == Direction.DOWN) { return stateIn; } else { - return facing == Direction.UP ? stateIn.setValue(WEST, this.getSide(levelIn, currentPos, Direction.WEST)).setValue(EAST, this.getSide(levelIn, currentPos, Direction.EAST)).setValue(NORTH, this.getSide(levelIn, currentPos, Direction.NORTH)).setValue(SOUTH, this.getSide(levelIn, currentPos, Direction.SOUTH)) : stateIn.setValue(RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(facing), this.getSide(levelIn, currentPos, facing)); + return facing == Direction.UP ? stateIn.setValue(BlockGoldPowder.WEST, this.getSide(levelIn, currentPos, Direction.WEST)).setValue(BlockGoldPowder.EAST, this.getSide(levelIn, currentPos, Direction.EAST)).setValue(BlockGoldPowder.NORTH, this.getSide(levelIn, currentPos, Direction.NORTH)).setValue(BlockGoldPowder.SOUTH, this.getSide(levelIn, currentPos, Direction.SOUTH)) : stateIn.setValue(RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(facing), this.getSide(levelIn, currentPos, facing)); } } @@ -180,7 +180,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, public void neighborChanged(BlockState state, Level levelIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { if (!levelIn.isClientSide) { if (!state.canSurvive(levelIn, pos)) { - dropResources(state, levelIn, pos); + Block.dropResources(state, levelIn, pos); levelIn.removeBlock(pos, false); } } @@ -197,7 +197,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, if (blockstate.getBlock() != Blocks.OBSERVER) { var blockpos = pool.relative(direction.getOpposite()); var blockstate1 = blockstate.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos), levelIn, pool, blockpos); - updateOrDestroy(blockstate, blockstate1, levelIn, pool, flags); + Block.updateOrDestroy(blockstate, blockstate1, levelIn, pool, flags); } pool.set(pos).move(direction).move(Direction.UP); @@ -205,7 +205,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, if (blockstate3.getBlock() != Blocks.OBSERVER) { var blockpos1 = pool.relative(direction.getOpposite()); var blockstate2 = blockstate3.updateShape(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1); - updateOrDestroy(blockstate3, blockstate2, levelIn, pool, flags); + Block.updateOrDestroy(blockstate3, blockstate2, levelIn, pool, flags); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java index 81d11ddf..cfae9061 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java @@ -10,6 +10,7 @@ import net.minecraft.client.renderer.BiomeColors; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.LeavesBlock; @@ -22,16 +23,14 @@ import net.minecraft.world.level.material.MaterialColor; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import java.util.Random; - public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorProvidingBlock, IColorProvidingItem, ICustomBlockState { public static final int HIGHEST_STAGE = 3; - public static final IntegerProperty STAGE = IntegerProperty.create("stage", 0, HIGHEST_STAGE); + public static final IntegerProperty STAGE = IntegerProperty.create("stage", 0, BlockGoldenLeaves.HIGHEST_STAGE); public BlockGoldenLeaves() { super(Properties.of(Material.LEAVES, MaterialColor.GOLD).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS)); - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } public static boolean convert(Level level, BlockPos pos) { @@ -39,8 +38,8 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr if (state.getBlock() instanceof LeavesBlock && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) { if (!level.isClientSide) { level.setBlockAndUpdate(pos, ModBlocks.GOLDEN_LEAVES.defaultBlockState() - .setValue(DISTANCE, state.hasProperty(DISTANCE) ? state.getValue(DISTANCE) : 1) - .setValue(PERSISTENT, state.hasProperty(PERSISTENT) ? state.getValue(PERSISTENT) : false)); + .setValue(LeavesBlock.DISTANCE, state.hasProperty(LeavesBlock.DISTANCE) ? state.getValue(LeavesBlock.DISTANCE) : 1) + .setValue(LeavesBlock.PERSISTENT, state.hasProperty(LeavesBlock.PERSISTENT) ? state.getValue(LeavesBlock.PERSISTENT) : false)); } return true; } @@ -54,8 +53,8 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { - if (stateIn.getValue(STAGE) == HIGHEST_STAGE && rand.nextFloat() >= 0.75F) + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) { + if (stateIn.getValue(BlockGoldenLeaves.STAGE) == BlockGoldenLeaves.HIGHEST_STAGE && rand.nextFloat() >= 0.75F) NaturesAuraAPI.instance().spawnMagicParticle( pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat(), @@ -67,7 +66,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); - builder.add(STAGE); + builder.add(BlockGoldenLeaves.STAGE); } @Override @@ -77,7 +76,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr var color = 0xF2FF00; if (state != null && levelIn != null && pos != null) { var foliage = BiomeColors.getAverageFoliageColor(levelIn, pos); - return Helper.blendColors(color, foliage, state.getValue(STAGE) / (float) HIGHEST_STAGE); + return Helper.blendColors(color, foliage, state.getValue(BlockGoldenLeaves.STAGE) / (float) BlockGoldenLeaves.HIGHEST_STAGE); } else { return color; } @@ -91,18 +90,18 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr } @Override - public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) { super.randomTick(state, levelIn, pos, random); if (!levelIn.isClientSide) { - int stage = state.getValue(STAGE); - if (stage < HIGHEST_STAGE) { - levelIn.setBlockAndUpdate(pos, state.setValue(STAGE, stage + 1)); + int stage = state.getValue(BlockGoldenLeaves.STAGE); + if (stage < BlockGoldenLeaves.HIGHEST_STAGE) { + levelIn.setBlockAndUpdate(pos, state.setValue(BlockGoldenLeaves.STAGE, stage + 1)); } if (stage > 1) { var offset = pos.relative(Direction.getRandom(random)); if (levelIn.isLoaded(offset)) - convert(levelIn, offset); + BlockGoldenLeaves.convert(levelIn, offset); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java index 831bccc7..5c5170f6 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java @@ -35,20 +35,20 @@ import javax.annotation.Nullable; public class BlockGratedChute extends BlockContainerImpl implements ICustomBlockState, ICustomItemModel { public static final DirectionProperty FACING = HopperBlock.FACING; - private static final VoxelShape INPUT_SHAPE = box(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D); - private static final VoxelShape MIDDLE_SHAPE = box(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D); - private static final VoxelShape INPUT_MIDDLE_SHAPE = Shapes.or(MIDDLE_SHAPE, INPUT_SHAPE); - private static final VoxelShape COMBINED_SHAPE = Shapes.join(INPUT_MIDDLE_SHAPE, Hopper.INSIDE, BooleanOp.ONLY_FIRST); - private static final VoxelShape DOWN_SHAPE = Shapes.or(COMBINED_SHAPE, box(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D)); - private static final VoxelShape EAST_SHAPE = Shapes.or(COMBINED_SHAPE, box(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D)); - private static final VoxelShape NORTH_SHAPE = Shapes.or(COMBINED_SHAPE, box(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D)); - private static final VoxelShape SOUTH_SHAPE = Shapes.or(COMBINED_SHAPE, box(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D)); - private static final VoxelShape WEST_SHAPE = Shapes.or(COMBINED_SHAPE, box(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D)); + private static final VoxelShape INPUT_SHAPE = Block.box(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D); + private static final VoxelShape MIDDLE_SHAPE = Block.box(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D); + private static final VoxelShape INPUT_MIDDLE_SHAPE = Shapes.or(BlockGratedChute.MIDDLE_SHAPE, BlockGratedChute.INPUT_SHAPE); + private static final VoxelShape COMBINED_SHAPE = Shapes.join(BlockGratedChute.INPUT_MIDDLE_SHAPE, Hopper.INSIDE, BooleanOp.ONLY_FIRST); + private static final VoxelShape DOWN_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D)); + private static final VoxelShape EAST_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D)); + private static final VoxelShape NORTH_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D)); + private static final VoxelShape SOUTH_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D)); + private static final VoxelShape WEST_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D)); private static final VoxelShape DOWN_RAYTRACE_SHAPE = Hopper.INSIDE; - private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D)); - private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D)); - private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D)); - private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, box(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D)); + private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D)); + private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D)); + private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D)); + private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D)); public BlockGratedChute() { super("grated_chute", BlockEntityGratedChute.class, Properties.of(Material.METAL).strength(3.0F, 8.0F).sound(SoundType.METAL)); @@ -61,24 +61,24 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return switch (state.getValue(FACING)) { - case DOWN -> DOWN_SHAPE; - case NORTH -> NORTH_SHAPE; - case SOUTH -> SOUTH_SHAPE; - case WEST -> WEST_SHAPE; - case EAST -> EAST_SHAPE; - default -> COMBINED_SHAPE; + return switch (state.getValue(BlockGratedChute.FACING)) { + case DOWN -> BlockGratedChute.DOWN_SHAPE; + case NORTH -> BlockGratedChute.NORTH_SHAPE; + case SOUTH -> BlockGratedChute.SOUTH_SHAPE; + case WEST -> BlockGratedChute.WEST_SHAPE; + case EAST -> BlockGratedChute.EAST_SHAPE; + default -> BlockGratedChute.COMBINED_SHAPE; }; } @Override public VoxelShape getInteractionShape(BlockState state, BlockGetter levelIn, BlockPos pos) { - return switch (state.getValue(FACING)) { - case DOWN -> DOWN_RAYTRACE_SHAPE; - case NORTH -> NORTH_RAYTRACE_SHAPE; - case SOUTH -> SOUTH_RAYTRACE_SHAPE; - case WEST -> WEST_RAYTRACE_SHAPE; - case EAST -> EAST_RAYTRACE_SHAPE; + return switch (state.getValue(BlockGratedChute.FACING)) { + case DOWN -> BlockGratedChute.DOWN_RAYTRACE_SHAPE; + case NORTH -> BlockGratedChute.NORTH_RAYTRACE_SHAPE; + case SOUTH -> BlockGratedChute.SOUTH_RAYTRACE_SHAPE; + case WEST -> BlockGratedChute.WEST_RAYTRACE_SHAPE; + case EAST -> BlockGratedChute.EAST_RAYTRACE_SHAPE; default -> Hopper.INSIDE; }; } @@ -103,7 +103,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock var newFacing = context.getClickedFace().getOpposite(); if (newFacing == Direction.UP) newFacing = Direction.DOWN; - return super.getStateForPlacement(context).setValue(FACING, newFacing); + return super.getStateForPlacement(context).setValue(BlockGratedChute.FACING, newFacing); } @Override @@ -132,7 +132,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); - builder.add(FACING); + builder.add(BlockGratedChute.FACING); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java index c6f42267..fc45a3a4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockImpl.java @@ -11,7 +11,7 @@ public class BlockImpl extends Block implements IModItem { public BlockImpl(String baseName, Block.Properties properties) { super(properties); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java index 4967299e..ea3d6683 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java @@ -7,9 +7,11 @@ import de.ellpeck.naturesaura.reg.ICustomRenderType; import de.ellpeck.naturesaura.reg.INoItemBlock; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.shapes.CollisionContext; @@ -22,7 +24,7 @@ import java.util.function.Supplier; public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemBlock, ICustomRenderType { - private static final VoxelShape SHAPE = box(4, 4, 4, 12, 12, 12); + private static final VoxelShape SHAPE = Block.box(4, 4, 4, 12, 12, 12); public BlockLight() { super("light", Properties.of(Material.WOOL).noCollission().lightLevel(s -> 15)); @@ -30,7 +32,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB @Override @OnlyIn(Dist.CLIENT) - public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) { + public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) { for (var i = 0; i < 2; i++) NaturesAuraAPI.instance().spawnMagicParticle( pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, @@ -40,7 +42,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockLight.SHAPE; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java index c100d820..9582fc88 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java @@ -36,7 +36,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide public BlockNatureAltar() { super("nature_altar", BlockEntityNatureAltar.class, Block.Properties.of(Material.STONE).strength(4F)); - this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false)); + this.registerDefaultState(this.defaultBlockState().setValue(BlockNatureAltar.NETHER, false)); } @Override @@ -46,7 +46,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockNatureAltar.SHAPE; } @Override @@ -63,14 +63,14 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); - builder.add(NETHER); + builder.add(BlockNatureAltar.NETHER); } @Nullable @Override public BlockState getStateForPlacement(BlockPlaceContext context) { var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER); - return super.getStateForPlacement(context).setValue(NETHER, nether); + return super.getStateForPlacement(context).setValue(BlockNatureAltar.NETHER, nether); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java index b9a28eb7..42fada86 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java @@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; @@ -20,7 +21,7 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo } @Override - public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) { + public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, RandomSource random) { var up = pos.above(); var upState = levelIn.getBlockState(up); if (upState.isFaceSturdy(levelIn, up, Direction.DOWN)) @@ -41,12 +42,12 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo } @Override - public boolean isBonemealSuccess(Level levelIn, Random rand, BlockPos pos, BlockState state) { + public boolean isBonemealSuccess(Level levelIn, RandomSource rand, BlockPos pos, BlockState state) { return true; } @Override - public void performBonemeal(ServerLevel level, Random rand, BlockPos pos, BlockState state) { + public void performBonemeal(ServerLevel level, RandomSource rand, BlockPos pos, BlockState state) { var blockpos = pos.above(); var blockstate = Blocks.GRASS.defaultBlockState(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java index ce50b7ba..f211ca4c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java @@ -42,7 +42,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockOfferingTable.SHAPE; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java index ae5fb3ac..7126b856 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java @@ -27,7 +27,7 @@ public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBloc @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockPowderPlacer.SHAPE; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java index eff84936..c1252185 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java @@ -84,7 +84,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockSpawnLamp.SHAPE; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java index 6a08ba4b..01513050 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java @@ -19,7 +19,7 @@ public class BlockStairsNA extends StairBlock implements IModItem, ICustomBlockS super(modelState, properties.dynamicShape()); this.baseName = baseName; this.textureName = textureName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java index dd50a429..2af327f1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java @@ -49,7 +49,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider< @Override public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) { - return SHAPE; + return BlockWoodStand.SHAPE; } @SubscribeEvent diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/Slab.java b/src/main/java/de/ellpeck/naturesaura/blocks/Slab.java index d19ea00e..2184cdaf 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/Slab.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/Slab.java @@ -16,7 +16,7 @@ public class Slab extends SlabBlock implements IModItem, ICustomBlockState { super(properties); this.baseName = baseName; this.textureName = textureName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java index 2ddc5902..583914ef 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java @@ -24,7 +24,7 @@ public final class Multiblocks { {" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}}; public static final IMultiblock ALTAR = NaturesAuraAPI.instance().createMultiblock( new ResourceLocation(NaturesAura.MOD_ID, "altar"), - ALTAR_PATTERN, + Multiblocks.ALTAR_PATTERN, 'C', Blocks.CHISELED_STONE_BRICKS, 'B', Matcher.tag(Blocks.STONE_BRICKS, BlockTagProvider.ALTAR_STONE), 'W', Matcher.tag(Blocks.OAK_PLANKS, BlockTagProvider.ALTAR_WOOD), @@ -33,7 +33,7 @@ public final class Multiblocks { ' ', Matcher.wildcard()); public static final IMultiblock NETHER_ALTAR = NaturesAuraAPI.instance().createMultiblock( new ResourceLocation(NaturesAura.MOD_ID, "nether_altar"), - ALTAR_PATTERN, + Multiblocks.ALTAR_PATTERN, 'C', Blocks.RED_NETHER_BRICKS, 'B', Matcher.tag(Blocks.NETHER_BRICKS, BlockTagProvider.NETHER_ALTAR_STONE), 'W', Matcher.tag(Blocks.CRIMSON_PLANKS, BlockTagProvider.NETHER_ALTAR_WOOD), diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraTimer.java index 73d1d8b6..d46c5847 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraTimer.java @@ -84,7 +84,7 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl var stack = this.itemHandler.getStackInSlot(0); if (stack.isEmpty()) return 0; - var amount = TIMES.get(ItemAuraBottle.getType(stack)); + var amount = BlockEntityAuraTimer.TIMES.get(ItemAuraBottle.getType(stack)); if (amount == null) return 0; return amount * stack.getCount(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java index 02e72b50..ed0da18d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java @@ -10,6 +10,7 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; @@ -17,6 +18,11 @@ import net.minecraft.world.phys.AABB; public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickableBlockEntity { public final CraftingContainer crafting = new CraftingContainer(new AbstractContainerMenu(null, 0) { + @Override + public ItemStack quickMoveStack(Player p_38941_, int p_38942_) { + return ItemStack.EMPTY; + } + @Override public boolean stillValid(Player playerIn) { return false; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChunkLoader.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChunkLoader.java index 8708c86a..e973b6d7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChunkLoader.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChunkLoader.java @@ -51,8 +51,8 @@ public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickable if (!unload) { var range = this.range(); if (range > 0) { - for (var x = (this.worldPosition.getX() - range) >> 4; x <= (this.worldPosition.getX() + range) >> 4; x++) { - for (var z = (this.worldPosition.getZ() - range) >> 4; z <= (this.worldPosition.getZ() + range) >> 4; z++) { + for (var x = this.worldPosition.getX() - range >> 4; x <= this.worldPosition.getX() + range >> 4; x++) { + for (var z = this.worldPosition.getZ() - range >> 4; z <= this.worldPosition.getZ() + range >> 4; z++) { var pos = new ChunkPos(x, z); // Only force chunks that we're already forcing or that nobody else is forcing if (this.forcedChunks.contains(pos) || !level.getForcedChunks().contains(pos.toLong())) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEnderCrate.java index e4a8048f..8ca1d2d9 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEnderCrate.java @@ -10,7 +10,6 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -140,7 +139,7 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid @Override public Component getDisplayName() { - return new TranslatableComponent("info." + NaturesAura.MOD_ID + ".ender_crate", ChatFormatting.ITALIC + this.name + ChatFormatting.RESET); + return Component.translatable("info." + NaturesAura.MOD_ID + ".ender_crate", ChatFormatting.ITALIC + this.name + ChatFormatting.RESET); } @Nullable diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java index edf48b14..38ad3670 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java @@ -106,7 +106,7 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick var block = state.getBlock(); var tag = new CompoundTag(); - tag.putString("block", block.getRegistryName().toString()); + tag.putString("block", ForgeRegistries.BLOCKS.getKey(block).toString()); tag.putInt("amount", entry.getValue().intValue()); list.add(tag); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java index 8c861c1a..e4613958 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java @@ -33,7 +33,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab public static ContainerData getFurnaceData(AbstractFurnaceBlockEntity tile) { try { - return (ContainerData) FURNACE_DATA_FIELD.get(tile); + return (ContainerData) BlockEntityFurnaceHeater.FURNACE_DATA_FIELD.get(tile); } catch (IllegalAccessException e) { NaturesAura.LOGGER.fatal("Couldn't reflect furnace field", e); return null; @@ -59,7 +59,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab var tilePos = this.worldPosition.relative(facing.getOpposite()); var tile = this.level.getBlockEntity(tilePos); if (tile instanceof AbstractFurnaceBlockEntity furnace && this.isReady(furnace)) { - var data = getFurnaceData(furnace); + var data = BlockEntityFurnaceHeater.getFurnaceData(furnace); var burnTime = data.get(0); if (burnTime <= 0) this.level.setBlockAndUpdate(tilePos, this.level.getBlockState(tilePos).setValue(AbstractFurnaceBlock.LIT, true)); @@ -99,7 +99,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab var input = furnace.getItem(0); if (!input.isEmpty()) { - var recipe = this.level.getRecipeManager().getRecipeFor(getRecipeType(furnace), furnace, this.level).orElse(null); + var recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(furnace), furnace, this.level).orElse(null); if (recipe == null) return false; var output = recipe.getResultItem(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityHopperUpgrade.java index 7e6fc949..c9f78ca8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityHopperUpgrade.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityHopperUpgrade.java @@ -34,7 +34,7 @@ public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickab if (IAuraChunk.getAuraInArea(this.level, this.worldPosition, 25) < 100000) return; var tile = this.level.getBlockEntity(this.worldPosition.below()); - if (!isValidHopper(tile)) + if (!BlockEntityHopperUpgrade.isValidHopper(tile)) return; var handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null); if (handler == null) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySlimeSplitGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySlimeSplitGenerator.java index 1b6866da..57b524ee 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySlimeSplitGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySlimeSplitGenerator.java @@ -44,7 +44,7 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I public void startGenerating(Slime slime) { var size = slime.getSize(); this.generationTimer = size * 30; - this.amountToRelease = (size * this.getGenerationAmount(slime)) / this.generationTimer; + this.amountToRelease = size * this.getGenerationAmount(slime) / this.generationTimer; this.color = this.getSlimeColor(slime); PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles((float) slime.getX(), (float) slime.getY(), (float) slime.getZ(), PacketParticles.Type.SLIME_SPLIT_GEN_START, diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityTimeChanger.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityTimeChanger.java index 4a00ed14..e4ded62a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityTimeChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityTimeChanger.java @@ -68,7 +68,7 @@ public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickable if (stack.isEmpty() || stack.getItem() != Items.CLOCK) continue; - var dayGoal = Mth.floor((frame.getRotation() / 8F) * 24000F) + 18000; + var dayGoal = Mth.floor(frame.getRotation() / 8F * 24000F) + 18000; var current = this.level.getDayTime(); var toMove = (24000 - current % 24000 + dayGoal) % 24000; this.goalTime = current + toMove; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java index 82c334ed..f44f68ce 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java @@ -80,7 +80,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl this.level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); return true; }); - recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false); + BlockEntityWoodStand.recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false); var item = new ItemEntity(this.level, this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5, @@ -141,7 +141,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl level.setBlockAndUpdate(offset, Blocks.AIR.defaultBlockState()); PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR)); } - recurseTreeDestruction(level, offset, start, includeLeaves, drop); + BlockEntityWoodStand.recurseTreeDestruction(level, offset, start, includeLeaves, drop); } } } @@ -154,7 +154,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl } for (var i = 0; i < 2; i++) { var state = this.level.getBlockState(this.ritualPos.above(i)); - if (!(state.is(BlockTags.LOGS))) + if (!state.is(BlockTags.LOGS)) return false; } if (this.timer < this.recipe.time / 2) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java index 35aa25c7..b47eb9ee 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java @@ -43,7 +43,7 @@ public class RenderAuraTimer implements BlockEntityRenderer> 16 & 255) / 255F; var g = (type.getColor() >> 8 & 255) / 255F; var b = (type.getColor() & 255) / 255F; - this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F); + this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RenderAuraTimer.RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F); stack.popPose(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java index e170e912..f019be7b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java @@ -47,7 +47,7 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer this.dist * this.dist) return ActiveType.INACTIVE; - if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NetherGrassEffect.NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } @@ -73,7 +73,7 @@ public class NetherGrassEffect implements IDrainSpotEffect { for (var yOff = -5; yOff <= 5; yOff++) { var goalPos = new BlockPos(x, y + yOff, z); if (goalPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(goalPos)) { - if (NaturesAuraAPI.instance().isEffectPowderActive(level, goalPos, NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(level, goalPos, NetherGrassEffect.NAME)) continue; var up = goalPos.above(); if (level.getBlockState(up).isFaceSturdy(level, up, Direction.DOWN)) @@ -102,6 +102,6 @@ public class NetherGrassEffect implements IDrainSpotEffect { @Override public ResourceLocation getName() { - return NAME; + return NetherGrassEffect.NAME; } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java index 5ad08f49..20f4f6b4 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java @@ -12,10 +12,8 @@ import net.minecraft.core.Direction; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; -import net.minecraft.tags.Tag; import net.minecraft.tags.TagKey; import net.minecraft.util.Mth; -import net.minecraft.util.Tuple; import net.minecraft.util.random.WeightedRandom; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; @@ -30,9 +28,7 @@ import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayerFactory; -import org.apache.commons.lang3.tuple.Pair; import java.util.HashSet; import java.util.List; @@ -66,7 +62,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { return ActiveType.INACTIVE; if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; - if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME)) + if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), OreSpawnEffect.NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } @@ -95,7 +91,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { var totalWeight = WeightedRandom.getTotalWeight(ores); var powders = NaturesAuraAPI.instance().getActiveEffectPowders(level, - new AABB(pos).inflate(this.dist), NAME); + new AABB(pos).inflate(this.dist), OreSpawnEffect.NAME); if (powders.isEmpty()) return; for (var i = 0; i < this.amount; i++) { @@ -130,7 +126,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { var ray = new BlockHitResult(Vec3.atCenterOf(pos), Direction.UP, pos, false); var context = new BlockPlaceContext(new UseOnContext(player, InteractionHand.MAIN_HAND, ray)); var stateToPlace = toPlace.getStateForPlacement(context); - if (SPAWN_EXCEPTIONS.contains(stateToPlace)) + if (OreSpawnEffect.SPAWN_EXCEPTIONS.contains(stateToPlace)) continue; level.setBlockAndUpdate(orePos, stateToPlace); @@ -154,6 +150,6 @@ public class OreSpawnEffect implements IDrainSpotEffect { @Override public ResourceLocation getName() { - return NAME; + return OreSpawnEffect.NAME; } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java index 27c5e032..390f45d5 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java @@ -49,7 +49,7 @@ public class PlantBoostEffect implements IDrainSpotEffect { return ActiveType.INACTIVE; if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; - if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), PlantBoostEffect.NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } @@ -68,7 +68,7 @@ public class PlantBoostEffect implements IDrainSpotEffect { var z = Mth.floor(pos.getZ() + (2 * level.random.nextFloat() - 1) * this.dist); var plantPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z).below(); if (plantPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(plantPos)) { - if (NaturesAuraAPI.instance().isEffectPowderActive(level, plantPos, NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(level, plantPos, PlantBoostEffect.NAME)) continue; var state = level.getBlockState(plantPos); @@ -99,6 +99,6 @@ public class PlantBoostEffect implements IDrainSpotEffect { @Override public ResourceLocation getName() { - return NAME; + return PlantBoostEffect.NAME; } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java index 2f9269eb..b0baaeda 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java @@ -55,6 +55,6 @@ public class ReplenishingEffect implements IDrainSpotEffect { @Override public ResourceLocation getName() { - return NAME; + return ReplenishingEffect.NAME; } } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java index 89cbc1da..0dc44812 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java @@ -61,6 +61,6 @@ public class SpreadEffect implements IDrainSpotEffect { @Override public ResourceLocation getName() { - return NAME; + return SpreadEffect.NAME; } } diff --git a/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java b/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java index 61f5a276..99cfd012 100644 --- a/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java +++ b/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java @@ -6,7 +6,7 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; public final class CommandAura { @@ -20,7 +20,7 @@ public final class CommandAura { var spot = IAuraChunk.getLowestSpot(source.getLevel(), pos, 35, pos); amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).storeAura(spot, amount); } - source.sendSuccess(new TextComponent("Added aura to area"), true); + source.sendSuccess(Component.literal("Added aura to area"), true); return 0; }))) .then(Commands.literal("remove").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> { @@ -31,7 +31,7 @@ public final class CommandAura { var spot = IAuraChunk.getHighestSpot(source.getLevel(), pos, 35, pos); amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).drainAura(spot, amount); } - source.sendSuccess(new TextComponent("Removed aura from area"), true); + source.sendSuccess(Component.literal("Removed aura from area"), true); return 0; }))) .then(Commands.literal("reset").executes(context -> { @@ -44,7 +44,7 @@ public final class CommandAura { else chunk.storeAura(spot, -amount); }); - source.sendSuccess(new TextComponent("Reset aura in area"), true); + source.sendSuccess(Component.literal("Reset aura in area"), true); return 0; }))); } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java index 4d153214..1d658b9a 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java @@ -22,29 +22,29 @@ public final class Compat { private static final Map MODULES = new HashMap<>(); public static void setup(FMLCommonSetupEvent event) { - populateModules(ModList.get()::isLoaded); - MODULES.values().forEach(c -> c.setup(event)); + Compat.populateModules(ModList.get()::isLoaded); + Compat.MODULES.values().forEach(c -> c.setup(event)); } public static void setupClient() { - MODULES.values().forEach(ICompat::setupClient); + Compat.MODULES.values().forEach(ICompat::setupClient); } public static boolean hasCompat(String mod) { - return MODULES.containsKey(mod); + return Compat.MODULES.containsKey(mod); } public static void addItemTags(ItemTagProvider provider) { // since other mods don't get loaded in runData, just populate all modules - populateModules(s -> true); - MODULES.values().forEach(m -> m.addItemTags(provider)); + Compat.populateModules(s -> true); + Compat.MODULES.values().forEach(m -> m.addItemTags(provider)); } private static void populateModules(Predicate isLoaded) { - for (var entry : MODULE_TYPES.entrySet()) { + for (var entry : Compat.MODULE_TYPES.entrySet()) { var id = entry.getKey(); if (isLoaded.test(id)) { - MODULES.put(id, entry.getValue().get()); + Compat.MODULES.put(id, entry.getValue().get()); NaturesAura.LOGGER.info("Loading compat module for mod " + id); } } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java index 15d44fac..eb1df8c6 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java @@ -50,12 +50,12 @@ public class CuriosCompat implements ICompat { } private void sendImc(InterModEnqueueEvent event) { - TYPES.values().stream().distinct().forEach(t -> InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder(t).build())); + CuriosCompat.TYPES.values().stream().distinct().forEach(t -> InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder(t).build())); } private void onCapabilitiesAttach(AttachCapabilitiesEvent event) { var stack = event.getObject(); - if (TYPES.containsKey(stack.getItem())) { + if (CuriosCompat.TYPES.containsKey(stack.getItem())) { event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() { private final LazyOptional curio = LazyOptional.of(() -> new ICurio() { @Override @@ -92,7 +92,7 @@ public class CuriosCompat implements ICompat { @Override public void addItemTags(ItemTagProvider provider) { - for (var entry : TYPES.entrySet()) { + for (var entry : CuriosCompat.TYPES.entrySet()) { var tag = ItemTags.create(new ResourceLocation("curios", entry.getValue())); provider.tag(tag).add(entry.getKey()); } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java index fe8b465c..f7cd3942 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java @@ -1,17 +1,16 @@ package de.ellpeck.naturesaura.compat.jei; -import com.google.common.collect.ImmutableList; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.recipes.AltarRecipe; -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; @@ -29,18 +28,13 @@ public class AltarCategory implements IRecipeCategory { } @Override - public ResourceLocation getUid() { + public RecipeType getRecipeType() { return JEINaturesAuraPlugin.ALTAR; } - @Override - public Class getRecipeClass() { - return AltarRecipe.class; - } - @Override public Component getTitle() { - return new TranslatableComponent("container." + JEINaturesAuraPlugin.ALTAR + ".name"); + return Component.translatable("container." + JEINaturesAuraPlugin.ALTAR + ".name"); } @Override @@ -54,29 +48,10 @@ public class AltarCategory implements IRecipeCategory { } @Override - public void setIngredients(AltarRecipe altarRecipe, IIngredients iIngredients) { - ImmutableList.Builder builder = ImmutableList.builder(); - builder.add(altarRecipe.input.getItems()); - if (altarRecipe.catalyst != Ingredient.EMPTY) - builder.add(altarRecipe.catalyst.getItems()); - if (altarRecipe.requiredType != null) - builder.add(altarRecipe.getDimensionBottle()); - iIngredients.setInputs(VanillaTypes.ITEM, builder.build()); - iIngredients.setOutput(VanillaTypes.ITEM, altarRecipe.output); - } - - @Override - public void setRecipe(IRecipeLayout iRecipeLayout, AltarRecipe recipe, IIngredients iIngredients) { - var group = iRecipeLayout.getItemStacks(); - group.init(0, true, 0, 18); - group.set(0, Arrays.asList(recipe.input.getItems())); - group.init(1, false, 80, 18); - group.set(1, recipe.output); - group.init(2, true, 26, 18); - group.set(2, recipe.catalyst == Ingredient.EMPTY ? - Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems())); - group.init(3, true, 51, 18); - if (recipe.requiredType != null) - group.set(3, recipe.getDimensionBottle()); + public void setRecipe(IRecipeLayoutBuilder builder, AltarRecipe recipe, IFocusGroup focuses) { + builder.addSlot(RecipeIngredientRole.INPUT, 0, 18).addItemStacks(Arrays.asList(recipe.input.getItems())); + builder.addSlot(RecipeIngredientRole.OUTPUT, 80, 18).addItemStack(recipe.output); + builder.addSlot(RecipeIngredientRole.CATALYST, 26, 18).addItemStacks(recipe.catalyst == Ingredient.EMPTY ? Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems())); + builder.addSlot(RecipeIngredientRole.CATALYST, 51, 18).addItemStack(recipe.requiredType != null ? recipe.getDimensionBottle() : ItemStack.EMPTY); } } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java index 6a558fa3..8bcfcd5c 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java @@ -1,22 +1,22 @@ package de.ellpeck.naturesaura.compat.jei; -import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Vector3f; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -81,18 +81,13 @@ public class AnimalSpawnerCategory implements IRecipeCategory getRecipeType() { return JEINaturesAuraPlugin.SPAWNER; } - @Override - public Class getRecipeClass() { - return AnimalSpawnerRecipe.class; - } - @Override public Component getTitle() { - return new TranslatableComponent("container." + JEINaturesAuraPlugin.SPAWNER + ".name"); + return Component.translatable("container." + JEINaturesAuraPlugin.SPAWNER + ".name"); } @Override @@ -106,25 +101,14 @@ public class AnimalSpawnerCategory implements IRecipeCategory builder = ImmutableList.builder(); - for (var ing : animalSpawnerRecipe.ingredients) - builder.add(ing.getItems()); - iIngredients.setInputs(VanillaTypes.ITEM, builder.build()); - iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(ForgeSpawnEggItem.fromEntityType(animalSpawnerRecipe.entity))); + public void setRecipe(IRecipeLayoutBuilder builder, AnimalSpawnerRecipe recipe, IFocusGroup focuses) { + for (var i = 0; i < recipe.ingredients.length; i++) + builder.addSlot(RecipeIngredientRole.INPUT, i * 18, 68).addItemStacks(Arrays.asList(recipe.ingredients[i].getItems())); + builder.addInvisibleIngredients(RecipeIngredientRole.OUTPUT).addItemStack(new ItemStack(ForgeSpawnEggItem.fromEntityType(recipe.entity))); } @Override - public void setRecipe(IRecipeLayout iRecipeLayout, AnimalSpawnerRecipe recipe, IIngredients iIngredients) { - var group = iRecipeLayout.getItemStacks(); - for (var i = 0; i < recipe.ingredients.length; i++) { - group.init(i, true, i * 18, 68); - group.set(i, Arrays.asList(recipe.ingredients[i].getItems())); - } - } - - @Override - public void draw(AnimalSpawnerRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) { + public void draw(AnimalSpawnerRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseStack matrixStack, double mouseX, double mouseY) { var minecraft = Minecraft.getInstance(); var entity = this.entityCache.get(recipe.entity); if (entity == null) { @@ -134,7 +118,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory TREE_RITUAL = RecipeType.create(NaturesAura.MOD_ID, "tree_ritual", TreeRitualRecipe.class); + public static final RecipeType ALTAR = RecipeType.create(NaturesAura.MOD_ID, "altar", AltarRecipe.class); + public static final RecipeType OFFERING = RecipeType.create(NaturesAura.MOD_ID, "offering", OfferingRecipe.class); + public static final RecipeType SPAWNER = RecipeType.create(NaturesAura.MOD_ID, "animal_spawner", AnimalSpawnerRecipe.class); @Override public ResourceLocation getPluginUid() { @@ -44,8 +46,8 @@ public class JEINaturesAuraPlugin implements IModPlugin { @Override public void registerItemSubtypes(ISubtypeRegistration registration) { - registration.registerSubtypeInterpreter(ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString()); - registration.registerSubtypeInterpreter(ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString()); + registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.EFFECT_POWDER, (stack, context) -> ItemEffectPowder.getEffect(stack).toString()); + registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString()); var auraInterpreter = (IIngredientSubtypeInterpreter) (stack, context) -> { var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null); @@ -53,25 +55,25 @@ public class JEINaturesAuraPlugin implements IModPlugin { return String.valueOf(container.getStoredAura()); return IIngredientSubtypeInterpreter.NONE; }; - registration.registerSubtypeInterpreter(ModItems.AURA_CACHE, auraInterpreter); - registration.registerSubtypeInterpreter(ModItems.AURA_TROVE, auraInterpreter); + registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_CACHE, auraInterpreter); + registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_TROVE, auraInterpreter); } @Override public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { - registration.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL); - registration.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL); - registration.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR); - registration.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), OFFERING); - registration.addRecipeCatalyst(new ItemStack(ModBlocks.ANIMAL_SPAWNER), SPAWNER); + registration.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), JEINaturesAuraPlugin.TREE_RITUAL); + registration.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), JEINaturesAuraPlugin.TREE_RITUAL); + registration.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), JEINaturesAuraPlugin.ALTAR); + registration.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), JEINaturesAuraPlugin.OFFERING); + registration.addRecipeCatalyst(new ItemStack(ModBlocks.ANIMAL_SPAWNER), JEINaturesAuraPlugin.SPAWNER); } @Override public void registerRecipes(IRecipeRegistration registration) { var manager = Minecraft.getInstance().level.getRecipeManager(); - registration.addRecipes(manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE), TREE_RITUAL); - registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE), ALTAR); - registration.addRecipes(manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE), OFFERING); - registration.addRecipes(manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE), SPAWNER); + registration.addRecipes(JEINaturesAuraPlugin.TREE_RITUAL, manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE)); + registration.addRecipes(JEINaturesAuraPlugin.ALTAR, manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE)); + registration.addRecipes(JEINaturesAuraPlugin.OFFERING, manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE)); + registration.addRecipes(JEINaturesAuraPlugin.SPAWNER, manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/OfferingCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/OfferingCategory.java index ded83943..9b0e2959 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/OfferingCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/OfferingCategory.java @@ -1,19 +1,16 @@ package de.ellpeck.naturesaura.compat.jei; -import com.google.common.collect.ImmutableList; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.recipes.OfferingRecipe; -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; import java.util.Arrays; @@ -26,18 +23,13 @@ public class OfferingCategory implements IRecipeCategory { } @Override - public ResourceLocation getUid() { + public RecipeType getRecipeType() { return JEINaturesAuraPlugin.OFFERING; } - @Override - public Class getRecipeClass() { - return OfferingRecipe.class; - } - @Override public Component getTitle() { - return new TranslatableComponent("container." + JEINaturesAuraPlugin.OFFERING + ".name"); + return Component.translatable("container." + JEINaturesAuraPlugin.OFFERING + ".name"); } @Override @@ -51,21 +43,9 @@ public class OfferingCategory implements IRecipeCategory { } @Override - public void setIngredients(OfferingRecipe offeringRecipe, IIngredients iIngredients) { - iIngredients.setInputs(VanillaTypes.ITEM, ImmutableList.builder() - .add(offeringRecipe.input.getItems()) - .add(offeringRecipe.startItem.getItems()).build()); - iIngredients.setOutput(VanillaTypes.ITEM, offeringRecipe.output); - } - - @Override - public void setRecipe(IRecipeLayout recipeLayout, OfferingRecipe recipe, IIngredients ingredients) { - IGuiItemStackGroup group = recipeLayout.getItemStacks(); - group.init(0, true, 0, 14); - group.set(0, Arrays.asList(recipe.input.getItems())); - group.init(1, false, 65, 14); - group.set(1, recipe.output); - group.init(2, true, 27, 0); - group.set(2, Arrays.asList(recipe.startItem.getItems())); + public void setRecipe(IRecipeLayoutBuilder builder, OfferingRecipe recipe, IFocusGroup focuses) { + builder.addSlot(RecipeIngredientRole.INPUT, 0, 14).addItemStacks(Arrays.asList(recipe.input.getItems())); + builder.addSlot(RecipeIngredientRole.OUTPUT, 65, 14).addItemStack(recipe.output); + builder.addSlot(RecipeIngredientRole.INPUT, 27, 0).addItemStacks(Arrays.asList(recipe.startItem.getItems())); } } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/TreeRitualCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/TreeRitualCategory.java index 16ad7e80..3f58c968 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/TreeRitualCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/TreeRitualCategory.java @@ -1,18 +1,16 @@ package de.ellpeck.naturesaura.compat.jei; -import com.google.common.collect.ImmutableList; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; import java.util.Arrays; @@ -25,18 +23,13 @@ public class TreeRitualCategory implements IRecipeCategory { } @Override - public ResourceLocation getUid() { + public RecipeType getRecipeType() { return JEINaturesAuraPlugin.TREE_RITUAL; } - @Override - public Class getRecipeClass() { - return TreeRitualRecipe.class; - } - @Override public Component getTitle() { - return new TranslatableComponent("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name"); + return Component.translatable("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name"); } @Override @@ -50,29 +43,13 @@ public class TreeRitualCategory implements IRecipeCategory { } @Override - public void setIngredients(TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) { - ImmutableList.Builder builder = ImmutableList.builder(); - for (var ing : treeRitualRecipe.ingredients) - builder.add(ing.getItems()); - builder.add(treeRitualRecipe.saplingType.getItems()); - iIngredients.setInputs(VanillaTypes.ITEM, builder.build()); - iIngredients.setOutput(VanillaTypes.ITEM, treeRitualRecipe.result); - } - - @Override - public void setRecipe(IRecipeLayout iRecipeLayout, TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) { - var group = iRecipeLayout.getItemStacks(); - - group.init(0, true, 34, 34); - group.set(0, Arrays.asList(treeRitualRecipe.saplingType.getItems())); - - group.init(1, true, 124, 34); - group.set(1, treeRitualRecipe.result); + public void setRecipe(IRecipeLayoutBuilder builder, TreeRitualRecipe recipe, IFocusGroup focuses) { + builder.addSlot(RecipeIngredientRole.CATALYST, 34, 34).addItemStacks(Arrays.asList(recipe.saplingType.getItems())); + builder.addSlot(RecipeIngredientRole.OUTPUT, 124, 34).addItemStack(recipe.result); var positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}}; - for (var i = 0; i < treeRitualRecipe.ingredients.length; i++) { - group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1); - group.set(i + 2, Arrays.asList(treeRitualRecipe.ingredients[i].getItems())); - } + for (var i = 0; i < recipe.ingredients.length; i++) + builder.addSlot(RecipeIngredientRole.INPUT, positions[i][0] - 1, positions[i][1] - 1).addItemStacks(Arrays.asList(recipe.ingredients[i].getItems())); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java index 1d457c1d..1bfcb8d9 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java @@ -12,8 +12,8 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; @@ -51,7 +51,7 @@ public class PatchouliCompat implements ICompat { state -> check.matches(null, null, null, null, state, (char) 0)); } } - MULTIBLOCKS.put(name, PatchouliAPI.get().makeMultiblock(pattern, rawMatchers)); + PatchouliCompat.MULTIBLOCKS.put(name, PatchouliAPI.get().makeMultiblock(pattern, rawMatchers)); } @SuppressWarnings("unchecked") @@ -70,7 +70,7 @@ public class PatchouliCompat implements ICompat { @Override public void setup(FMLCommonSetupEvent event) { event.enqueueWork(() -> { - for (var entry : MULTIBLOCKS.entrySet()) + for (var entry : PatchouliCompat.MULTIBLOCKS.entrySet()) PatchouliAPI.get().registerMultiblock(entry.getKey(), entry.getValue()); PatchouliAPI.get().setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get()); @@ -93,7 +93,7 @@ public class PatchouliCompat implements ICompat { public void onBookDraw(BookDrawScreenEvent event) { var book = event.getBook(); var gui = event.getScreen(); - if (book == null || !book.equals(BOOK)) + if (book == null || !book.equals(PatchouliCompat.BOOK)) return; var now = LocalDateTime.now(); if (now.getMonth() == Month.MAY && now.getDayOfMonth() == 21) { @@ -106,7 +106,7 @@ public class PatchouliCompat implements ICompat { if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 43 && event.getMouseY() < y + 42) gui.renderComponentTooltip(event.getPoseStack(), - Collections.singletonList(new TextComponent("It's the author Ellpeck's birthday!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD))), + Collections.singletonList(Component.literal("It's the author Ellpeck's birthday!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD))), event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); } else if (now.getMonth() == Month.JUNE) { var x = gui.width / 2 + 272 / 2; @@ -118,7 +118,7 @@ public class PatchouliCompat implements ICompat { if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 45 && event.getMouseY() < y + 26) gui.renderComponentTooltip(event.getPoseStack(), - Collections.singletonList(new TextComponent("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")), + Collections.singletonList(Component.literal("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")), event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); } @@ -135,8 +135,8 @@ public class PatchouliCompat implements ICompat { if (info.tier() == 1) { Screen.blit(event.getPoseStack(), x, y, 496 - 16, 44, 16, 18, 512, 256); } else { - var r = ((info.color() >> 16) & 255) / 255F; - var g = ((info.color() >> 8) & 255) / 255F; + var r = (info.color() >> 16 & 255) / 255F; + var g = (info.color() >> 8 & 255) / 255F; var b = (info.color() & 255) / 255F; RenderSystem.setShaderColor(r, g, b, 1); Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256); @@ -144,7 +144,7 @@ public class PatchouliCompat implements ICompat { if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 16 && event.getMouseY() < y + 18) gui.renderComponentTooltip(event.getPoseStack(), - Collections.singletonList(new TextComponent("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))), + Collections.singletonList(Component.literal("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))), event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java index f1ce0559..0a7c683b 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java @@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.compat.patchouli; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.ForgeSpawnEggItem; +import net.minecraftforge.registries.ForgeRegistries; import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IVariable; import vazkii.patchouli.api.IVariableProvider; @@ -26,7 +27,7 @@ public class ProcessorAnimalSpawner implements IComponentProcessor { } else { return switch (key) { case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString()); - case "entity" -> IVariable.wrap(this.recipe.entity.getRegistryName().toString()); + case "entity" -> IVariable.wrap(ForgeRegistries.ENTITIES.getKey(this.recipe.entity).toString()); case "egg" -> IVariable.from(new ItemStack(ForgeSpawnEggItem.fromEntityType(this.recipe.entity))); default -> null; }; diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java index 375a54a0..84cc3394 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java @@ -7,12 +7,11 @@ import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.Slab; import de.ellpeck.naturesaura.items.ModItems; -import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.advancements.critereon.StatePropertiesPredicate; +import net.minecraft.data.CachedOutput; import net.minecraft.data.DataGenerator; import net.minecraft.data.DataProvider; -import net.minecraft.data.HashCache; import net.minecraft.data.loot.BlockLoot; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Items; @@ -31,6 +30,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePrope import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; +import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nonnull; import java.io.IOException; @@ -72,13 +72,13 @@ public class BlockLootProvider implements DataProvider { } @Override - public void run(HashCache cache) throws IOException { + public void run(CachedOutput cache) throws IOException { for (var function : this.lootFunctions.entrySet()) { var block = function.getKey(); var func = function.getValue(); var table = func.apply(block).setParamSet(LootContextParamSets.BLOCK).build(); - var path = getPath(this.generator.getOutputFolder(), block.getRegistryName()); - DataProvider.save(GSON, cache, LootTables.serialize(table), path); + var path = BlockLootProvider.getPath(this.generator.getOutputFolder(), ForgeRegistries.BLOCKS.getKey(block)); + DataProvider.saveStable(cache, LootTables.serialize(table), path); } } @@ -92,31 +92,31 @@ public class BlockLootProvider implements DataProvider { private static class LootTableHooks extends BlockLoot { public static LootTable.Builder genLeaves(Block block, Block drop) { - return createLeavesDrops(block, drop, 0.05F, 0.0625F, 0.083333336F, 0.1F); + return BlockLoot.createLeavesDrops(block, drop, 0.05F, 0.0625F, 0.083333336F, 0.1F); } public static LootTable.Builder genSlab(Block block) { - return createSlabItemTable(block); + return BlockLoot.createSlabItemTable(block); } public static LootTable.Builder genRegular(Block block) { - return createSingleItemTable(block); + return BlockLoot.createSingleItemTable(block); } public static LootTable.Builder genSilkOnly(Block block) { - return createSilkTouchOnlyTable(block); + return BlockLoot.createSilkTouchOnlyTable(block); } public static LootTable.Builder genSilkOr(Block block, LootPoolEntryContainer.Builder builder) { - return createSilkTouchOrShearsDispatchTable(block, builder); + return BlockLoot.createSilkTouchOrShearsDispatchTable(block, builder); } public static LootTable.Builder genFlowerPot(Block block) { - return createPotFlowerItemTable(((FlowerPotBlock) block).getContent()); + return BlockLoot.createPotFlowerItemTable(((FlowerPotBlock) block).getContent()); } - public static T survivesExplosion(Block block, ConditionUserBuilder then) { - return applyExplosionCondition(block, then); + public static > T survivesExplosion(Block block, ConditionUserBuilder then) { + return BlockLoot.applyExplosionCondition(block, then); } } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java index 9eb5ecfa..f8c01b13 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java @@ -34,10 +34,10 @@ public class BlockTagProvider extends BlockTagsProvider { this.tag(BlockTags.SLABS).add(ModBlocks.ANCIENT_SLAB, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_BRICK_SLAB); this.tag(BlockTags.DIRT).add(ModBlocks.NETHER_GRASS); this.tag(BlockTags.SMALL_FLOWERS).add(ModBlocks.END_FLOWER, ModBlocks.AURA_BLOOM); - this.tag(ALTAR_WOOD).addTag(BlockTags.PLANKS); - this.tag(ALTAR_STONE).addTag(BlockTags.STONE_BRICKS); - this.tag(NETHER_ALTAR_WOOD).add(Blocks.CRIMSON_PLANKS, Blocks.WARPED_PLANKS); - this.tag(NETHER_ALTAR_STONE).add(Blocks.NETHER_BRICKS); + this.tag(BlockTagProvider.ALTAR_WOOD).addTag(BlockTags.PLANKS); + this.tag(BlockTagProvider.ALTAR_STONE).addTag(BlockTags.STONE_BRICKS); + this.tag(BlockTagProvider.NETHER_ALTAR_WOOD).add(Blocks.CRIMSON_PLANKS, Blocks.WARPED_PLANKS); + this.tag(BlockTagProvider.NETHER_ALTAR_STONE).add(Blocks.NETHER_BRICKS); } } diff --git a/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java b/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java index a7a369e1..28ace9f3 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java @@ -3,14 +3,11 @@ package de.ellpeck.naturesaura.data; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.items.ModItems; -import de.ellpeck.naturesaura.items.tools.ItemPickaxe; -import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.data.DataGenerator; import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; -import net.minecraft.tags.Tag; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraftforge.common.Tags; diff --git a/src/main/java/de/ellpeck/naturesaura/data/ModData.java b/src/main/java/de/ellpeck/naturesaura/data/ModData.java index 0ff79255..3bbd65d3 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/ModData.java +++ b/src/main/java/de/ellpeck/naturesaura/data/ModData.java @@ -12,10 +12,10 @@ public final class ModData { var generator = event.getGenerator(); var ex = event.getExistingFileHelper(); var blockTags = new BlockTagProvider(generator, ex); - generator.addProvider(blockTags); - generator.addProvider(new ItemTagProvider(generator, blockTags, ex)); - generator.addProvider(new BlockLootProvider(generator)); - generator.addProvider(new BlockStateGenerator(generator, ex)); - generator.addProvider(new ItemModelGenerator(generator, ex)); + generator.addProvider(event.includeServer(), blockTags); + generator.addProvider(event.includeServer(), new ItemTagProvider(generator, blockTags, ex)); + generator.addProvider(event.includeServer(), new BlockLootProvider(generator)); + generator.addProvider(event.includeServer(), new BlockStateGenerator(generator, ex)); + generator.addProvider(event.includeServer(), new ItemModelGenerator(generator, ex)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/enchant/ModEnchantment.java b/src/main/java/de/ellpeck/naturesaura/enchant/ModEnchantment.java index 375c9d18..24b46205 100644 --- a/src/main/java/de/ellpeck/naturesaura/enchant/ModEnchantment.java +++ b/src/main/java/de/ellpeck/naturesaura/enchant/ModEnchantment.java @@ -13,7 +13,7 @@ public class ModEnchantment extends Enchantment implements IModItem { protected ModEnchantment(String name, Rarity rarityIn, EnchantmentCategory typeIn, EquipmentSlot[] slots) { super(rarityIn, typeIn, slots); this.name = name; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java index fed4eae1..a791f003 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java @@ -68,15 +68,15 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { @Override protected void defineSynchedData() { - this.entityData.define(INHIBITED_EFFECT, null); - this.entityData.define(COLOR, 0); - this.entityData.define(AMOUNT, 0); + this.entityData.define(EntityEffectInhibitor.INHIBITED_EFFECT, null); + this.entityData.define(EntityEffectInhibitor.COLOR, 0); + this.entityData.define(EntityEffectInhibitor.AMOUNT, 0); } @Override public void onSyncedDataUpdated(EntityDataAccessor key) { super.onSyncedDataUpdated(key); - if (INHIBITED_EFFECT.equals(key) || AMOUNT.equals(key)) + if (EntityEffectInhibitor.INHIBITED_EFFECT.equals(key) || EntityEffectInhibitor.AMOUNT.equals(key)) this.powderListDirty = true; } @@ -161,30 +161,30 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { } public ResourceLocation getInhibitedEffect() { - var effect = this.entityData.get(INHIBITED_EFFECT); + var effect = this.entityData.get(EntityEffectInhibitor.INHIBITED_EFFECT); if (effect == null || effect.isEmpty()) return null; return new ResourceLocation(effect); } public void setInhibitedEffect(ResourceLocation effect) { - this.entityData.set(INHIBITED_EFFECT, effect != null ? effect.toString() : null); + this.entityData.set(EntityEffectInhibitor.INHIBITED_EFFECT, effect != null ? effect.toString() : null); } public int getColor() { - return this.entityData.get(COLOR); + return this.entityData.get(EntityEffectInhibitor.COLOR); } public void setColor(int color) { - this.entityData.set(COLOR, color); + this.entityData.set(EntityEffectInhibitor.COLOR, color); } public int getAmount() { - return this.entityData.get(AMOUNT); + return this.entityData.get(EntityEffectInhibitor.AMOUNT); } public void setAmount(int amount) { - this.entityData.set(AMOUNT, amount); + this.entityData.set(EntityEffectInhibitor.AMOUNT, amount); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java index 64091142..1067be77 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java @@ -12,17 +12,19 @@ import net.minecraft.nbt.Tag; import net.minecraft.network.protocol.Packet; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.vehicle.Minecart; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.util.ITeleporter; import net.minecraftforge.network.NetworkHooks; @@ -30,7 +32,7 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class EntityMoverMinecart extends AbstractMinecart { +public class EntityMoverMinecart extends Minecart { private final List spotOffsets = new ArrayList<>(); public boolean isActive; @@ -41,7 +43,11 @@ public class EntityMoverMinecart extends AbstractMinecart { } public EntityMoverMinecart(EntityType type, Level level, double x, double y, double z) { - super(type, level, x, y, z); + super(type, level); + this.setPos(x, y, z); + this.xo = x; + this.yo = y; + this.zo = z; } @Override @@ -180,4 +186,9 @@ public class EntityMoverMinecart extends AbstractMinecart { public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } + + @Override + public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) { + return InteractionResult.PASS; + } } diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java index 2dc4ead2..d508def7 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java @@ -34,19 +34,19 @@ public class EntityStructureFinder extends EyeOfEnder { @Override protected void defineSynchedData() { super.defineSynchedData(); - this.entityData.define(COLOR, 0); + this.entityData.define(EntityStructureFinder.COLOR, 0); } @Override public void addAdditionalSaveData(CompoundTag compound) { super.addAdditionalSaveData(compound); - compound.putInt("color", this.entityData.get(COLOR)); + compound.putInt("color", this.entityData.get(EntityStructureFinder.COLOR)); } @Override public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); - this.entityData.set(COLOR, compound.getInt("color")); + this.entityData.set(EntityStructureFinder.COLOR, compound.getInt("color")); } @Override @@ -58,8 +58,8 @@ public class EntityStructureFinder extends EyeOfEnder { var d3 = d1 - this.getZ(); var f = Math.sqrt(d2 * d2 + d3 * d3); if (f > 12.0F) { - this.targetX = this.getX() + d2 / (double) f * 12.0D; - this.targetZ = this.getZ() + d3 / (double) f * 12.0D; + this.targetX = this.getX() + d2 / f * 12.0D; + this.targetZ = this.getZ() + d3 / f * 12.0D; this.targetY = this.getY() + 8.0D; } else { this.targetX = d0; @@ -113,7 +113,7 @@ public class EntityStructureFinder extends EyeOfEnder { for (var i = 0; i < 4; ++i) this.level.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); } else if (this.level.isClientSide) { - NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.entityData.get(COLOR), 1, 50, 0, false, true); + NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.entityData.get(EntityStructureFinder.COLOR), 1, 50, 0, false, true); } if (!this.level.isClientSide) { diff --git a/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java index bd332c3c..5034438e 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java @@ -36,7 +36,7 @@ public class RenderMoverMinecart extends MinecartRenderer { matrixStackIn.translate(0, 22 / 16F, 0); matrixStackIn.translate(0, 0, 1); matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(180)); - this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1); + this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RenderMoverMinecart.RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1); matrixStackIn.popPose(); } diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index f259599b..beb72de1 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -88,16 +88,16 @@ public class ClientEvents { @SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.END) { - heldCache = ItemStack.EMPTY; - heldEye = ItemStack.EMPTY; - heldOcular = ItemStack.EMPTY; + ClientEvents.heldCache = ItemStack.EMPTY; + ClientEvents.heldEye = ItemStack.EMPTY; + ClientEvents.heldOcular = ItemStack.EMPTY; var mc = Minecraft.getInstance(); if (mc.level == null) { ItemRangeVisualizer.clear(); - PENDING_AURA_CHUNKS.clear(); + ClientEvents.PENDING_AURA_CHUNKS.clear(); } else { - PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level)); + ClientEvents.PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level)); if (!mc.isPaused()) { if (mc.level.getGameTime() % 20 == 0) { @@ -144,14 +144,14 @@ public class ClientEvents { inst.setParticleSpawnRange(32); } - heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player); - heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player); - heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player); + ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player); + ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player); + ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player); - if (!heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) { - SHOWING_EFFECTS.clear(); + if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) { + ClientEvents.SHOWING_EFFECTS.clear(); Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.blockPosition(), 100, - chunk -> chunk.getActiveEffectIcons(mc.player, SHOWING_EFFECTS)); + chunk -> chunk.getActiveEffectIcons(mc.player, ClientEvents.SHOWING_EFFECTS)); } } } @@ -176,7 +176,7 @@ public class ClientEvents { RenderSystem.enableBlend(); // aura spot debug - hoveringAuraSpot = null; + ClientEvents.hoveringAuraSpot = null; if (mc.options.renderDebug && mc.player.isCreative() && ModConfig.instance.debugLevel.get()) { var playerEye = mc.player.getEyePosition(event.getPartialTick()); var playerView = mc.player.getViewVector(event.getPartialTick()).normalize(); @@ -188,7 +188,7 @@ public class ClientEvents { if (playerEye.distanceToSqr(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5) <= range * range) { for (var d = 0F; d <= range; d += 0.5F) { if (pos.equals(new BlockPos(playerEye.add(playerView.scale(d))))) { - hoveringAuraSpot = pos; + ClientEvents.hoveringAuraSpot = pos; break; } } @@ -240,12 +240,12 @@ public class ClientEvents { @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent.Post event) { var mc = Minecraft.getInstance(); - var stack = event.getMatrixStack(); + var stack = event.getPoseStack(); if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) { var res = event.getWindow(); if (mc.player != null) { - if (!heldCache.isEmpty()) { - var container = heldCache.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null); + if (!ClientEvents.heldCache.isEmpty()) { + var container = ClientEvents.heldCache.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null); var width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80); int conf = ModConfig.instance.cacheBarLocation.get(); @@ -256,7 +256,7 @@ public class ClientEvents { var color = container.getAuraColor(); RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); - RenderSystem.setShaderTexture(0, OVERLAYS); + RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); if (width < 80) Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); if (width > 0) @@ -265,7 +265,7 @@ public class ClientEvents { var scale = 0.75F; stack.pushPose(); stack.scale(scale, scale, scale); - var s = heldCache.getHoverName().getString(); + var s = ClientEvents.heldCache.getHoverName().getString(); mc.font.drawShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color); stack.popPose(); @@ -273,9 +273,9 @@ public class ClientEvents { stack.pushPose(); } - if (!heldEye.isEmpty() || !heldOcular.isEmpty()) { + if (!ClientEvents.heldEye.isEmpty() || !ClientEvents.heldOcular.isEmpty()) { stack.pushPose(); - RenderSystem.setShaderTexture(0, OVERLAYS); + RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); int conf = ModConfig.instance.auraBarLocation.get(); if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) { @@ -288,19 +288,19 @@ public class ClientEvents { var textScale = 0.75F; var startX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - 6; - var startY = conf < 2 ? 10 : (!heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getGuiScaledHeight() - 60; + var startY = conf < 2 ? 10 : (!ClientEvents.heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getGuiScaledHeight() - 60; float plusOffX = conf % 2 == 0 ? 7 : -1 - 6; var textX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - mc.font.width(text) * textScale; float textY = conf < 2 ? 3 : res.getGuiScaledHeight() - 3 - 6; var tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50); - var y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY; + var y = !ClientEvents.heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY; if (tHeight < 50) Screen.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256); if (tHeight > 0) Screen.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256); - if (!heldOcular.isEmpty()) { + if (!ClientEvents.heldOcular.isEmpty()) { var topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25); if (topHeight > 0) { if (topHeight < 25) @@ -315,30 +315,30 @@ public class ClientEvents { } } - if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F)) + if (totalPercentage > (ClientEvents.heldOcular.isEmpty() ? 1F : 1.5F)) mc.font.drawShadow(stack, "+", startX + plusOffX, startY - 0.5F, color); - if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F)) - mc.font.drawShadow(stack, "-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color); + if (totalPercentage < (ClientEvents.heldOcular.isEmpty() ? 0F : -0.5F)) + mc.font.drawShadow(stack, "-", startX + plusOffX, startY - 0.5F + (ClientEvents.heldOcular.isEmpty() ? 44 : 70), color); stack.pushPose(); stack.scale(textScale, textScale, textScale); mc.font.drawShadow(stack, text, textX / textScale, textY / textScale, color); stack.popPose(); - if (!heldOcular.isEmpty()) { + if (!ClientEvents.heldOcular.isEmpty()) { var scale = 0.75F; stack.pushPose(); stack.scale(scale, scale, scale); var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22; var stackY = conf < 2 ? 15 : res.getGuiScaledHeight() - 55; - for (var effect : SHOWING_EFFECTS.values()) { + for (var effect : ClientEvents.SHOWING_EFFECTS.values()) { var theX = (int) (stackX / scale); var theY = (int) (stackY / scale); var itemStack = effect.getA(); Helper.renderItemInGui(itemStack, theX, theY, 1F); if (effect.getB()) { RenderSystem.disableDepthTest(); - RenderSystem.setShaderTexture(0, OVERLAYS); + RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); Screen.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256); RenderSystem.enableDepthTest(); } @@ -387,15 +387,15 @@ public class ClientEvents { Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F); } - Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F); - RenderSystem.setShaderTexture(0, OVERLAYS); + Helper.renderItemInGui(ClientEvents.ITEM_FRAME, x - 24, y - 24, 1F); + RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); var u = chute.isBlacklist ? 240 : 224; RenderSystem.disableDepthTest(); Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); RenderSystem.enableDepthTest(); } else if (tile instanceof BlockEntityItemDistributor distributor) { - Helper.renderItemInGui(DISPENSER, x - 24, y - 24, 1F); - RenderSystem.setShaderTexture(0, OVERLAYS); + Helper.renderItemInGui(ClientEvents.DISPENSER, x - 24, y - 24, 1F); + RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); var u = !distributor.isRandomMode ? 240 : 224; RenderSystem.disableDepthTest(); Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); @@ -415,9 +415,9 @@ public class ClientEvents { stack.popPose(); } - if (hoveringAuraSpot != null) { + if (ClientEvents.hoveringAuraSpot != null) { var format = NumberFormat.getInstance(); - var amount = IAuraChunk.getAuraChunk(mc.level, hoveringAuraSpot).getDrainSpot(hoveringAuraSpot); + var amount = IAuraChunk.getAuraChunk(mc.level, ClientEvents.hoveringAuraSpot).getDrainSpot(ClientEvents.hoveringAuraSpot); var color = amount > 0 ? ChatFormatting.GREEN : ChatFormatting.RED; mc.font.drawShadow(stack, color + format.format(amount), res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F - 11, 0xFFFFFF); } @@ -440,7 +440,7 @@ public class ClientEvents { var y = res.getGuiScaledHeight() / 2 + yOffset; var width = Mth.ceil(stored / (float) max * 80); - RenderSystem.setShaderTexture(0, OVERLAYS); + RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); if (width < 80) Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); if (width > 0) diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index 3778253e..e8ffc561 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.events; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; @@ -11,7 +10,6 @@ import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunkProvider; import de.ellpeck.naturesaura.commands.CommandAura; -import de.ellpeck.naturesaura.gen.ModFeatures; import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.packet.PacketHandler; import net.minecraft.resources.ResourceLocation; @@ -26,24 +24,23 @@ import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.server.ServerStartingEvent; -import net.minecraftforge.event.world.BiomeLoadingEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.ChunkWatchEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; +import net.minecraftforge.registries.ForgeRegistries; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.UUID; -import static net.minecraft.world.level.levelgen.GenerationStep.Decoration; - public class CommonEvents { private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "m_140416_"); private static final ListMultimap PENDING_AURA_CHUNKS = ArrayListMultimap.create(); - @SubscribeEvent + // TODO apparently this changed a ton to some weird biome modifier thing + /*@SubscribeEvent public void onBiomeLoad(BiomeLoadingEvent event) { if (ModConfig.instance.auraBlooms.get()) { event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_BLOOM); @@ -56,7 +53,7 @@ public class CommonEvents { case MUSHROOM -> event.getGeneration().addFeature(Decoration.VEGETAL_DECORATION, ModFeatures.Placed.AURA_MUSHROOM); } } - } + }*/ @SubscribeEvent public void onChunkCapsAttach(AttachCapabilitiesEvent event) { @@ -87,7 +84,7 @@ public class CommonEvents { if (player.level.isClientSide) return; var held = event.getItemStack(); - if (!held.isEmpty() && held.getItem().getRegistryName().getPath().contains("chisel")) { + if (!held.isEmpty() && ForgeRegistries.ITEMS.getKey(held.getItem()).getPath().contains("chisel")) { var state = player.level.getBlockState(event.getPos()); if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.containsKey(state)) { var data = (LevelData) ILevelData.getLevelData(player.level); @@ -104,7 +101,7 @@ public class CommonEvents { event.world.getProfiler().push(NaturesAura.MOD_ID + ":onLevelTick"); try { var manager = ((ServerChunkCache) event.world.getChunkSource()).chunkMap; - var chunks = (Iterable) GET_LOADED_CHUNKS_METHOD.invoke(manager); + var chunks = (Iterable) CommonEvents.GET_LOADED_CHUNKS_METHOD.invoke(manager); for (var holder : chunks) { var chunk = holder.getTickingChunk(); if (chunk == null) @@ -125,7 +122,7 @@ public class CommonEvents { public void onPlayerTick(TickEvent.PlayerTickEvent event) { if (!event.player.level.isClientSide && event.phase == TickEvent.Phase.END) { if (event.player.level.getGameTime() % 10 == 0) { - var pending = PENDING_AURA_CHUNKS.get(event.player.getUUID()); + var pending = CommonEvents.PENDING_AURA_CHUNKS.get(event.player.getUUID()); pending.removeIf(p -> this.handleChunkWatchDeferred(event.player, p)); } @@ -142,7 +139,7 @@ public class CommonEvents { @SubscribeEvent public void onChunkWatch(ChunkWatchEvent.Watch event) { - PENDING_AURA_CHUNKS.put(event.getPlayer().getUUID(), event.getPos()); + CommonEvents.PENDING_AURA_CHUNKS.put(event.getPlayer().getUUID(), event.getPos()); } private boolean handleChunkWatchDeferred(Player player, ChunkPos pos) { diff --git a/src/main/java/de/ellpeck/naturesaura/gen/LevelGenAncientTree.java b/src/main/java/de/ellpeck/naturesaura/gen/LevelGenAncientTree.java index 9cc1bd2e..99c6a5d9 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/LevelGenAncientTree.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/LevelGenAncientTree.java @@ -4,6 +4,7 @@ import com.mojang.serialization.Codec; import de.ellpeck.naturesaura.blocks.ModBlocks; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.RotatedPillarBlock; @@ -15,8 +16,6 @@ import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfigur import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.material.Material; -import java.util.Random; - import static net.minecraft.core.Direction.Axis; public class LevelGenAncientTree extends Feature { @@ -100,7 +99,7 @@ public class LevelGenAncientTree extends Feature { } } - private void makeLeaves(WorldGenLevel level, BlockPos pos, BlockState state, int radius, Random rand) { + private void makeLeaves(WorldGenLevel level, BlockPos pos, BlockState state, int radius, RandomSource rand) { for (var x = -radius; x <= radius; x++) { for (var y = -radius; y <= radius; y++) { for (var z = -radius; z <= radius; z++) { diff --git a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java index 00c214c2..0ca511d2 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.gen; import net.minecraft.core.Holder; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.Feature; -import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; import net.minecraft.world.level.levelgen.placement.PlacedFeature; diff --git a/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java index 3d33ec57..23b3051a 100644 --- a/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java @@ -36,7 +36,7 @@ public class GuiEnderCrate extends AbstractContainerScreen @Override protected void renderBg(PoseStack matrixStack, float partialTicks, int mouseX, int mouseY) { RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, CHEST_GUI_TEXTURE); + RenderSystem.setShaderTexture(0, GuiEnderCrate.CHEST_GUI_TEXTURE); var i = (this.width - this.imageWidth) / 2; var j = (this.height - this.imageHeight) / 2; this.blit(matrixStack, i, j, 0, 0, this.imageWidth, 3 * 18 + 17); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java index 8ccc97b1..1215bde3 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java @@ -10,7 +10,6 @@ import net.minecraft.client.color.item.ItemColor; import net.minecraft.core.NonNullList; import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -43,7 +42,7 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu var dispense = stack.split(1); if (offsetState.isAir()) { if (IAuraChunk.getAuraInArea(level, offset, 30) >= 100000) { - dispense = setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(level)); + dispense = ItemAuraBottle.setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(level)); var spot = IAuraChunk.getHighestSpot(level, offset, 30, offset); IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 20000); @@ -71,10 +70,10 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu @Override public void fillItemCategory(CreativeModeTab tab, NonNullList items) { - if (this.allowdedIn(tab)) { + if (this.allowedIn(tab)) { for (var type : NaturesAuraAPI.AURA_TYPES.values()) { var stack = new ItemStack(this); - setType(stack, type); + ItemAuraBottle.setType(stack, type); items.add(stack); } } @@ -82,13 +81,13 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu @Override public Component getName(ItemStack stack) { - return new TranslatableComponent(stack.getDescriptionId() + "." + getType(stack).getName()); + return Component.translatable(stack.getDescriptionId() + "." + ItemAuraBottle.getType(stack).getName()); } @Override @OnlyIn(Dist.CLIENT) public ItemColor getItemColor() { - return (stack, tintIndex) -> tintIndex > 0 ? getType(stack).getColor() : 0xFFFFFF; + return (stack, tintIndex) -> tintIndex > 0 ? ItemAuraBottle.getType(stack).getColor() : 0xFFFFFF; } @Override @@ -106,7 +105,7 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu if (held.isEmpty() || held.getItem() != ModItems.BOTTLE_TWO_THE_REBOTTLING) return; var player = event.getPlayer(); - HitResult ray = getPlayerPOVHitResult(player.level, player, ClipContext.Fluid.NONE); + HitResult ray = Item.getPlayerPOVHitResult(player.level, player, ClipContext.Fluid.NONE); if (ray.getType() == HitResult.Type.BLOCK) return; var pos = player.blockPosition(); @@ -116,7 +115,7 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu if (!player.level.isClientSide) { held.shrink(1); - player.getInventory().add(setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(player.level))); + player.getInventory().add(ItemAuraBottle.setType(new ItemStack(ItemAuraBottle.this), IAuraType.forLevel(player.level))); var spot = IAuraChunk.getHighestSpot(player.level, pos, 30, pos); IAuraChunk.getAuraChunk(player.level, spot).drainAura(spot, 20000); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java index 4d962896..35bace58 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java @@ -66,7 +66,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { @Override public void fillItemCategory(CreativeModeTab tab, NonNullList items) { - if (this.allowdedIn(tab)) { + if (this.allowedIn(tab)) { items.add(new ItemStack(this)); var stack = new ItemStack(this); @@ -86,7 +86,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { public int getBarWidth(ItemStack stack) { if (stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).isPresent()) { var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null); - return Math.round((container.getStoredAura() / (float) container.getMaxAura()) * 13); + return Math.round(container.getStoredAura() / (float) container.getMaxAura() * 13); } return 0; } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemBreakPrevention.java b/src/main/java/de/ellpeck/naturesaura/items/ItemBreakPrevention.java index 3a169163..71072f4a 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemBreakPrevention.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemBreakPrevention.java @@ -5,10 +5,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ElytraItem; -import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -17,8 +14,6 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import java.util.List; - public class ItemBreakPrevention extends ItemImpl { public ItemBreakPrevention() { @@ -63,14 +58,14 @@ public class ItemBreakPrevention extends ItemImpl { if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention")) return; var tooltip = event.getToolTip(); - tooltip.add(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".break_prevention").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY))); + tooltip.add(Component.translatable("info." + NaturesAura.MOD_ID + ".break_prevention").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY))); if (ElytraItem.isFlyEnabled(stack)) return; if (tooltip.size() < 1) return; var head = tooltip.get(0); if (head instanceof MutableComponent) - ((MutableComponent) head).append(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".broken").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY))); + ((MutableComponent) head).append(Component.translatable("info." + NaturesAura.MOD_ID + ".broken").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY))); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java b/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java index d3d3cb8a..f84c8040 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java @@ -37,13 +37,13 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I return false; var color = DyeColor.byId(blocks.indexOf(block)); if (firstColor == null || color == firstColor) { - var stored = getStoredColor(stack); + var stored = ItemColorChanger.getStoredColor(stack); if (player.isCrouching()) { if (stored != color) { level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.BUCKET_FILL, SoundSource.PLAYERS, 0.65F, 1F); if (!level.isClientSide) - storeColor(stack, color); + ItemColorChanger.storeColor(stack, color); return true; } } else { @@ -56,9 +56,9 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I if (!level.isClientSide) { level.setBlockAndUpdate(pos, blocks.get(stored.getId()).defaultBlockState()); - if (isFillMode(stack)) { + if (ItemColorChanger.isFillMode(stack)) { for (var off : Direction.values()) { - changeOrCopyColor(player, stack, level, pos.relative(off), color); + ItemColorChanger.changeOrCopyColor(player, stack, level, pos.relative(off), color); } } } @@ -98,7 +98,7 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I @Override public InteractionResult useOn(UseOnContext context) { var stack = context.getPlayer().getItemInHand(context.getHand()); - if (changeOrCopyColor(context.getPlayer(), stack, context.getLevel(), context.getClickedPos(), null)) { + if (ItemColorChanger.changeOrCopyColor(context.getPlayer(), stack, context.getLevel(), context.getClickedPos(), null)) { return InteractionResult.SUCCESS; } else { return InteractionResult.PASS; @@ -108,10 +108,10 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I @Override public InteractionResultHolder use(Level levelIn, Player playerIn, InteractionHand handIn) { var stack = playerIn.getItemInHand(handIn); - if (playerIn.isCrouching() && getStoredColor(stack) != null) { + if (playerIn.isCrouching() && ItemColorChanger.getStoredColor(stack) != null) { levelIn.playSound(playerIn, playerIn.getX(), playerIn.getY(), playerIn.getZ(), SoundEvents.BUCKET_FILL_LAVA, SoundSource.PLAYERS, 0.65F, 1F); if (!levelIn.isClientSide) { - setFillMode(stack, !isFillMode(stack)); + ItemColorChanger.setFillMode(stack, !ItemColorChanger.isFillMode(stack)); } return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack); } else { @@ -124,7 +124,7 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I public ItemColor getItemColor() { return (stack, tintIndex) -> { if (tintIndex > 0) { - var color = getStoredColor(stack); + var color = ItemColorChanger.getStoredColor(stack); if (color != null) { return color.getFireworkColor(); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java index c77348ef..4e07359b 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java @@ -6,14 +6,11 @@ import de.ellpeck.naturesaura.reg.IColorProvidingItem; import net.minecraft.client.color.item.ItemColor; import net.minecraft.core.NonNullList; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -51,10 +48,10 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem { @Override public void fillItemCategory(CreativeModeTab tab, NonNullList items) { - if (this.allowdedIn(tab)) { + if (this.allowedIn(tab)) { for (var effect : NaturesAuraAPI.EFFECT_POWDERS.keySet()) { var stack = new ItemStack(this); - setEffect(stack, effect); + ItemEffectPowder.setEffect(stack, effect); items.add(stack); } } @@ -62,12 +59,12 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem { @Override public Component getName(ItemStack stack) { - return new TranslatableComponent(this.getDescriptionId(stack) + "." + getEffect(stack)); + return Component.translatable(this.getDescriptionId(stack) + "." + ItemEffectPowder.getEffect(stack)); } @Override @OnlyIn(Dist.CLIENT) public ItemColor getItemColor() { - return (stack, tintIndex) -> NaturesAuraAPI.EFFECT_POWDERS.getOrDefault(getEffect(stack), 0xFFFFFF); + return (stack, tintIndex) -> NaturesAuraAPI.EFFECT_POWDERS.getOrDefault(ItemEffectPowder.getEffect(stack), 0xFFFFFF); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java index 0f0dc1b7..2cd65d64 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java @@ -9,7 +9,6 @@ import de.ellpeck.naturesaura.gui.ContainerEnderCrate; import de.ellpeck.naturesaura.gui.ModContainers; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -46,7 +45,7 @@ public class ItemEnderAccess extends ItemImpl { NetworkHooks.openGui((ServerPlayer) playerIn, new MenuProvider() { @Override public Component getDisplayName() { - return new TranslatableComponent("info." + NaturesAura.MOD_ID + ".ender_access", ChatFormatting.ITALIC + name + ChatFormatting.RESET); + return Component.translatable("info." + NaturesAura.MOD_ID + ".ender_access", ChatFormatting.ITALIC + name + ChatFormatting.RESET); } @Nullable diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java b/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java index 7f2bbf86..477aba8e 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java @@ -16,7 +16,7 @@ public class ItemImpl extends Item implements IModItem { public ItemImpl(String baseName, Item.Properties properties) { super(properties.tab(NaturesAura.CREATIVE_TAB)); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java b/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java index 92672380..74b66693 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java @@ -28,8 +28,8 @@ public class ItemMultiblockMaker extends ItemImpl { public InteractionResultHolder use(Level levelIn, Player playerIn, InteractionHand handIn) { var stack = playerIn.getItemInHand(handIn); if (!levelIn.isClientSide && playerIn.isCreative()) { - var curr = getMultiblockId(stack); - var next = (curr + 1) % multiblocks().size(); + var curr = ItemMultiblockMaker.getMultiblockId(stack); + var next = (curr + 1) % ItemMultiblockMaker.multiblocks().size(); stack.getOrCreateTag().putInt("multiblock", next); } return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack); @@ -39,7 +39,7 @@ public class ItemMultiblockMaker extends ItemImpl { public InteractionResult useOn(UseOnContext context) { var player = context.getPlayer(); if (player.isCreative()) { - var multi = getMultiblock(player.getItemInHand(context.getHand())); + var multi = ItemMultiblockMaker.getMultiblock(player.getItemInHand(context.getHand())); if (multi == null) return InteractionResult.PASS; @@ -57,19 +57,19 @@ public class ItemMultiblockMaker extends ItemImpl { @Override public Component getName(ItemStack stack) { var name = (MutableComponent) super.getName(stack); - var multi = getMultiblock(stack); + var multi = ItemMultiblockMaker.getMultiblock(stack); return multi == null ? name : name.append(" (" + multi.getName() + ")"); } private static List multiblocks() { - if (multiblocks == null) { + if (ItemMultiblockMaker.multiblocks == null) { // some weird mixins call getName way too early, before multiblocks are initialized if (NaturesAuraAPI.MULTIBLOCKS.isEmpty()) return null; - multiblocks = new ArrayList<>(); - multiblocks.addAll(NaturesAuraAPI.MULTIBLOCKS.values()); + ItemMultiblockMaker.multiblocks = new ArrayList<>(); + ItemMultiblockMaker.multiblocks.addAll(NaturesAuraAPI.MULTIBLOCKS.values()); } - return multiblocks; + return ItemMultiblockMaker.multiblocks; } private static int getMultiblockId(ItemStack stack) { @@ -79,10 +79,10 @@ public class ItemMultiblockMaker extends ItemImpl { } private static IMultiblock getMultiblock(ItemStack stack) { - var multiblocks = multiblocks(); + var multiblocks = ItemMultiblockMaker.multiblocks(); if (multiblocks == null) return null; - var id = getMultiblockId(stack); + var id = ItemMultiblockMaker.getMultiblockId(stack); if (id < 0 || id >= multiblocks.size()) return null; return multiblocks.get(id); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemNetheriteFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemNetheriteFinder.java index 57a59df0..f8a84df2 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemNetheriteFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemNetheriteFinder.java @@ -9,7 +9,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.registries.ForgeRegistries; public class ItemNetheriteFinder extends ItemImpl { @@ -35,7 +35,7 @@ public class ItemNetheriteFinder extends ItemImpl { for (var z = -range; z <= range; z++) { var offset = new BlockPos(pos.getX() + x, y, pos.getZ() + z); var state = levelIn.getBlockState(offset); - if (state.getBlock() == Blocks.ANCIENT_DEBRIS || state.getBlock().getRegistryName().toString().contains("netherite")) { + if (state.getBlock() == Blocks.ANCIENT_DEBRIS || ForgeRegistries.BLOCKS.getKey(state.getBlock()).toString().contains("netherite")) { inst.spawnMagicParticle( offset.getX() + 0.5F, offset.getY() + 0.5F, offset.getZ() + 0.5F, 0F, 0F, 0F, 0xab4d38, 6F, 20 * 60, 0F, false, true); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java b/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java index 9db89e55..286bea58 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java @@ -5,17 +5,14 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.ChatFormatting; -import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.TamableAnimal; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -24,9 +21,6 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; -import java.util.Optional; -import java.util.UUID; - public class ItemPetReviver extends ItemImpl { public ItemPetReviver() { @@ -105,7 +99,7 @@ public class ItemPetReviver extends ItemImpl { var spawnedPet = tameable; if (tameable.level != spawnLevel) { - ((ServerLevel) tameable.level).removeEntity(tameable, true); + tameable.remove(Entity.RemovalReason.DISCARDED); spawnedPet = (TamableAnimal) tameable.getType().create(spawnLevel); } // respawn (a copy of) the pet @@ -132,7 +126,7 @@ public class ItemPetReviver extends ItemImpl { PacketHandler.sendToAllAround(spawnedPet.level, spawnedPet.blockPosition(), 32, new PacketParticles((float) spawnedPet.getX(), (float) spawnedPet.getEyeY(), (float) spawnedPet.getZ(), PacketParticles.Type.PET_REVIVER, 0x4dba2f)); if (owner instanceof Player) - owner.sendMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY), UUID.randomUUID()); + owner.sendSystemMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY)); event.setCanceled(true); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java index ae1d196d..b3451608 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java @@ -5,7 +5,7 @@ import com.google.common.collect.ListMultimap; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.render.IVisualizable; import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -15,8 +15,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -33,21 +31,21 @@ public class ItemRangeVisualizer extends ItemImpl { } public static void clear() { - if (!VISUALIZED_BLOCKS.isEmpty()) - VISUALIZED_BLOCKS.clear(); - if (!VISUALIZED_ENTITIES.isEmpty()) - VISUALIZED_ENTITIES.clear(); - if (!VISUALIZED_RAILS.isEmpty()) - VISUALIZED_RAILS.clear(); + if (!ItemRangeVisualizer.VISUALIZED_BLOCKS.isEmpty()) + ItemRangeVisualizer.VISUALIZED_BLOCKS.clear(); + if (!ItemRangeVisualizer.VISUALIZED_ENTITIES.isEmpty()) + ItemRangeVisualizer.VISUALIZED_ENTITIES.clear(); + if (!ItemRangeVisualizer.VISUALIZED_RAILS.isEmpty()) + ItemRangeVisualizer.VISUALIZED_RAILS.clear(); } public static void visualize(Player player, ListMultimap map, ResourceLocation dim, T value) { if (map.containsEntry(dim, value)) { map.remove(dim, value); - player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true); + player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true); } else { map.put(dim, value); - player.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.start"), true); + player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".range_visualizer.start"), true); } } @@ -55,8 +53,8 @@ public class ItemRangeVisualizer extends ItemImpl { public InteractionResultHolder use(Level levelIn, Player playerIn, InteractionHand handIn) { var stack = playerIn.getItemInHand(handIn); if (playerIn.isCrouching()) { - clear(); - playerIn.displayClientMessage(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end_all"), true); + ItemRangeVisualizer.clear(); + playerIn.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".range_visualizer.end_all"), true); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack); } return new InteractionResultHolder<>(InteractionResult.PASS, stack); @@ -70,7 +68,7 @@ public class ItemRangeVisualizer extends ItemImpl { var block = state.getBlock(); if (block instanceof IVisualizable) { if (level.isClientSide) - visualize(context.getPlayer(), VISUALIZED_BLOCKS, level.dimension().location(), pos); + ItemRangeVisualizer.visualize(context.getPlayer(), ItemRangeVisualizer.VISUALIZED_BLOCKS, level.dimension().location(), pos); return InteractionResult.SUCCESS; } return InteractionResult.PASS; @@ -87,7 +85,7 @@ public class ItemRangeVisualizer extends ItemImpl { if (entity instanceof IVisualizable) { if (entity.level.isClientSide) { var dim = entity.level.dimension().location(); - visualize(event.getPlayer(), VISUALIZED_ENTITIES, dim, entity); + ItemRangeVisualizer.visualize(event.getPlayer(), ItemRangeVisualizer.VISUALIZED_ENTITIES, dim, entity); } event.getPlayer().swing(event.getHand()); event.setCancellationResult(InteractionResult.SUCCESS); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java index 0d29f9f6..aad98dc4 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java @@ -11,17 +11,17 @@ import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; +import net.minecraft.world.level.levelgen.structure.Structure; public class ItemStructureFinder extends ItemImpl { - private final Holder> structureName; + private final Holder structure; private final int color; private final int radius; - public ItemStructureFinder(String baseName, Holder> structureName, int color, int radius) { + public ItemStructureFinder(String baseName, Holder structure, int color, int radius) { super(baseName); - this.structureName = structureName; + this.structure = structure; this.color = color; this.radius = radius; } @@ -29,9 +29,9 @@ public class ItemStructureFinder extends ItemImpl { @Override public InteractionResultHolder use(Level levelIn, Player playerIn, InteractionHand handIn) { var stack = playerIn.getItemInHand(handIn); - if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureFeatureManager().shouldGenerateFeatures()) { - var holderSet = HolderSet.direct(this.structureName); - var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapFeature((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false); + if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureManager().shouldGenerateStructures()) { + var holderSet = HolderSet.direct(this.structure); + var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapStructure((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false); if (pos != null) { var entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, levelIn); entity.setPos(playerIn.getX(), playerIn.getY(0.5D), playerIn.getZ()); diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java index fc9d1cca..87837a9d 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java @@ -35,11 +35,11 @@ public class ItemArmor extends ArmorItem implements IModItem { public ItemArmor(String baseName, ArmorMaterial materialIn, EquipmentSlot equipmentSlotIn) { super(materialIn, equipmentSlotIn, new Properties().tab(NaturesAura.CREATIVE_TAB)); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } public static boolean isFullSetEquipped(LivingEntity entity, ArmorMaterial material) { - var set = SETS.computeIfAbsent(material, m -> ForgeRegistries.ITEMS.getValues().stream() + var set = ItemArmor.SETS.computeIfAbsent(material, m -> ForgeRegistries.ITEMS.getValues().stream() .filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial() == material) .sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getSlot().ordinal())) .toArray(Item[]::new)); @@ -70,7 +70,7 @@ public class ItemArmor extends ArmorItem implements IModItem { public static void onAttack(LivingAttackEvent event) { var entity = event.getEntityLiving(); if (!entity.level.isClientSide) { - if (!isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) + if (!ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) return; var source = event.getSource().getEntity(); if (source instanceof LivingEntity) @@ -84,18 +84,18 @@ public class ItemArmor extends ArmorItem implements IModItem { var speed = player.getAttribute(Attributes.MOVEMENT_SPEED); var key = NaturesAura.MOD_ID + ":sky_equipped"; var nbt = player.getPersistentData(); - var equipped = isFullSetEquipped(player, ModArmorMaterial.SKY); + var equipped = ItemArmor.isFullSetEquipped(player, ModArmorMaterial.SKY); if (equipped && !nbt.getBoolean(key)) { // we just equipped it nbt.putBoolean(key, true); player.maxUpStep = 1.1F; - if (!speed.hasModifier(SKY_MOVEMENT_MODIFIER)) - speed.addPermanentModifier(SKY_MOVEMENT_MODIFIER); + if (!speed.hasModifier(ItemArmor.SKY_MOVEMENT_MODIFIER)) + speed.addPermanentModifier(ItemArmor.SKY_MOVEMENT_MODIFIER); } else if (!equipped && nbt.getBoolean(key)) { // we just unequipped it nbt.putBoolean(key, false); player.maxUpStep = 0.6F; - speed.removeModifier(SKY_MOVEMENT_MODIFIER); + speed.removeModifier(ItemArmor.SKY_MOVEMENT_MODIFIER); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java index e63f9832..e5edb1cb 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java @@ -28,7 +28,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { public ItemAxe(String baseName, Tier material, float damage, float speed) { super(material, damage, speed, new Properties().tab(NaturesAura.CREATIVE_TAB)); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java index acc90b34..f4c4133b 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java @@ -17,14 +17,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.Tier; import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BushBlock; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.capabilities.ICapabilityProvider; import javax.annotation.Nullable; -import java.util.Random; public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { @@ -33,7 +30,7 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { public ItemHoe(String baseName, Tier material, int speed) { super(material, speed, 0, new Properties().tab(NaturesAura.CREATIVE_TAB)); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java index 34029711..bd064af8 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java @@ -10,7 +10,6 @@ import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.reg.ICustomItemModel; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; -import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -23,7 +22,6 @@ import net.minecraft.world.item.PickaxeItem; import net.minecraft.world.item.Tier; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -36,7 +34,7 @@ public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemMod public ItemPickaxe(String baseName, Tier material, int damage, float speed) { super(material, damage, speed, new Properties().tab(NaturesAura.CREATIVE_TAB)); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java index 7687dbc5..8aafddd0 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java @@ -7,24 +7,19 @@ import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.reg.ICustomItemModel; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; -import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ShovelItem; import net.minecraft.world.item.Tier; import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -38,7 +33,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel public ItemShovel(String baseName, Tier material, float damage, float speed) { super(material, damage, speed, new Properties().tab(NaturesAura.CREATIVE_TAB)); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java index a3be897d..6f57aaf6 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java @@ -25,7 +25,7 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel { public ItemSword(String baseName, Tier material, int damage, float speed) { super(material, damage, speed, new Properties().tab(NaturesAura.CREATIVE_TAB)); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/misc/ColoredBlockHelper.java b/src/main/java/de/ellpeck/naturesaura/misc/ColoredBlockHelper.java index 97d86225..d82c6d3e 100644 --- a/src/main/java/de/ellpeck/naturesaura/misc/ColoredBlockHelper.java +++ b/src/main/java/de/ellpeck/naturesaura/misc/ColoredBlockHelper.java @@ -12,14 +12,14 @@ import java.util.List; public final class ColoredBlockHelper { - public static final List WOOL = collectBlocks("wool"); - public static final List TERRACOTTA = collectBlocks("terracotta"); - public static final List CONCRETE_POWDER = collectBlocks("concrete_powder"); - public static final List CONCRETE = collectBlocks("concrete"); - public static final List GLASS = collectBlocks("stained_glass"); - public static final List GLASS_PANE = collectBlocks("glass_pane"); - public static final List CARPET = collectBlocks("carpet"); - public static final List> LISTS = Arrays.asList(WOOL, TERRACOTTA, CONCRETE_POWDER, CONCRETE, GLASS, GLASS_PANE, CARPET); + public static final List WOOL = ColoredBlockHelper.collectBlocks("wool"); + public static final List TERRACOTTA = ColoredBlockHelper.collectBlocks("terracotta"); + public static final List CONCRETE_POWDER = ColoredBlockHelper.collectBlocks("concrete_powder"); + public static final List CONCRETE = ColoredBlockHelper.collectBlocks("concrete"); + public static final List GLASS = ColoredBlockHelper.collectBlocks("stained_glass"); + public static final List GLASS_PANE = ColoredBlockHelper.collectBlocks("glass_pane"); + public static final List CARPET = ColoredBlockHelper.collectBlocks("carpet"); + public static final List> LISTS = Arrays.asList(ColoredBlockHelper.WOOL, ColoredBlockHelper.TERRACOTTA, ColoredBlockHelper.CONCRETE_POWDER, ColoredBlockHelper.CONCRETE, ColoredBlockHelper.GLASS, ColoredBlockHelper.GLASS_PANE, ColoredBlockHelper.CARPET); private static List collectBlocks(String name) { List blocks = new ArrayList<>(); @@ -29,7 +29,7 @@ public final class ColoredBlockHelper { } public static List getBlocksContaining(Block block) { - for (var list : LISTS) { + for (var list : ColoredBlockHelper.LISTS) { if (list.contains(block)) return list; } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java index cc830dde..4cabc26f 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketHandler.java @@ -16,22 +16,22 @@ public final class PacketHandler { private static SimpleChannel network; public static void init() { - network = NetworkRegistry.newSimpleChannel(new ResourceLocation(NaturesAura.MOD_ID, "network"), () -> VERSION, VERSION::equals, VERSION::equals); - network.registerMessage(0, PacketParticleStream.class, PacketParticleStream::toBytes, PacketParticleStream::fromBytes, PacketParticleStream::onMessage); - network.registerMessage(1, PacketParticles.class, PacketParticles::toBytes, PacketParticles::fromBytes, PacketParticles::onMessage); - network.registerMessage(2, PacketAuraChunk.class, PacketAuraChunk::toBytes, PacketAuraChunk::fromBytes, PacketAuraChunk::onMessage); - network.registerMessage(3, PacketClient.class, PacketClient::toBytes, PacketClient::fromBytes, PacketClient::onMessage); + PacketHandler.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(NaturesAura.MOD_ID, "network"), () -> PacketHandler.VERSION, PacketHandler.VERSION::equals, PacketHandler.VERSION::equals); + PacketHandler.network.registerMessage(0, PacketParticleStream.class, PacketParticleStream::toBytes, PacketParticleStream::fromBytes, PacketParticleStream::onMessage); + PacketHandler.network.registerMessage(1, PacketParticles.class, PacketParticles::toBytes, PacketParticles::fromBytes, PacketParticles::onMessage); + PacketHandler.network.registerMessage(2, PacketAuraChunk.class, PacketAuraChunk::toBytes, PacketAuraChunk::fromBytes, PacketAuraChunk::onMessage); + PacketHandler.network.registerMessage(3, PacketClient.class, PacketClient::toBytes, PacketClient::fromBytes, PacketClient::onMessage); } public static void sendToAllLoaded(Level level, BlockPos pos, Object message) { - network.send(PacketDistributor.TRACKING_CHUNK.with(() -> level.getChunkAt(pos)), message); + PacketHandler.network.send(PacketDistributor.TRACKING_CHUNK.with(() -> level.getChunkAt(pos)), message); } public static void sendToAllAround(Level level, BlockPos pos, int range, Object message) { - network.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, level.dimension())), message); + PacketHandler.network.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, level.dimension())), message); } public static void sendTo(Player player, Object message) { - network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), message); + PacketHandler.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), message); } } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 8f93c72e..beb9c0f7 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -525,7 +525,7 @@ public class PacketParticles { renderer.addParticle(new ItemParticleOption(ParticleTypes.ITEM, entity.getItem()), false, d0, d13, d18, level.random.nextGaussian() * 0.15D, level.random.nextDouble() * 0.2D, level.random.nextGaussian() * 0.15D); int color = entity.getEntityData().get(EntityStructureFinder.COLOR); - for (var d24 = 0.0D; d24 < (Math.PI * 2D); d24 += 0.15707963267948966D) { + for (var d24 = 0.0D; d24 < Math.PI * 2D; d24 += 0.15707963267948966D) { NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2, 0.0D, Math.sin(d24) * -2, color, 2, 60, 0, false, true); NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2.5, 0.0D, Math.sin(d24) * -2.5, color, 2, 60, 0, false, true); } diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java index 14c5a4da..fdab2acb 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java @@ -27,7 +27,7 @@ public final class ParticleHandler { @Override public void begin(BufferBuilder buffer, TextureManager textureManager) { - setupRendering(); + ParticleHandler.setupRendering(); RenderSystem.enableDepthTest(); buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); } @@ -46,7 +46,7 @@ public final class ParticleHandler { public static final ParticleRenderType MAGIC_NO_DEPTH = new ParticleRenderType() { @Override public void begin(BufferBuilder buffer, TextureManager textureManager) { - setupRendering(); + ParticleHandler.setupRendering(); RenderSystem.disableDepthTest(); buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); } @@ -68,10 +68,10 @@ public final class ParticleHandler { public static void spawnParticle(Supplier particle, double x, double y, double z) { var mc = Minecraft.getInstance(); - if (mc.player.distanceToSqr(x, y, z) <= range * range) { - if (culling) { + if (mc.player.distanceToSqr(x, y, z) <= ParticleHandler.range * ParticleHandler.range) { + if (ParticleHandler.culling) { if (ModConfig.instance.respectVanillaParticleSettings.get()) { - var setting = mc.options.particles; + var setting = mc.options.particles().get(); if (setting != ParticleStatus.ALL && (setting != ParticleStatus.DECREASED || mc.level.random.nextInt(3) != 0) && (setting != ParticleStatus.MINIMAL || mc.level.random.nextInt(10) != 0)) diff --git a/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java b/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java index 85c4f541..a80e0d74 100644 --- a/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/potion/PotionImpl.java @@ -13,7 +13,7 @@ public class PotionImpl extends MobEffect implements IModItem { super(type, liquidColorIn); this.baseName = baseName; - ModRegistry.add(this); + ModRegistry.ALL_ITEMS.add(this); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java index ba94fe2d..c967debe 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java @@ -7,14 +7,13 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.items.ItemAuraBottle; import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.registries.ForgeRegistryEntry; import javax.annotation.Nullable; @@ -44,7 +43,7 @@ public class AltarRecipe extends ModRecipe { @Override public RecipeSerializer getSerializer() { - return ModRecipes.ALTAR_SERIAIZER; + return ModRecipes.ALTAR_SERIALIZER; } @Override @@ -54,11 +53,11 @@ public class AltarRecipe extends ModRecipe { public ItemStack getDimensionBottle() { var bottle = ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), this.requiredType); - bottle.setHoverName(new TranslatableComponent("info." + NaturesAura.MOD_ID + ".required_aura_type." + this.requiredType.getName())); + bottle.setHoverName(Component.translatable("info." + NaturesAura.MOD_ID + ".required_aura_type." + this.requiredType.getName())); return bottle; } - public static class Serializer extends ForgeRegistryEntry> implements RecipeSerializer { + public static class Serializer implements RecipeSerializer { @Override public AltarRecipe fromJson(ResourceLocation recipeId, JsonObject json) { diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java index 896cdbbf..9b180e23 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura.recipes; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.minecraft.core.BlockPos; import net.minecraft.network.FriendlyByteBuf; @@ -15,7 +14,6 @@ import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.ForgeRegistryEntry; import javax.annotation.Nullable; import java.util.ArrayList; @@ -58,7 +56,7 @@ public class AnimalSpawnerRecipe extends ModRecipe { return ModRecipes.ANIMAL_SPAWNER_TYPE; } - public static class Serializer extends ForgeRegistryEntry> implements RecipeSerializer { + public static class Serializer implements RecipeSerializer { @Override public AnimalSpawnerRecipe fromJson(ResourceLocation recipeId, JsonObject json) { @@ -91,7 +89,7 @@ public class AnimalSpawnerRecipe extends ModRecipe { buffer.writeInt(recipe.ingredients.length); for (var ing : recipe.ingredients) ing.toNetwork(buffer); - buffer.writeResourceLocation(recipe.entity.getRegistryName()); + buffer.writeResourceLocation(ForgeRegistries.ENTITIES.getKey(recipe.entity)); buffer.writeInt(recipe.aura); buffer.writeInt(recipe.time); } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/EnabledCondition.java b/src/main/java/de/ellpeck/naturesaura/recipes/EnabledCondition.java index d9b82b7f..808ff815 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/EnabledCondition.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/EnabledCondition.java @@ -27,11 +27,11 @@ public class EnabledCondition implements ICondition { @Override public ResourceLocation getID() { - return NAME; + return EnabledCondition.NAME; } @Override - public boolean test() { + public boolean test(IContext context) { return this.config != null && this.config.get(); } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 57f1d289..901b0c8d 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -1,16 +1,9 @@ package de.ellpeck.naturesaura.recipes; -import com.google.gson.JsonObject; -import com.mojang.serialization.Dynamic; -import com.mojang.serialization.JsonOps; -import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.misc.WeatherType; import de.ellpeck.naturesaura.api.misc.WeightedOre; import net.minecraft.core.Registry; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtOps; -import net.minecraft.nbt.Tag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.ItemStack; @@ -18,14 +11,13 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.block.Blocks; -import net.minecraftforge.registries.IForgeRegistry; import java.util.List; public final class ModRecipes { public static final RecipeType ALTAR_TYPE = new RecipeType<>(); - public static final RecipeSerializer ALTAR_SERIAIZER = new AltarRecipe.Serializer(); + public static final RecipeSerializer ALTAR_SERIALIZER = new AltarRecipe.Serializer(); public static final RecipeType ANIMAL_SPAWNER_TYPE = new RecipeType<>(); public static final RecipeSerializer ANIMAL_SPAWNER_SERIALIZER = new AnimalSpawnerRecipe.Serializer(); @@ -36,13 +28,6 @@ public final class ModRecipes { public static final RecipeType TREE_RITUAL_TYPE = new RecipeType<>(); public static final RecipeSerializer TREE_RITUAL_SERIALIZER = new TreeRitualRecipe.Serializer(); - public static void register(IForgeRegistry> registry) { - register(registry, "altar", ALTAR_TYPE, ALTAR_SERIAIZER); - register(registry, "animal_spawner", ANIMAL_SPAWNER_TYPE, ANIMAL_SPAWNER_SERIALIZER); - register(registry, "offering", OFFERING_TYPE, OFFERING_SERIALIZER); - register(registry, "tree_ritual", TREE_RITUAL_TYPE, TREE_RITUAL_SERIALIZER); - } - public static void init() { NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( Blocks.COBBLESTONE.defaultBlockState(), @@ -57,57 +42,57 @@ public final class ModRecipes { Blocks.STONE_BRICK_WALL.defaultBlockState(), Blocks.MOSSY_STONE_BRICK_WALL.defaultBlockState()); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/coal", 5000); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/coal", 5000); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/iron", 3000); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/iron", 3000); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/gold", 500); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/gold", 500); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/diamond", 50); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/diamond", 50); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/lapis", 250); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/lapis", 250); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/redstone", 200); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/redstone", 200); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/emerald", 30); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/emerald", 30); - ore(NaturesAuraAPI.NETHER_ORES, "ores/quartz", 8000); - ore(NaturesAuraAPI.NETHER_ORES, "ores/netherite_scrap", 30); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/coal", 5000); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/coal", 5000); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/iron", 3000); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/iron", 3000); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/gold", 500); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/gold", 500); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/diamond", 50); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/diamond", 50); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/lapis", 250); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/lapis", 250); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/redstone", 200); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/redstone", 200); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/emerald", 30); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/emerald", 30); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/quartz", 8000); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/netherite_scrap", 30); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/copper", 2000); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/copper", 2000); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/tin", 1800); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/tin", 1800); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/lead", 1500); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/lead", 1500); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/silver", 1000); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/silver", 1000); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/nickel", 100); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/nickel", 100); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/platinum", 20); - ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/platinum", 20); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/aluminum", 1200); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/aluminium", 1200); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/osmium", 1500); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/zinc", 1000); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/yellorite", 1200); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/uranium", 400); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/apatite", 700); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/ruby", 40); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/peridot", 40); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/topaz", 40); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/tanzanite", 40); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/malachite", 40); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/sapphire", 40); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/amber", 150); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/resonating", 50); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/sulfur", 600); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/saltpeter", 250); - ore(NaturesAuraAPI.NETHER_ORES, "ores/firestone", 30); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/salt", 2900); - ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/draconium", 5); - ore(NaturesAuraAPI.NETHER_ORES, "ores/cobalt", 50); - ore(NaturesAuraAPI.NETHER_ORES, "ores/ardite", 50); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/copper", 2000); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/copper", 2000); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/tin", 1800); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/tin", 1800); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/lead", 1500); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/lead", 1500); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/silver", 1000); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/silver", 1000); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/nickel", 100); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/nickel", 100); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/platinum", 20); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/platinum", 20); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/aluminum", 1200); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/aluminium", 1200); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/osmium", 1500); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/zinc", 1000); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/yellorite", 1200); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/uranium", 400); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/apatite", 700); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/ruby", 40); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/peridot", 40); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/topaz", 40); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/tanzanite", 40); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/malachite", 40); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/sapphire", 40); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/amber", 150); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/resonating", 50); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/sulfur", 600); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/saltpeter", 250); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/firestone", 30); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/salt", 2900); + ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/draconium", 5); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/cobalt", 50); + ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/ardite", 50); NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.EGG, 10000); NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.SNOWBALL, 7000); @@ -130,33 +115,6 @@ public final class ModRecipes { list.add(new WeightedOre(res, weight)); } - private static void register(IForgeRegistry> registry, String name, RecipeType type, RecipeSerializer serializer) { - var res = new ResourceLocation(NaturesAura.MOD_ID, name); - Registry.register(Registry.RECIPE_TYPE, res, type); - registry.register(serializer.setRegistryName(res)); - } - - public static JsonObject serializeStack(ItemStack stack) { - var nbt = stack.save(new CompoundTag()); - var c = nbt.getByte("Count"); - if (c != 1) { - nbt.putByte("count", c); - } - nbt.remove("Count"); - renameTag(nbt, "id", "item"); - renameTag(nbt, "tag", "nbt"); - var dyn = new Dynamic(NbtOps.INSTANCE, nbt); - return dyn.convert(JsonOps.INSTANCE).getValue().getAsJsonObject(); - } - - private static void renameTag(CompoundTag nbt, String oldName, String newName) { - var tag = nbt.get(oldName); - if (tag != null) { - nbt.remove(oldName); - nbt.put(newName, tag); - } - } - private static class RecipeType> implements net.minecraft.world.item.crafting.RecipeType { @Override diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java index 9687e33e..57f16823 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java @@ -8,7 +8,6 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.registries.ForgeRegistryEntry; import javax.annotation.Nullable; @@ -40,7 +39,7 @@ public class OfferingRecipe extends ModRecipe { return ModRecipes.OFFERING_TYPE; } - public static class Serializer extends ForgeRegistryEntry> implements RecipeSerializer { + public static class Serializer implements RecipeSerializer { @Override public OfferingRecipe fromJson(ResourceLocation recipeId, JsonObject json) { diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java index e00b22be..c85092be 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura.recipes; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; @@ -9,7 +8,6 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.registries.ForgeRegistryEntry; import javax.annotation.Nullable; import java.util.ArrayList; @@ -45,7 +43,7 @@ public class TreeRitualRecipe extends ModRecipe { return ModRecipes.TREE_RITUAL_TYPE; } - public static class Serializer extends ForgeRegistryEntry> implements RecipeSerializer { + public static class Serializer implements RecipeSerializer { @Override public TreeRitualRecipe fromJson(ResourceLocation recipeId, JsonObject json) { diff --git a/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java b/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java index 1702918c..24352ce2 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/IModItem.java @@ -1,12 +1,7 @@ package de.ellpeck.naturesaura.reg; -import net.minecraftforge.registries.ForgeRegistryEntry; - public interface IModItem { String getBaseName(); - default ForgeRegistryEntry getRegistryEntry() { - return (ForgeRegistryEntry) this; - } } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java b/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java index a703dfe5..d85b1b11 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java @@ -39,7 +39,7 @@ public enum ModArmorMaterial implements ArmorMaterial { @Override public int getDurabilityForSlot(EquipmentSlot slotIn) { - return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; + return ModArmorMaterial.MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index aa679e2a..9d4f4875 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -22,321 +22,303 @@ import de.ellpeck.naturesaura.potion.ModPotions; import de.ellpeck.naturesaura.potion.PotionBreathless; import de.ellpeck.naturesaura.recipes.EnabledCondition; import de.ellpeck.naturesaura.recipes.ModRecipes; -import net.minecraft.core.Registry; -import net.minecraft.data.BuiltinRegistries; -import net.minecraft.data.worldgen.StructureFeatures; +import net.minecraft.data.worldgen.Structures; import net.minecraft.data.worldgen.features.FeatureUtils; import net.minecraft.data.worldgen.placement.PlacementUtils; -import net.minecraft.world.effect.MobEffect; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.MobCategory; -import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.FlowerPotBlock; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; -import net.minecraft.world.level.levelgen.feature.Feature; -import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; -import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.material.Material; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.extensions.IForgeMenuType; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegisterEvent; import java.util.HashSet; import java.util.Set; -import java.util.function.Supplier; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public final class ModRegistry { public static final Set ALL_ITEMS = new HashSet<>(); - public static void add(IModItem item) { - ALL_ITEMS.add(item); - item.getRegistryEntry().setRegistryName(item.getBaseName()); - } - @SubscribeEvent - public static void registerBlocks(RegistryEvent.Register event) { - Block temp; - event.getRegistry().registerAll( - new BlockAncientLog("ancient_log"), - new BlockAncientLog("ancient_bark"), - temp = new BlockImpl("ancient_planks", Block.Properties.of(Material.WOOD).sound(SoundType.WOOD).strength(2F)), - new BlockStairsNA("ancient_stairs", "ancient_planks", temp::defaultBlockState, Block.Properties.copy(temp)), - new Slab("ancient_slab", "ancient_planks", Block.Properties.copy(temp)), - new BlockAncientLeaves(), - new BlockAncientSapling(), - new BlockNatureAltar(), - new BlockDecayedLeaves(), - new BlockGoldenLeaves(), - new BlockGoldPowder(), - new BlockWoodStand(), - temp = new BlockImpl("infused_stone", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(1.75F)), - new BlockStairsNA("infused_stairs", "infused_stone", temp::defaultBlockState, Block.Properties.copy(temp)), - new Slab("infused_slab", "infused_stone", Block.Properties.copy(temp)), - temp = new BlockImpl("infused_brick", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(1.5F)), - new BlockStairsNA("infused_brick_stairs", "infused_brick", temp::defaultBlockState, Block.Properties.copy(temp)), - new Slab("infused_brick_slab", "infused_brick", Block.Properties.copy(temp)), - new BlockFurnaceHeater(), - new BlockPotionGenerator(), - new BlockAuraDetector(), - new BlockCatalyst("conversion_catalyst", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(2.5F)), - new BlockCatalyst("crushing_catalyst", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(2.5F)), - new BlockFlowerGenerator(), - new BlockPlacer(), - new BlockHopperUpgrade(), - new BlockFieldCreator(), - new BlockOakGenerator(), - new BlockImpl("infused_iron_block", Block.Properties.of(Material.METAL).sound(SoundType.METAL).strength(3F)), - new BlockOfferingTable(), - new BlockPickupStopper(), - new BlockSpawnLamp(), - new BlockAnimalGenerator(), - new BlockEndFlower(), - new BlockGratedChute(), - new BlockAnimalSpawner(), - new BlockAutoCrafter(), - new BlockImpl("gold_brick", Block.Properties.copy(Blocks.STONE_BRICKS)), - new BlockImpl("gold_nether_brick", Block.Properties.copy(Blocks.NETHER_BRICKS)), - new BlockMossGenerator(), - new BlockTimeChanger(), - new BlockGeneratorLimitRemover(), - new BlockEnderCrate(), - new BlockPowderPlacer(), - new BlockFireworkGenerator(), - new BlockProjectileGenerator(), - new BlockDimensionRail("overworld", Level.OVERWORLD, Level.NETHER, Level.END), - new BlockDimensionRail("nether", Level.NETHER, Level.OVERWORLD), - new BlockDimensionRail("end", Level.END, Level.OVERWORLD), - new BlockBlastFurnaceBooster(), - new BlockImpl("nether_wart_mushroom", Block.Properties.copy(Blocks.RED_MUSHROOM_BLOCK)), - new BlockAnimalContainer(), - new BlockSnowCreator(), - new BlockItemDistributor(), - temp = new BlockAuraBloom("aura_bloom", Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.PODZOL, Blocks.COARSE_DIRT, Blocks.FARMLAND), - createFlowerPot(temp), - temp = new BlockAuraBloom("aura_cactus", Blocks.SAND, Blocks.RED_SAND), - createFlowerPot(temp), - temp = new BlockAuraBloom("warped_aura_mushroom", Blocks.WARPED_NYLIUM), - createFlowerPot(temp), - temp = new BlockAuraBloom("crimson_aura_mushroom", Blocks.CRIMSON_NYLIUM), - createFlowerPot(temp), - temp = new BlockAuraBloom("aura_mushroom", Blocks.MYCELIUM), - createFlowerPot(temp), - new BlockImpl("tainted_gold_block", Block.Properties.of(Material.METAL).sound(SoundType.METAL).strength(3F)), - new BlockNetherGrass(), - new BlockLight(), - new BlockChorusGenerator(), - new BlockAuraTimer(), - new BlockSlimeSplitGenerator(), - new BlockSpring(), - new BlockWeatherChanger(), - new BlockRFConverter(), - new BlockChunkLoader() - ); - Helper.populateObjectHolders(ModBlocks.class, event.getRegistry()); - } + public static void register(RegisterEvent event) { + event.register(ForgeRegistries.Keys.BLOCKS, h -> { + Block temp; + ModRegistry.registerAll(h, + new BlockAncientLog("ancient_log"), + new BlockAncientLog("ancient_bark"), + temp = new BlockImpl("ancient_planks", Block.Properties.of(Material.WOOD).sound(SoundType.WOOD).strength(2F)), + new BlockStairsNA("ancient_stairs", "ancient_planks", temp::defaultBlockState, Block.Properties.copy(temp)), + new Slab("ancient_slab", "ancient_planks", Block.Properties.copy(temp)), + new BlockAncientLeaves(), + new BlockAncientSapling(), + new BlockNatureAltar(), + new BlockDecayedLeaves(), + new BlockGoldenLeaves(), + new BlockGoldPowder(), + new BlockWoodStand(), + temp = new BlockImpl("infused_stone", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(1.75F)), + new BlockStairsNA("infused_stairs", "infused_stone", temp::defaultBlockState, Block.Properties.copy(temp)), + new Slab("infused_slab", "infused_stone", Block.Properties.copy(temp)), + temp = new BlockImpl("infused_brick", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(1.5F)), + new BlockStairsNA("infused_brick_stairs", "infused_brick", temp::defaultBlockState, Block.Properties.copy(temp)), + new Slab("infused_brick_slab", "infused_brick", Block.Properties.copy(temp)), + new BlockFurnaceHeater(), + new BlockPotionGenerator(), + new BlockAuraDetector(), + new BlockCatalyst("conversion_catalyst", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(2.5F)), + new BlockCatalyst("crushing_catalyst", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(2.5F)), + new BlockFlowerGenerator(), + new BlockPlacer(), + new BlockHopperUpgrade(), + new BlockFieldCreator(), + new BlockOakGenerator(), + new BlockImpl("infused_iron_block", Block.Properties.of(Material.METAL).sound(SoundType.METAL).strength(3F)), + new BlockOfferingTable(), + new BlockPickupStopper(), + new BlockSpawnLamp(), + new BlockAnimalGenerator(), + new BlockEndFlower(), + new BlockGratedChute(), + new BlockAnimalSpawner(), + new BlockAutoCrafter(), + new BlockImpl("gold_brick", Block.Properties.copy(Blocks.STONE_BRICKS)), + new BlockImpl("gold_nether_brick", Block.Properties.copy(Blocks.NETHER_BRICKS)), + new BlockMossGenerator(), + new BlockTimeChanger(), + new BlockGeneratorLimitRemover(), + new BlockEnderCrate(), + new BlockPowderPlacer(), + new BlockFireworkGenerator(), + new BlockProjectileGenerator(), + new BlockDimensionRail("overworld", Level.OVERWORLD, Level.NETHER, Level.END), + new BlockDimensionRail("nether", Level.NETHER, Level.OVERWORLD), + new BlockDimensionRail("end", Level.END, Level.OVERWORLD), + new BlockBlastFurnaceBooster(), + new BlockImpl("nether_wart_mushroom", Block.Properties.copy(Blocks.RED_MUSHROOM_BLOCK)), + new BlockAnimalContainer(), + new BlockSnowCreator(), + new BlockItemDistributor(), + temp = new BlockAuraBloom("aura_bloom", Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.PODZOL, Blocks.COARSE_DIRT, Blocks.FARMLAND), + ModRegistry.createFlowerPot(temp), + temp = new BlockAuraBloom("aura_cactus", Blocks.SAND, Blocks.RED_SAND), + ModRegistry.createFlowerPot(temp), + temp = new BlockAuraBloom("warped_aura_mushroom", Blocks.WARPED_NYLIUM), + ModRegistry.createFlowerPot(temp), + temp = new BlockAuraBloom("crimson_aura_mushroom", Blocks.CRIMSON_NYLIUM), + ModRegistry.createFlowerPot(temp), + temp = new BlockAuraBloom("aura_mushroom", Blocks.MYCELIUM), + ModRegistry.createFlowerPot(temp), + new BlockImpl("tainted_gold_block", Block.Properties.of(Material.METAL).sound(SoundType.METAL).strength(3F)), + new BlockNetherGrass(), + new BlockLight(), + new BlockChorusGenerator(), + new BlockAuraTimer(), + new BlockSlimeSplitGenerator(), + new BlockSpring(), + new BlockWeatherChanger(), + new BlockRFConverter(), + new BlockChunkLoader()); + Helper.populateObjectHolders(ModBlocks.class, event.getForgeRegistry()); + }); - @SubscribeEvent - public static void registerItems(RegistryEvent.Register event) { - for (var block : ALL_ITEMS) { - if (block instanceof Block && !(block instanceof INoItemBlock)) { - var item = new BlockItem((Block) block, new Item.Properties().tab(NaturesAura.CREATIVE_TAB)); - item.setRegistryName(block.getBaseName()); - event.getRegistry().register(item); + event.register(ForgeRegistries.Keys.ITEMS, h -> { + for (var block : ModRegistry.ALL_ITEMS) { + if (block instanceof Block && !(block instanceof INoItemBlock)) { + var item = new BlockItem((Block) block, new Item.Properties().tab(NaturesAura.CREATIVE_TAB)); + h.register(new ResourceLocation(NaturesAura.MOD_ID, block.getBaseName()), item); + } } - } - Item temp; - event.getRegistry().registerAll( - new ItemPickaxe("infused_iron_pickaxe", ModItemTier.INFUSED, 1, -2.8F), - new ItemAxe("infused_iron_axe", ModItemTier.INFUSED, 6.0F, -3.1F), - new ItemShovel("infused_iron_shovel", ModItemTier.INFUSED, 1.5F, -3.0F), - new ItemHoe("infused_iron_hoe", ModItemTier.INFUSED, -1), - new ItemSword("infused_iron_sword", ModItemTier.INFUSED, 3, -2.4F), - new ItemArmor("infused_iron_helmet", ModArmorMaterial.INFUSED, EquipmentSlot.HEAD), - new ItemArmor("infused_iron_chest", ModArmorMaterial.INFUSED, EquipmentSlot.CHEST), - new ItemArmor("infused_iron_pants", ModArmorMaterial.INFUSED, EquipmentSlot.LEGS), - new ItemArmor("infused_iron_shoes", ModArmorMaterial.INFUSED, EquipmentSlot.FEET), - new ItemEye("eye"), - new ItemEye("eye_improved"), - new ItemGoldFiber(), - new ItemImpl("gold_leaf"), - new ItemImpl("infused_iron"), - new ItemImpl("ancient_stick"), - new ItemColorChanger(), - new ItemAuraCache("aura_cache", 400000), - new ItemAuraCache("aura_trove", 1200000), - new ItemShockwaveCreator(), - new ItemMultiblockMaker(), - temp = new ItemImpl("bottle_two_the_rebottling"), - new ItemAuraBottle(temp), - new ItemImpl("farming_stencil"), - new ItemImpl("sky_ingot"), - new ItemGlowing("calling_spirit"), - new ItemEffectPowder(), - new ItemBirthSpirit(), - new ItemMoverMinecart(), - new ItemRangeVisualizer(), - new ItemImpl("clock_hand"), - new ItemImpl("token_joy"), - new ItemImpl("token_fear"), - new ItemImpl("token_anger"), - new ItemImpl("token_sorrow"), - new ItemImpl("token_euphoria"), - new ItemImpl("token_terror"), - new ItemImpl("token_rage"), - new ItemImpl("token_grief"), - new ItemEnderAccess(), - new ItemCaveFinder(), - new ItemCrimsonMeal(), - new ItemDeathRing(), - new ItemImpl("tainted_gold"), - new ItemLootFinder(), - new ItemLightStaff(), - new ItemPickaxe("sky_pickaxe", ModItemTier.SKY, 1, -2.8F), - new ItemAxe("sky_axe", ModItemTier.SKY, 5.0F, -3.0F), - new ItemShovel("sky_shovel", ModItemTier.SKY, 1.5F, -3.0F), - new ItemHoe("sky_hoe", ModItemTier.SKY, -1), - new ItemSword("sky_sword", ModItemTier.SKY, 3, -2.4F), - new ItemArmor("sky_helmet", ModArmorMaterial.SKY, EquipmentSlot.HEAD), - new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlot.CHEST), - new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlot.LEGS), - new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlot.FEET), - new ItemStructureFinder("fortress_finder", StructureFeatures.FORTRESS, 0xba2800, 1024), - new ItemStructureFinder("end_city_finder", StructureFeatures.END_CITY, 0xca5cd6, 1024), - new ItemStructureFinder("outpost_finder", StructureFeatures.PILLAGER_OUTPOST, 0xab9f98, 2048), - new ItemBreakPrevention(), - new ItemPetReviver(), - new ItemNetheriteFinder() - ); - Helper.populateObjectHolders(ModItems.class, event.getRegistry()); - } + Item temp; + ModRegistry.registerAll(h, + new ItemPickaxe("infused_iron_pickaxe", ModItemTier.INFUSED, 1, -2.8F), + new ItemAxe("infused_iron_axe", ModItemTier.INFUSED, 6.0F, -3.1F), + new ItemShovel("infused_iron_shovel", ModItemTier.INFUSED, 1.5F, -3.0F), + new ItemHoe("infused_iron_hoe", ModItemTier.INFUSED, -1), + new ItemSword("infused_iron_sword", ModItemTier.INFUSED, 3, -2.4F), + new ItemArmor("infused_iron_helmet", ModArmorMaterial.INFUSED, EquipmentSlot.HEAD), + new ItemArmor("infused_iron_chest", ModArmorMaterial.INFUSED, EquipmentSlot.CHEST), + new ItemArmor("infused_iron_pants", ModArmorMaterial.INFUSED, EquipmentSlot.LEGS), + new ItemArmor("infused_iron_shoes", ModArmorMaterial.INFUSED, EquipmentSlot.FEET), + new ItemEye("eye"), + new ItemEye("eye_improved"), + new ItemGoldFiber(), + new ItemImpl("gold_leaf"), + new ItemImpl("infused_iron"), + new ItemImpl("ancient_stick"), + new ItemColorChanger(), + new ItemAuraCache("aura_cache", 400000), + new ItemAuraCache("aura_trove", 1200000), + new ItemShockwaveCreator(), + new ItemMultiblockMaker(), + temp = new ItemImpl("bottle_two_the_rebottling"), + new ItemAuraBottle(temp), + new ItemImpl("farming_stencil"), + new ItemImpl("sky_ingot"), + new ItemGlowing("calling_spirit"), + new ItemEffectPowder(), + new ItemBirthSpirit(), + new ItemMoverMinecart(), + new ItemRangeVisualizer(), + new ItemImpl("clock_hand"), + new ItemImpl("token_joy"), + new ItemImpl("token_fear"), + new ItemImpl("token_anger"), + new ItemImpl("token_sorrow"), + new ItemImpl("token_euphoria"), + new ItemImpl("token_terror"), + new ItemImpl("token_rage"), + new ItemImpl("token_grief"), + new ItemEnderAccess(), + new ItemCaveFinder(), + new ItemCrimsonMeal(), + new ItemDeathRing(), + new ItemImpl("tainted_gold"), + new ItemLootFinder(), + new ItemLightStaff(), + new ItemPickaxe("sky_pickaxe", ModItemTier.SKY, 1, -2.8F), + new ItemAxe("sky_axe", ModItemTier.SKY, 5.0F, -3.0F), + new ItemShovel("sky_shovel", ModItemTier.SKY, 1.5F, -3.0F), + new ItemHoe("sky_hoe", ModItemTier.SKY, -1), + new ItemSword("sky_sword", ModItemTier.SKY, 3, -2.4F), + new ItemArmor("sky_helmet", ModArmorMaterial.SKY, EquipmentSlot.HEAD), + new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlot.CHEST), + new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlot.LEGS), + new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlot.FEET), + new ItemStructureFinder("fortress_finder", Structures.FORTRESS, 0xba2800, 1024), + new ItemStructureFinder("end_city_finder", Structures.END_CITY, 0xca5cd6, 1024), + new ItemStructureFinder("outpost_finder", Structures.PILLAGER_OUTPOST, 0xab9f98, 2048), + new ItemBreakPrevention(), + new ItemPetReviver(), + new ItemNetheriteFinder() + ); + Helper.populateObjectHolders(ModItems.class, event.getForgeRegistry()); + }); - @SubscribeEvent - public static void registerTiles(RegistryEvent.Register> event) { - // add tile entities that support multiple blocks - add(new ModTileType<>(BlockEntityAuraBloom::new, "aura_bloom", ALL_ITEMS.stream().filter(i -> i instanceof BlockAuraBloom).toArray(IModItem[]::new))); + event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, h -> { + // add tile entities that support multiple blocks + ModRegistry.ALL_ITEMS.add(new ModTileType<>(BlockEntityAuraBloom::new, "aura_bloom", ModRegistry.ALL_ITEMS.stream().filter(i -> i instanceof BlockAuraBloom).toArray(IModItem[]::new))); - for (var item : ALL_ITEMS) { - if (item instanceof ModTileType type) - event.getRegistry().register(type.type); - } - Helper.populateObjectHolders(ModBlockEntities.class, event.getRegistry()); - } + for (var item : ModRegistry.ALL_ITEMS) { + if (item instanceof ModTileType type) + h.register(new ResourceLocation(NaturesAura.MOD_ID, type.getBaseName()), type.type); + } + Helper.populateObjectHolders(ModBlockEntities.class, event.getForgeRegistry()); + }); - @SubscribeEvent - public static void registerPotions(RegistryEvent.Register event) { - event.getRegistry().registerAll( - new PotionBreathless() - ); - Helper.populateObjectHolders(ModPotions.class, event.getRegistry()); - } + event.register(ForgeRegistries.Keys.MOB_EFFECTS, h -> { + h.register(new ResourceLocation(NaturesAura.MOD_ID, "breathless"), new PotionBreathless()); + Helper.populateObjectHolders(ModPotions.class, event.getForgeRegistry()); + }); - @SubscribeEvent - public static void registerContainers(RegistryEvent.Register> event) { - event.getRegistry().registerAll( - IForgeMenuType.create((windowId, inv, data) -> { - var tile = inv.player.level.getBlockEntity(data.readBlockPos()); - if (tile instanceof BlockEntityEnderCrate crate) - return new ContainerEnderCrate(ModContainers.ENDER_CRATE, windowId, inv.player, crate.getItemHandler()); - return null; - }).setRegistryName("ender_crate"), - IForgeMenuType.create((windowId, inv, data) -> { - IItemHandler handler = ILevelData.getOverworldData(inv.player.level).getEnderStorage(data.readUtf()); - return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, inv.player, handler); - }).setRegistryName("ender_access") - ); - Helper.populateObjectHolders(ModContainers.class, event.getRegistry()); - } + event.register(ForgeRegistries.Keys.CONTAINER_TYPES, h -> { + h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_crate"), IForgeMenuType.create((windowId, inv, data) -> { + var tile = inv.player.level.getBlockEntity(data.readBlockPos()); + if (tile instanceof BlockEntityEnderCrate crate) + return new ContainerEnderCrate(ModContainers.ENDER_CRATE, windowId, inv.player, crate.getItemHandler()); + return null; + })); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_access"), IForgeMenuType.create((windowId, inv, data) -> { + IItemHandler handler = ILevelData.getOverworldData(inv.player.level).getEnderStorage(data.readUtf()); + return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, inv.player, handler); + })); + Helper.populateObjectHolders(ModContainers.class, event.getForgeRegistry()); + }); - @SubscribeEvent - public static void registerEnchantments(RegistryEvent.Register event) { - event.getRegistry().registerAll( - new AuraMendingEnchantment() - ); - Helper.populateObjectHolders(ModEnchantments.class, event.getRegistry()); - } + event.register(ForgeRegistries.Keys.ENCHANTMENTS, h -> { + h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_mending"), new AuraMendingEnchantment()); + Helper.populateObjectHolders(ModEnchantments.class, event.getForgeRegistry()); + }); - @SubscribeEvent - public static void registerEntities(RegistryEvent.Register> event) { - event.getRegistry().registerAll( - EntityType.Builder.of(EntityMoverMinecart::new, MobCategory.MISC) - .sized(1, 1).setShouldReceiveVelocityUpdates(true) - .setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":mover_minecart") - .setRegistryName("mover_cart"), - EntityType.Builder.of(EntityEffectInhibitor::new, MobCategory.MISC) - .sized(1, 1).setShouldReceiveVelocityUpdates(true) - .setTrackingRange(64).setUpdateInterval(20).fireImmune().build(NaturesAura.MOD_ID + ":effect_inhibitor") - .setRegistryName("effect_inhibitor"), - EntityType.Builder.of(EntityLightProjectile::new, MobCategory.MISC) - .sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) - .setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":light_projectile") - .setRegistryName("light_projectile"), - EntityType.Builder.of(EntityStructureFinder::new, MobCategory.MISC) - .sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) - .setTrackingRange(64).setUpdateInterval(2).fireImmune().build(NaturesAura.MOD_ID + ":structure_finder") - .setRegistryName("structure_finder") - ); - Helper.populateObjectHolders(ModEntities.class, event.getRegistry()); - } + event.register(ForgeRegistries.Keys.ENTITY_TYPES, h -> { + h.register(new ResourceLocation(NaturesAura.MOD_ID, "mover_cart"), EntityType.Builder + .of(EntityMoverMinecart::new, MobCategory.MISC) + .sized(1, 1).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":mover_minecart")); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "effect_inhibitor"), EntityType.Builder + .of(EntityEffectInhibitor::new, MobCategory.MISC) + .sized(1, 1).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(20).fireImmune().build(NaturesAura.MOD_ID + ":effect_inhibitor")); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "light_projectile"), EntityType.Builder + .of(EntityLightProjectile::new, MobCategory.MISC) + .sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":light_projectile")); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "structure_finder"), EntityType.Builder + .of(EntityStructureFinder::new, MobCategory.MISC) + .sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(2).fireImmune().build(NaturesAura.MOD_ID + ":structure_finder")); + Helper.populateObjectHolders(ModEntities.class, event.getForgeRegistry()); + }); - @SubscribeEvent - public static void registerFeatures(RegistryEvent.Register> event) { - event.getRegistry().registerAll( - new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false).setRegistryName("aura_bloom"), - new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false).setRegistryName("aura_cactus"), - new LevelGenAuraBloom(ModBlocks.WARPED_AURA_MUSHROOM, 10, true).setRegistryName("warped_aura_mushroom"), - new LevelGenAuraBloom(ModBlocks.CRIMSON_AURA_MUSHROOM, 10, true).setRegistryName("crimson_aura_mushroom"), - new LevelGenAuraBloom(ModBlocks.AURA_MUSHROOM, 20, false).setRegistryName("aura_mushroom"), - new LevelGenAncientTree().setRegistryName("ancient_tree"), - new LevelGenNetherWartMushroom().setRegistryName("nether_wart_mushroom") - ); - Helper.populateObjectHolders(ModFeatures.class, event.getRegistry()); - } + event.register(ForgeRegistries.Keys.FEATURES, h -> { + h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_bloom"), new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false)); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false)); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "warped_aura_mushroom"), new LevelGenAuraBloom(ModBlocks.WARPED_AURA_MUSHROOM, 10, true)); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "crimson_aura_mushroom"), new LevelGenAuraBloom(ModBlocks.CRIMSON_AURA_MUSHROOM, 10, true)); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_mushroom"), new LevelGenAuraBloom(ModBlocks.AURA_MUSHROOM, 20, false)); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "ancient_tree"), new LevelGenAncientTree()); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "nether_wart_mushroom"), new LevelGenNetherWartMushroom()); + Helper.populateObjectHolders(ModFeatures.class, event.getForgeRegistry()); + }); - @SubscribeEvent - public static void registerRecipes(RegistryEvent.Register> event) { - ModRecipes.register(event.getRegistry()); - CraftingHelper.register(new EnabledCondition.Serializer()); + event.register(ForgeRegistries.Keys.RECIPE_TYPES, h -> { + h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_TYPE); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_TYPE); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_TYPE); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_TYPE); + }); + + event.register(ForgeRegistries.Keys.RECIPE_SERIALIZERS, h -> { + h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_SERIALIZER); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_SERIALIZER); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_SERIALIZER); + h.register(new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_SERIALIZER); + CraftingHelper.register(new EnabledCondition.Serializer()); + }); } public static void init() { - ModFeatures.Configured.AURA_BLOOM = FeatureUtils.register(ModFeatures.AURA_BLOOM.getRegistryName().toString(), ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE); - ModFeatures.Configured.AURA_CACTUS = FeatureUtils.register(ModFeatures.AURA_CACTUS.getRegistryName().toString(), ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE); - ModFeatures.Configured.WARPED_AURA_MUSHROOM = FeatureUtils.register(ModFeatures.WARPED_AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); - ModFeatures.Configured.CRIMSON_AURA_MUSHROOM = FeatureUtils.register(ModFeatures.CRIMSON_AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.CRIMSON_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); - ModFeatures.Configured.AURA_MUSHROOM = FeatureUtils.register(ModFeatures.AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); - ModFeatures.Configured.ANCIENT_TREE = FeatureUtils.register(ModFeatures.ANCIENT_TREE.getRegistryName().toString(), ModFeatures.ANCIENT_TREE, new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build()); - ModFeatures.Configured.NETHER_WART_MUSHROOM = FeatureUtils.register(ModFeatures.NETHER_WART_MUSHROOM.getRegistryName().toString(), ModFeatures.NETHER_WART_MUSHROOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.AURA_BLOOM = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_bloom", ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.AURA_CACTUS = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_cactus", ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.WARPED_AURA_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":warped_aura_mushroom", ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.CRIMSON_AURA_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":crimson_aura_mushroom", ModFeatures.CRIMSON_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.AURA_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_mushroom", ModFeatures.AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); + ModFeatures.Configured.ANCIENT_TREE = FeatureUtils.register(NaturesAura.MOD_ID + ":ancient_tree", ModFeatures.ANCIENT_TREE, new TreeConfiguration.TreeConfigurationBuilder(null, null, null, null, null).build()); + ModFeatures.Configured.NETHER_WART_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":nether_wart_mushroom", ModFeatures.NETHER_WART_MUSHROOM, NoneFeatureConfiguration.INSTANCE); - ModFeatures.Placed.AURA_BLOOM = PlacementUtils.register(ModFeatures.AURA_BLOOM.getRegistryName().toString(), ModFeatures.Configured.AURA_BLOOM); - ModFeatures.Placed.AURA_CACTUS = PlacementUtils.register(ModFeatures.AURA_CACTUS.getRegistryName().toString(), ModFeatures.Configured.AURA_CACTUS); - ModFeatures.Placed.WARPED_AURA_MUSHROOM = PlacementUtils.register(ModFeatures.WARPED_AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.Configured.WARPED_AURA_MUSHROOM); - ModFeatures.Placed.CRIMSON_AURA_MUSHROOM = PlacementUtils.register(ModFeatures.CRIMSON_AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.Configured.CRIMSON_AURA_MUSHROOM); - ModFeatures.Placed.AURA_MUSHROOM = PlacementUtils.register(ModFeatures.AURA_MUSHROOM.getRegistryName().toString(), ModFeatures.Configured.AURA_MUSHROOM); + ModFeatures.Placed.AURA_BLOOM = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_bloom", ModFeatures.Configured.AURA_BLOOM); + ModFeatures.Placed.AURA_CACTUS = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_cactus", ModFeatures.Configured.AURA_CACTUS); + ModFeatures.Placed.WARPED_AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":warped_aura_mushroom", ModFeatures.Configured.WARPED_AURA_MUSHROOM); + ModFeatures.Placed.CRIMSON_AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":crimson_aura_mushroom", ModFeatures.Configured.CRIMSON_AURA_MUSHROOM); + ModFeatures.Placed.AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_mushroom", ModFeatures.Configured.AURA_MUSHROOM); } public static Block createFlowerPot(Block block) { var props = Block.Properties.of(Material.DECORATION).strength(0F); Block potted = new BlockFlowerPot(() -> (FlowerPotBlock) Blocks.FLOWER_POT, () -> block, props); - ((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(block.getRegistryName(), () -> potted); + ((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(ForgeRegistries.BLOCKS.getKey(block), () -> potted); return potted; } + + @SafeVarargs + private static void registerAll(RegisterEvent.RegisterHelper helper, T... items) { + for (var item : items) + helper.register(new ResourceLocation(NaturesAura.MOD_ID, ((IModItem) item).getBaseName()), item); + } } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java b/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java index c34ec4e2..c332fb4b 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModTileType.java @@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.reg; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraftforge.registries.ForgeRegistryEntry; import java.util.Arrays; @@ -26,9 +25,4 @@ public class ModTileType implements IModItem { public String getBaseName() { return this.name; } - - @Override - public ForgeRegistryEntry getRegistryEntry() { - return this.type; - } } diff --git a/src/main/java/de/ellpeck/naturesaura/renderers/SupporterFancyHandler.java b/src/main/java/de/ellpeck/naturesaura/renderers/SupporterFancyHandler.java index 71670a89..17099238 100644 --- a/src/main/java/de/ellpeck/naturesaura/renderers/SupporterFancyHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/renderers/SupporterFancyHandler.java @@ -41,7 +41,7 @@ public class SupporterFancyHandler { var mc = Minecraft.getInstance(); if (player == mc.player && mc.options.getCameraType() == CameraType.FIRST_PERSON) return; - var info = FANCY_INFOS.get(player.getGameProfile().getName()); + var info = SupporterFancyHandler.FANCY_INFOS.get(player.getGameProfile().getName()); if (info == null) return; @@ -89,7 +89,7 @@ public class SupporterFancyHandler { var object = entry.getValue().getAsJsonObject(); var tier = object.get("tier").getAsInt(); var color = object.has("color") ? Integer.parseInt(object.get("color").getAsString(), 16) : 0; - FANCY_INFOS.put(entry.getKey(), new FancyInfo(tier, color)); + SupporterFancyHandler.FANCY_INFOS.put(entry.getKey(), new FancyInfo(tier, color)); } reader.close();