tangled
alpha
login
or
join now
codexarchonic.nekoweb.org
/
ProjectInfinity
0
fork
atom
Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
0
fork
atom
overview
issues
6
pulls
pipelines
Restore compatibility with NeoForge
cassian.cc
9 months ago
b79d13bf
599afa1f
+120
-91
6 changed files
expand all
collapse all
unified
split
forge
src
main
java
net
lerariemann
infinity
fluids
forge
FluidTypes.java
ModFluidsForge.java
forge
InfinityModForge.java
client
InfinityModForgeClient.java
util
forge
PlatformMethodsImpl.java
gradle.properties
-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
36
-
private static final DeferredRegister<FluidType> FLUID_TYPES = DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, InfinityMod.MOD_ID);
37
36
38
38
-
public static final RegistryObject<FluidType> IRIDESCENCE_TYPE = FLUID_TYPES.register("iridescence",
39
39
-
() -> new IridescentFluidType(FluidType.Properties.create()
40
40
-
.descriptionId("fluid.infinity.iridescence")
41
41
-
.fallDistanceModifier(0F)
42
42
-
.canExtinguish(true)
43
43
-
.canConvertToSource(true)
44
44
-
.supportsBoating(true)
45
45
-
.canSwim(true)
46
46
-
.canHydrate(true)
47
47
-
.sound(SoundActions.BUCKET_FILL, SoundEvents.ITEM_BUCKET_FILL)
48
48
-
.sound(SoundActions.BUCKET_EMPTY, SoundEvents.ITEM_BUCKET_EMPTY)
49
49
-
.sound(SoundActions.FLUID_VAPORIZE, SoundEvents.BLOCK_FIRE_EXTINGUISH)
50
50
-
.pathType(PathNodeType.WATER)
51
51
-
.adjacentPathType(PathNodeType.WATER)) {
52
52
-
53
53
-
@Override
54
54
-
public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) {
55
55
-
consumer.accept(new IClientFluidTypeExtensions() {
56
56
-
private static final Identifier IRIDESCENCE = InfinityMethods.getId("block/iridescence");
57
57
-
58
58
-
@Override
59
59
-
public @NotNull Identifier getStillTexture() {
60
60
-
return IRIDESCENCE;
61
61
-
}
62
62
-
63
63
-
@Override
64
64
-
public @NotNull Identifier getFlowingTexture() {
65
65
-
return IRIDESCENCE;
66
66
-
}
67
67
-
68
68
-
@Override
69
69
-
public int getTintColor(@NotNull FluidState state, @NotNull BlockRenderView getter, @NotNull BlockPos pos) {
70
70
-
return ColorHelper.Abgr.toOpaque(Iridescence.getPosBasedColor(pos));
71
71
-
}
72
72
-
});
73
73
-
}
74
74
-
});
75
75
-
76
76
-
public static FluidInteractionRegistry.InteractionInformation getIridescentInteraction(FluidType type) {
77
77
-
return new FluidInteractionRegistry.InteractionInformation(
78
78
-
(level, currentPos, relativePos, currentState) -> level.getFluidState(relativePos).getFluidType() == type,
79
79
-
(level, currentPos, relativePos, currentState) -> {
80
80
-
level.setBlockState(currentPos, ForgeEventFactory.fireFluidPlaceBlockEvent(level, currentPos, currentPos,
81
81
-
currentState.isStill() ? Blocks.OBSIDIAN.getDefaultState() :
82
82
-
Iridescence.getRandomColorBlock(level,"glazed_terracotta").getDefaultState()));
83
83
-
level.syncWorldEvent(1501, currentPos, 0);
84
84
-
});
85
85
-
}
86
86
-
87
87
-
public static void registerFluidTypes(IEventBus bus) {
88
88
-
FLUID_TYPES.register(bus);
89
89
-
}
90
90
-
public static void registerFluidInteractions(FMLCommonSetupEvent event) {
91
91
-
FluidInteractionRegistry.addInteraction(ForgeMod.LAVA_TYPE.get(), getIridescentInteraction(IRIDESCENCE_TYPE.get()));
92
92
-
}
93
93
-
94
94
-
public static class IridescentFluidType extends FluidType {
95
95
-
public IridescentFluidType(Properties properties) {
96
96
-
super(properties);
97
97
-
}
98
98
-
@Override
99
99
-
public PathNodeType getBlockPathType(@NotNull FluidState state, @NotNull BlockView level, @NotNull BlockPos pos,
100
100
-
@Nullable MobEntity mob, boolean canFluidLog) {
101
101
-
return canFluidLog ? super.getBlockPathType(state, level, pos, mob, true) : null;
102
102
-
}
103
103
-
@Override
104
104
-
public boolean canConvertToSource(@NotNull FluidState state, @NotNull WorldView reader, @NotNull BlockPos pos) {
105
105
-
if (reader instanceof World level) {
106
106
-
return Iridescence.isInfinite(level);
107
107
-
}
108
108
-
//Best guess fallback to default (true)
109
109
-
return super.canConvertToSource(state, reader, pos);
110
110
-
}
111
111
-
@Override
112
112
-
public boolean isVaporizedOnPlacement(@NotNull World w, @NotNull BlockPos pos, @NotNull FluidStack stack) {
113
113
-
return false;
114
114
-
}
115
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
5
+
import net.lerariemann.infinity.InfinityMod;
6
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
9
+
import net.lerariemann.infinity.util.InfinityMethods;
10
10
+
import net.minecraft.block.Blocks;
11
11
+
import net.minecraft.entity.ai.pathing.PathNodeType;
12
12
+
import net.minecraft.entity.mob.MobEntity;
7
13
import net.minecraft.fluid.Fluid;
14
14
+
import net.minecraft.fluid.FluidState;
8
15
import net.minecraft.registry.RegistryKeys;
16
16
+
import net.minecraft.sound.SoundEvents;
17
17
+
import net.minecraft.util.Identifier;
18
18
+
import net.minecraft.util.math.BlockPos;
19
19
+
import net.minecraft.util.math.ColorHelper;
20
20
+
import net.minecraft.world.BlockRenderView;
21
21
+
import net.minecraft.world.BlockView;
22
22
+
import net.minecraft.world.World;
23
23
+
import net.minecraft.world.WorldView;
24
24
+
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
25
25
+
import net.minecraftforge.common.ForgeMod;
26
26
+
import net.minecraftforge.common.SoundActions;
27
27
+
import net.minecraftforge.event.ForgeEventFactory;
28
28
+
import net.minecraftforge.eventbus.api.IEventBus;
29
29
+
import net.minecraftforge.fluids.FluidInteractionRegistry;
30
30
+
import net.minecraftforge.fluids.FluidStack;
31
31
+
import net.minecraftforge.fluids.FluidType;
9
32
import net.minecraftforge.fluids.ForgeFlowingFluid;
33
33
+
import net.minecraftforge.registries.ForgeRegistries;
34
34
+
import net.minecraftforge.registries.RegistryObject;
35
35
+
import org.jetbrains.annotations.NotNull;
36
36
+
import org.jetbrains.annotations.Nullable;
37
37
+
38
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
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
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
22
-
return (new ForgeFlowingFluid.Properties(FluidTypes.IRIDESCENCE_TYPE,
53
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
28
-
public static void registerModFluids() {
59
59
+
public static final RegistryObject<FluidType> IRIDESCENCE_TYPE = FLUID_TYPES.register("iridescence",
60
60
+
() -> new IridescentFluidType(FluidType.Properties.create()
61
61
+
.descriptionId("fluid.infinity.iridescence")
62
62
+
.fallDistanceModifier(0F)
63
63
+
.canExtinguish(true)
64
64
+
.canConvertToSource(true)
65
65
+
.supportsBoating(true)
66
66
+
.canSwim(true)
67
67
+
.canHydrate(true)
68
68
+
.sound(SoundActions.BUCKET_FILL, SoundEvents.ITEM_BUCKET_FILL)
69
69
+
.sound(SoundActions.BUCKET_EMPTY, SoundEvents.ITEM_BUCKET_EMPTY)
70
70
+
.sound(SoundActions.FLUID_VAPORIZE, SoundEvents.BLOCK_FIRE_EXTINGUISH)
71
71
+
.pathType(PathNodeType.WATER)
72
72
+
.adjacentPathType(PathNodeType.WATER)) {
73
73
+
74
74
+
@Override
75
75
+
public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) {
76
76
+
consumer.accept(new IClientFluidTypeExtensions() {
77
77
+
private static final Identifier IRIDESCENCE = InfinityMethods.getId("block/iridescence");
78
78
+
79
79
+
@Override
80
80
+
public @NotNull Identifier getStillTexture() {
81
81
+
return IRIDESCENCE;
82
82
+
}
83
83
+
84
84
+
@Override
85
85
+
public @NotNull Identifier getFlowingTexture() {
86
86
+
return IRIDESCENCE;
87
87
+
}
88
88
+
89
89
+
@Override
90
90
+
public int getTintColor(@NotNull FluidState state, @NotNull BlockRenderView getter, @NotNull BlockPos pos) {
91
91
+
return ColorHelper.Abgr.toOpaque(Iridescence.getPosBasedColor(pos));
92
92
+
}
93
93
+
});
94
94
+
}
95
95
+
});
96
96
+
97
97
+
public static class IridescentFluidType extends FluidType {
98
98
+
public IridescentFluidType(Properties properties) {
99
99
+
super(properties);
100
100
+
}
101
101
+
@Override
102
102
+
public PathNodeType getBlockPathType(@NotNull FluidState state, @NotNull BlockView level, @NotNull BlockPos pos,
103
103
+
@Nullable MobEntity mob, boolean canFluidLog) {
104
104
+
return canFluidLog ? super.getBlockPathType(state, level, pos, mob, true) : null;
105
105
+
}
106
106
+
@Override
107
107
+
public boolean canConvertToSource(@NotNull FluidState state, @NotNull WorldView reader, @NotNull BlockPos pos) {
108
108
+
if (reader instanceof World level) {
109
109
+
return Iridescence.isInfinite(level);
110
110
+
}
111
111
+
//Best guess fallback to default (true)
112
112
+
return super.canConvertToSource(state, reader, pos);
113
113
+
}
114
114
+
@Override
115
115
+
public boolean isVaporizedOnPlacement(@NotNull World w, @NotNull BlockPos pos, @NotNull FluidStack stack) {
116
116
+
return false;
117
117
+
}
118
118
+
}
119
119
+
120
120
+
public static FluidInteractionRegistry.InteractionInformation getIridescentInteraction(FluidType type) {
121
121
+
return new FluidInteractionRegistry.InteractionInformation(
122
122
+
(level, currentPos, relativePos, currentState) -> level.getFluidState(relativePos).getFluidType() == type,
123
123
+
(level, currentPos, relativePos, currentState) -> {
124
124
+
level.setBlockState(currentPos, ForgeEventFactory.fireFluidPlaceBlockEvent(level, currentPos, currentPos,
125
125
+
currentState.isStill() ? Blocks.OBSIDIAN.getDefaultState() :
126
126
+
Iridescence.getRandomColorBlock(level,"glazed_terracotta").getDefaultState()));
127
127
+
level.syncWorldEvent(1501, currentPos, 0);
128
128
+
});
129
129
+
}
130
130
+
131
131
+
public static void registerModFluids(IEventBus bus) {
29
132
FLUIDS.register();
133
133
+
FLUID_TYPES.register(bus);
134
134
+
}
135
135
+
136
136
+
public static void registerFluidInteractions() {
137
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
53
-
eventBus.addListener(FluidTypes::registerFluidInteractions);
54
53
MinecraftForge.EVENT_BUS.addListener(InfinityModForge::sliderSpamFix);
55
55
-
56
56
-
FluidTypes.registerFluidTypes(eventBus);
57
57
-
ModFluidsForge.registerModFluids();
54
54
+
55
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
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
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
24
-
InfinityModForgeClient.registerModsPage(context);
25
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
32
-
public static void registerModsPage(FMLJavaModLoadingContext context) {
33
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
108
-
if (eyes) return entity.isEyeInFluidType(FluidTypes.IRIDESCENCE_TYPE.get());
109
109
-
return entity.isInFluidType(FluidTypes.IRIDESCENCE_TYPE.get());
108
108
+
if (eyes) return entity.isEyeInFluidType(ModFluidsForge.IRIDESCENCE_TYPE.get());
109
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
114
-
return entity.getFluidTypeHeight(FluidTypes.IRIDESCENCE_TYPE.get());
114
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
24
-
forge_version = 1.20.1-47.4.0
24
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