Created
December 2, 2020 03:10
-
-
Save Haven-King/53dca9926d2850ff1c59a416f731a327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dev.hephaestus.shatteredsky; | |
import dev.hephaestus.shatteredsky.client.render.ShatteredSkyProperties; | |
import dev.hephaestus.shatteredsky.fluid.AtmosphereFluid; | |
import dev.hephaestus.shatteredsky.fluid.FluidBlock; | |
import dev.hephaestus.shatteredsky.mixin.client.render.RenderLayersAccessor; | |
import dev.hephaestus.shatteredsky.mixin.client.render.SkyPropertiesAccessor; | |
import net.fabricmc.api.ClientModInitializer; | |
import net.fabricmc.api.EnvType; | |
import net.fabricmc.api.Environment; | |
import net.fabricmc.api.ModInitializer; | |
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; | |
import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder; | |
import net.minecraft.block.AbstractBlock; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.Material; | |
import net.minecraft.block.MaterialColor; | |
import net.minecraft.client.render.RenderLayer; | |
import net.minecraft.fluid.FlowableFluid; | |
import net.minecraft.fluid.Fluid; | |
import net.minecraft.util.Identifier; | |
import net.minecraft.util.registry.Registry; | |
import net.minecraft.util.registry.RegistryKey; | |
import net.minecraft.world.dimension.DimensionType; | |
public class ShatteredSky implements ModInitializer, ClientModInitializer { | |
public static final String MOD_ID = "shatteredsky"; | |
public static final RegistryKey<DimensionType> DIMENSION_TYPE = RegistryKey.of(Registry.DIMENSION_TYPE_KEY, id("dimension_type")); | |
@Override | |
public void onInitialize() { | |
Blocks.init(); | |
Fluids.init(); | |
} | |
@Override | |
@Environment(EnvType.CLIENT) | |
public void onInitializeClient() { | |
SkyPropertiesAccessor.getIdMap().put(id("sky"), new ShatteredSkyProperties()); | |
Blocks.initClient(); | |
Fluids.initClient(); | |
} | |
public static Identifier id(String... path) { | |
return new Identifier(MOD_ID, String.join(".", path)); | |
} | |
public static class Materials { | |
public static final Material ATMOSPHERE = new FabricMaterialBuilder(MaterialColor.LIGHT_BLUE).allowsMovement().lightPassesThrough().notSolid().replaceable().liquid().build(); | |
} | |
public static class Blocks { | |
public static final FluidBlock ATMOSPHERE = register("atmosphere", new FluidBlock(Fluids.ATMOSPHERE, AbstractBlock.Settings.of(Materials.ATMOSPHERE).noCollision().strength(100.0F).dropsNothing())); | |
private static <T extends Block> T register(final String id, final T block) { | |
return Registry.register(Registry.BLOCK, id(id), block); | |
} | |
public static void init() { | |
} | |
public static void initClient() { | |
} | |
} | |
public static class Fluids { | |
public static final FlowableFluid ATMOSPHERE = register("atmosphere", new AtmosphereFluid()); | |
public static void init() { | |
} | |
public static void initClient() { | |
FluidRenderHandlerRegistry.INSTANCE.register(ATMOSPHERE, new AtmosphereFluid.Renderer()); | |
RenderLayersAccessor.getFluids().put(ATMOSPHERE, RenderLayer.getTranslucent()); | |
} | |
private static <T extends Fluid> T register(final String id, final T fluid) { | |
return Registry.register(Registry.FLUID, id(id), fluid); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment