Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.

Restore compatibility with NeoForge

+120 -91
-79
forge/src/main/java/net/lerariemann/infinity/fluids/forge/FluidTypes.java
··· 33 33 import java.util.function.Consumer; 34 34 35 35 public class FluidTypes { 36 - private static final DeferredRegister<FluidType> FLUID_TYPES = DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, InfinityMod.MOD_ID); 37 36 38 - public static final RegistryObject<FluidType> IRIDESCENCE_TYPE = FLUID_TYPES.register("iridescence", 39 - () -> new IridescentFluidType(FluidType.Properties.create() 40 - .descriptionId("fluid.infinity.iridescence") 41 - .fallDistanceModifier(0F) 42 - .canExtinguish(true) 43 - .canConvertToSource(true) 44 - .supportsBoating(true) 45 - .canSwim(true) 46 - .canHydrate(true) 47 - .sound(SoundActions.BUCKET_FILL, SoundEvents.ITEM_BUCKET_FILL) 48 - .sound(SoundActions.BUCKET_EMPTY, SoundEvents.ITEM_BUCKET_EMPTY) 49 - .sound(SoundActions.FLUID_VAPORIZE, SoundEvents.BLOCK_FIRE_EXTINGUISH) 50 - .pathType(PathNodeType.WATER) 51 - .adjacentPathType(PathNodeType.WATER)) { 52 - 53 - @Override 54 - public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) { 55 - consumer.accept(new IClientFluidTypeExtensions() { 56 - private static final Identifier IRIDESCENCE = InfinityMethods.getId("block/iridescence"); 57 - 58 - @Override 59 - public @NotNull Identifier getStillTexture() { 60 - return IRIDESCENCE; 61 - } 62 - 63 - @Override 64 - public @NotNull Identifier getFlowingTexture() { 65 - return IRIDESCENCE; 66 - } 67 - 68 - @Override 69 - public int getTintColor(@NotNull FluidState state, @NotNull BlockRenderView getter, @NotNull BlockPos pos) { 70 - return ColorHelper.Abgr.toOpaque(Iridescence.getPosBasedColor(pos)); 71 - } 72 - }); 73 - } 74 - }); 75 - 76 - public static FluidInteractionRegistry.InteractionInformation getIridescentInteraction(FluidType type) { 77 - return new FluidInteractionRegistry.InteractionInformation( 78 - (level, currentPos, relativePos, currentState) -> level.getFluidState(relativePos).getFluidType() == type, 79 - (level, currentPos, relativePos, currentState) -> { 80 - level.setBlockState(currentPos, ForgeEventFactory.fireFluidPlaceBlockEvent(level, currentPos, currentPos, 81 - currentState.isStill() ? Blocks.OBSIDIAN.getDefaultState() : 82 - Iridescence.getRandomColorBlock(level,"glazed_terracotta").getDefaultState())); 83 - level.syncWorldEvent(1501, currentPos, 0); 84 - }); 85 - } 86 - 87 - public static void registerFluidTypes(IEventBus bus) { 88 - FLUID_TYPES.register(bus); 89 - } 90 - public static void registerFluidInteractions(FMLCommonSetupEvent event) { 91 - FluidInteractionRegistry.addInteraction(ForgeMod.LAVA_TYPE.get(), getIridescentInteraction(IRIDESCENCE_TYPE.get())); 92 - } 93 - 94 - public static class IridescentFluidType extends FluidType { 95 - public IridescentFluidType(Properties properties) { 96 - super(properties); 97 - } 98 - @Override 99 - public PathNodeType getBlockPathType(@NotNull FluidState state, @NotNull BlockView level, @NotNull BlockPos pos, 100 - @Nullable MobEntity mob, boolean canFluidLog) { 101 - return canFluidLog ? super.getBlockPathType(state, level, pos, mob, true) : null; 102 - } 103 - @Override 104 - public boolean canConvertToSource(@NotNull FluidState state, @NotNull WorldView reader, @NotNull BlockPos pos) { 105 - if (reader instanceof World level) { 106 - return Iridescence.isInfinite(level); 107 - } 108 - //Best guess fallback to default (true) 109 - return super.canConvertToSource(state, reader, pos); 110 - } 111 - @Override 112 - public boolean isVaporizedOnPlacement(@NotNull World w, @NotNull BlockPos pos, @NotNull FluidStack stack) { 113 - return false; 114 - } 115 - } 116 37 }
+110 -2
forge/src/main/java/net/lerariemann/infinity/fluids/forge/ModFluidsForge.java
··· 2 2 3 3 import dev.architectury.registry.registries.DeferredRegister; 4 4 import dev.architectury.registry.registries.RegistrySupplier; 5 + import net.lerariemann.infinity.InfinityMod; 6 + import net.lerariemann.infinity.iridescence.Iridescence; 5 7 import net.lerariemann.infinity.registry.core.ModBlocks; 6 8 import net.lerariemann.infinity.registry.core.ModItems; 9 + import net.lerariemann.infinity.util.InfinityMethods; 10 + import net.minecraft.block.Blocks; 11 + import net.minecraft.entity.ai.pathing.PathNodeType; 12 + import net.minecraft.entity.mob.MobEntity; 7 13 import net.minecraft.fluid.Fluid; 14 + import net.minecraft.fluid.FluidState; 8 15 import net.minecraft.registry.RegistryKeys; 16 + import net.minecraft.sound.SoundEvents; 17 + import net.minecraft.util.Identifier; 18 + import net.minecraft.util.math.BlockPos; 19 + import net.minecraft.util.math.ColorHelper; 20 + import net.minecraft.world.BlockRenderView; 21 + import net.minecraft.world.BlockView; 22 + import net.minecraft.world.World; 23 + import net.minecraft.world.WorldView; 24 + import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; 25 + import net.minecraftforge.common.ForgeMod; 26 + import net.minecraftforge.common.SoundActions; 27 + import net.minecraftforge.event.ForgeEventFactory; 28 + import net.minecraftforge.eventbus.api.IEventBus; 29 + import net.minecraftforge.fluids.FluidInteractionRegistry; 30 + import net.minecraftforge.fluids.FluidStack; 31 + import net.minecraftforge.fluids.FluidType; 9 32 import net.minecraftforge.fluids.ForgeFlowingFluid; 33 + import net.minecraftforge.registries.ForgeRegistries; 34 + import net.minecraftforge.registries.RegistryObject; 35 + import org.jetbrains.annotations.NotNull; 36 + import org.jetbrains.annotations.Nullable; 37 + 38 + import java.util.function.Consumer; 10 39 11 40 import static net.lerariemann.infinity.InfinityMod.MOD_ID; 12 41 13 42 public class ModFluidsForge { 14 43 public static final DeferredRegister<Fluid> FLUIDS = DeferredRegister.create(MOD_ID, RegistryKeys.FLUID); 44 + private static final net.minecraftforge.registries.DeferredRegister<FluidType> FLUID_TYPES = net.minecraftforge.registries.DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, InfinityMod.MOD_ID); 15 45 16 46 public static final RegistrySupplier<ForgeFlowingFluid.Flowing> IRIDESCENCE_FLOWING = 17 47 FLUIDS.register("flowing_iridescence", () -> new ForgeFlowingFluid.Flowing(iridProp())); 48 + 18 49 public static final RegistrySupplier<ForgeFlowingFluid.Source> IRIDESCENCE_STILL = 19 50 FLUIDS.register("iridescence", () -> new ForgeFlowingFluid.Source(iridProp())); 20 51 21 52 public static ForgeFlowingFluid.Properties iridProp() { 22 - return (new ForgeFlowingFluid.Properties(FluidTypes.IRIDESCENCE_TYPE, 53 + return (new ForgeFlowingFluid.Properties(IRIDESCENCE_TYPE, 23 54 IRIDESCENCE_STILL, IRIDESCENCE_FLOWING)) 24 55 .bucket(ModItems.IRIDESCENCE_BUCKET) 25 56 .block(ModBlocks.IRIDESCENCE); 26 57 } 27 58 28 - public static void registerModFluids() { 59 + public static final RegistryObject<FluidType> IRIDESCENCE_TYPE = FLUID_TYPES.register("iridescence", 60 + () -> new IridescentFluidType(FluidType.Properties.create() 61 + .descriptionId("fluid.infinity.iridescence") 62 + .fallDistanceModifier(0F) 63 + .canExtinguish(true) 64 + .canConvertToSource(true) 65 + .supportsBoating(true) 66 + .canSwim(true) 67 + .canHydrate(true) 68 + .sound(SoundActions.BUCKET_FILL, SoundEvents.ITEM_BUCKET_FILL) 69 + .sound(SoundActions.BUCKET_EMPTY, SoundEvents.ITEM_BUCKET_EMPTY) 70 + .sound(SoundActions.FLUID_VAPORIZE, SoundEvents.BLOCK_FIRE_EXTINGUISH) 71 + .pathType(PathNodeType.WATER) 72 + .adjacentPathType(PathNodeType.WATER)) { 73 + 74 + @Override 75 + public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) { 76 + consumer.accept(new IClientFluidTypeExtensions() { 77 + private static final Identifier IRIDESCENCE = InfinityMethods.getId("block/iridescence"); 78 + 79 + @Override 80 + public @NotNull Identifier getStillTexture() { 81 + return IRIDESCENCE; 82 + } 83 + 84 + @Override 85 + public @NotNull Identifier getFlowingTexture() { 86 + return IRIDESCENCE; 87 + } 88 + 89 + @Override 90 + public int getTintColor(@NotNull FluidState state, @NotNull BlockRenderView getter, @NotNull BlockPos pos) { 91 + return ColorHelper.Abgr.toOpaque(Iridescence.getPosBasedColor(pos)); 92 + } 93 + }); 94 + } 95 + }); 96 + 97 + public static class IridescentFluidType extends FluidType { 98 + public IridescentFluidType(Properties properties) { 99 + super(properties); 100 + } 101 + @Override 102 + public PathNodeType getBlockPathType(@NotNull FluidState state, @NotNull BlockView level, @NotNull BlockPos pos, 103 + @Nullable MobEntity mob, boolean canFluidLog) { 104 + return canFluidLog ? super.getBlockPathType(state, level, pos, mob, true) : null; 105 + } 106 + @Override 107 + public boolean canConvertToSource(@NotNull FluidState state, @NotNull WorldView reader, @NotNull BlockPos pos) { 108 + if (reader instanceof World level) { 109 + return Iridescence.isInfinite(level); 110 + } 111 + //Best guess fallback to default (true) 112 + return super.canConvertToSource(state, reader, pos); 113 + } 114 + @Override 115 + public boolean isVaporizedOnPlacement(@NotNull World w, @NotNull BlockPos pos, @NotNull FluidStack stack) { 116 + return false; 117 + } 118 + } 119 + 120 + public static FluidInteractionRegistry.InteractionInformation getIridescentInteraction(FluidType type) { 121 + return new FluidInteractionRegistry.InteractionInformation( 122 + (level, currentPos, relativePos, currentState) -> level.getFluidState(relativePos).getFluidType() == type, 123 + (level, currentPos, relativePos, currentState) -> { 124 + level.setBlockState(currentPos, ForgeEventFactory.fireFluidPlaceBlockEvent(level, currentPos, currentPos, 125 + currentState.isStill() ? Blocks.OBSIDIAN.getDefaultState() : 126 + Iridescence.getRandomColorBlock(level,"glazed_terracotta").getDefaultState())); 127 + level.syncWorldEvent(1501, currentPos, 0); 128 + }); 129 + } 130 + 131 + public static void registerModFluids(IEventBus bus) { 29 132 FLUIDS.register(); 133 + FLUID_TYPES.register(bus); 134 + } 135 + 136 + public static void registerFluidInteractions() { 137 + FluidInteractionRegistry.addInteraction(ForgeMod.LAVA_TYPE.get(), getIridescentInteraction(IRIDESCENCE_TYPE.get())); 30 138 } 31 139 }
+3 -4
forge/src/main/java/net/lerariemann/infinity/forge/InfinityModForge.java
··· 50 50 // Run any remaining Forge specific tasks. 51 51 eventBus.addListener(InfinityModForge::registerSpawns); 52 52 eventBus.addListener(InfinityModForge::commonSetup); 53 - eventBus.addListener(FluidTypes::registerFluidInteractions); 54 53 MinecraftForge.EVENT_BUS.addListener(InfinityModForge::sliderSpamFix); 55 - 56 - FluidTypes.registerFluidTypes(eventBus); 57 - ModFluidsForge.registerModFluids(); 54 + 55 + ModFluidsForge.registerModFluids(eventBus); 58 56 ModEffectsForge.register(eventBus); 59 57 ModTags.IRIDESCENT_ITEMS = ItemTags.create(InfinityMethods.getId("iridescent")); 60 58 } ··· 82 80 ModItemFunctions.registerDispenserBehaviour(); 83 81 if (isCreateLoaded()) 84 82 CreateCompat.register(); 83 + ModFluidsForge.registerFluidInteractions(); 85 84 } 86 85 }
+3 -2
forge/src/main/java/net/lerariemann/infinity/forge/client/InfinityModForgeClient.java
··· 14 14 import net.minecraftforge.client.event.RegisterColorHandlersEvent; 15 15 import net.minecraftforge.eventbus.api.IEventBus; 16 16 import net.minecraftforge.eventbus.api.SubscribeEvent; 17 + import net.minecraftforge.fml.ModLoadingContext; 17 18 import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; 18 19 import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; 19 20 ··· 21 22 22 23 public static void initializeClient(FMLJavaModLoadingContext context, IEventBus eventBus) { 23 24 InfinityModClient.initializeClient(); 24 - InfinityModForgeClient.registerModsPage(context); 25 + InfinityModForgeClient.registerModsPage(ModLoadingContext.get()); 25 26 eventBus.addListener(InfinityModForgeClient::registerBlockColorHandlers); 26 27 eventBus.addListener(InfinityModForgeClient::registerItemColorHandlers); 27 28 eventBus.addListener(InfinityModForgeClient::registerFluidRenderLayers); ··· 29 30 } 30 31 31 32 //Integrate Cloth Config screen (if mod present) with Forge mod menu. 32 - public static void registerModsPage(FMLJavaModLoadingContext context) { 33 + public static void registerModsPage(ModLoadingContext context) { 33 34 if (clothConfigInstalled()) context.registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory(ModConfigFactory::createScreen)); 34 35 } 35 36
+3 -3
forge/src/main/java/net/lerariemann/infinity/util/forge/PlatformMethodsImpl.java
··· 105 105 106 106 public static boolean acidTest(Entity entity, boolean eyes) { 107 107 if (entity instanceof PlayerEntity) return false; 108 - if (eyes) return entity.isEyeInFluidType(FluidTypes.IRIDESCENCE_TYPE.get()); 109 - return entity.isInFluidType(FluidTypes.IRIDESCENCE_TYPE.get()); 108 + if (eyes) return entity.isEyeInFluidType(ModFluidsForge.IRIDESCENCE_TYPE.get()); 109 + return entity.isInFluidType(ModFluidsForge.IRIDESCENCE_TYPE.get()); 110 110 } 111 111 112 112 public static double acidHeightTest(Entity entity) { 113 113 if (entity instanceof PlayerEntity) return -1; 114 - return entity.getFluidTypeHeight(FluidTypes.IRIDESCENCE_TYPE.get()); 114 + return entity.getFluidTypeHeight(ModFluidsForge.IRIDESCENCE_TYPE.get()); 115 115 } 116 116 117 117 public static Function<Item.Settings, ? extends StarOfLangItem> getStarOfLangConstructor() {
+1 -1
gradle.properties
··· 21 21 fabric_api_version = 0.92.2+1.20.1 22 22 23 23 # Forge Dependencies 24 - forge_version = 1.20.1-47.4.0 24 + forge_version = 1.20.1-47.1.3 25 25 forgified_fabric_api_version = 0.92.2+1.11.8+1.20.1 26 26 27 27 # Optional Dependencies