generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
378 additions
and
313 deletions.
There are no files selected for viewing
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
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
7 changes: 7 additions & 0 deletions
7
src/generated/resources/assets/examplemod/blockstates/example_fluid.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "examplemod:block/example_fluid" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"block.examplemod.example_block": "Test Example Block", | ||
"fluid_type.examplemod.example_fluid": "Example Fluid", | ||
"block.examplemod.example_fluid": "Example Fluid", | ||
"item.examplemod.example_fluid_bucket": "Example Fluid Bucket", | ||
"item.examplemod.example_item": "Test Example Item", | ||
"itemGroup.examplemod.example_tab": "Example" | ||
} |
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/examplemod/models/block/example_fluid.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/cube_all", | ||
"textures": { | ||
"all": "examplemod:block/example_fluid" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/generated/resources/assets/examplemod/models/item/example_fluid_bucket.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"parent": "neoforge:item/bucket", | ||
"fluid": "examplemod:fluid_example_fluid_source", | ||
"loader": "neoforge:fluid_container" | ||
} |
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
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
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
33 changes: 0 additions & 33 deletions
33
src/main/java/com/enderio/regilite/events/FluidRenderTypeEvents.java
This file was deleted.
Oops, something went wrong.
129 changes: 129 additions & 0 deletions
129
src/main/java/com/enderio/regilite/fluids/FluidTypeBuilder.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright (c) Team Ender IO and contributors | ||
* SPDX-License-Identifier: LGPL-3.0-only | ||
*/ | ||
|
||
package com.enderio.regilite.fluids; | ||
|
||
import com.enderio.regilite.RegiliteBuilder; | ||
import com.enderio.regilite.blocks.BlockBuilder; | ||
import com.enderio.regilite.blocks.RegiliteBlocks; | ||
import com.enderio.regilite.items.ItemBuilder; | ||
import com.enderio.regilite.items.RegiliteItems; | ||
import com.enderio.regilite.lang.RegiliteLang; | ||
import com.enderio.regilite.tags.RegiliteTags; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.BucketItem; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.LiquidBlock; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
import net.minecraft.world.level.material.FlowingFluid; | ||
import net.minecraft.world.level.material.Fluid; | ||
import net.neoforged.neoforge.fluids.BaseFlowingFluid; | ||
import net.neoforged.neoforge.fluids.FluidType; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
import java.util.function.UnaryOperator; | ||
|
||
public class FluidTypeBuilder<T extends FluidType> extends RegiliteBuilder<FluidTypeBuilder<T>, FluidType, T, FluidTypeHolder<T>> { | ||
|
||
private final RegiliteLang langModule; | ||
private final RegiliteTags tagsModule; | ||
private final RegiliteItems itemsModule; | ||
private final RegiliteBlocks blocksModule; | ||
|
||
private BaseFlowingFluid.Properties properties = new BaseFlowingFluid.Properties(holder, holder::sourceFluid, holder::flowingFluid).block(holder::block).bucket(holder::bucket); | ||
|
||
protected Supplier<Supplier<RenderType>> renderTypeSupplier = () -> null; | ||
|
||
protected FluidTypeBuilder(FluidTypeHolder<T> holder, DeferredRegister<Fluid> fluidRegister, RegiliteLang langModule, RegiliteTags tagsModule, RegiliteItems itemsModule, RegiliteBlocks blocksModule) { | ||
super(holder); | ||
this.langModule = langModule; | ||
this.tagsModule = tagsModule; | ||
this.itemsModule = itemsModule; | ||
this.blocksModule = blocksModule; | ||
|
||
// TODO: Make the factories configurable (and add opt-out). | ||
holder.flowingFluidHolder(fluidRegister.register("fluid_" + getId().getPath() + "_flowing", () -> new BaseFlowingFluid.Flowing(properties))); | ||
holder.sourceFluidHolder(fluidRegister.register("fluid_" + getId().getPath() + "_source", () -> new BaseFlowingFluid.Source(properties))); | ||
} | ||
|
||
public FluidTypeBuilder<T> tag(TagKey<Fluid> tag) { | ||
tagsModule.fluids().tag(tag).add(holder::sourceFluid, holder::flowingFluid); | ||
return this; | ||
} | ||
|
||
@SafeVarargs | ||
public final FluidTypeBuilder<T> tags(TagKey<Fluid>... tags) { | ||
tagsModule.fluids().addToTags(holder::sourceFluid, tags); | ||
tagsModule.fluids().addToTags(holder::flowingFluid, tags); | ||
return this; | ||
} | ||
|
||
public FluidTypeBuilder<T> translation(String translation) { | ||
langModule.addFluid(this::get, translation); | ||
return this; | ||
} | ||
|
||
public FluidTypeBuilder<T> properties(UnaryOperator<BaseFlowingFluid.Properties> propertiesOperator) { | ||
properties = propertiesOperator.apply(properties); | ||
return this; | ||
} | ||
|
||
public FluidTypeBuilder<T> bucket() { | ||
return customBucket(f -> new BucketItem(f.get(), new Item.Properties().stacksTo(1)), i -> { | ||
}); | ||
} | ||
|
||
public FluidTypeBuilder<T> bucket(Consumer<ItemBuilder<BucketItem>> itemConfigure) { | ||
return customBucket(f -> new BucketItem(f.get(), new Item.Properties().stacksTo(1)), itemConfigure); | ||
} | ||
|
||
public FluidTypeBuilder<T> bucket(Item.Properties properties) { | ||
return customBucket(f -> new BucketItem(f.get(), properties), i -> { | ||
}); | ||
} | ||
|
||
public <I extends BucketItem> FluidTypeBuilder<T> customBucket(Function<Supplier<? extends FlowingFluid>, I> supplier) { | ||
return customBucket(supplier, i -> { | ||
}); | ||
} | ||
|
||
public <I extends BucketItem> FluidTypeBuilder<T> customBucket(Function<Supplier<? extends FlowingFluid>, I> supplier, Consumer<ItemBuilder<I>> itemConfigure) { | ||
var bucket = itemsModule.create(getId().getPath() + "_bucket", () -> supplier.apply(holder::sourceFluid)); | ||
bucket.modelProvider((prov, ctx) -> prov.bucketItem(ctx.get())); | ||
itemConfigure.accept(bucket); | ||
holder.bucketHolder(bucket.asHolder()); | ||
return this; | ||
} | ||
|
||
public FluidTypeBuilder<T> block(BlockBehaviour.Properties properties) { | ||
return block(f -> new LiquidBlock(f.get(), properties), b -> { | ||
}); | ||
} | ||
|
||
public FluidTypeBuilder<T> block(BlockBehaviour.Properties properties, Consumer<BlockBuilder<LiquidBlock>> blockConfigure) { | ||
return block(f -> new LiquidBlock(f.get(), properties), blockConfigure); | ||
} | ||
|
||
public <B extends LiquidBlock> FluidTypeBuilder<T> block(Function<Supplier<? extends BaseFlowingFluid>, B> supplier) { | ||
return block(supplier, b -> { | ||
}); | ||
} | ||
|
||
public <B extends LiquidBlock> FluidTypeBuilder<T> block(Function<Supplier<? extends BaseFlowingFluid>, B> supplier, Consumer<BlockBuilder<B>> blockConfigure) { | ||
var block = blocksModule.create(getId().getPath(), () -> supplier.apply(holder::flowingFluid)); | ||
blockConfigure.accept(block); | ||
holder.blockHolder(block.asHolder()); | ||
return this; | ||
} | ||
|
||
public FluidTypeBuilder<T> renderType(Supplier<Supplier<RenderType>> renderTypeSupplier) { | ||
this.renderTypeSupplier = renderTypeSupplier; | ||
return this; | ||
} | ||
} |
Oops, something went wrong.