mirror of
https://github.com/MinecraftForge/MinecraftForge
synced 2026-08-22 04:26:10 -04:00
Fix base bucket model not being flipped for gasses. Closes #10814
This commit is contained in:
parent
3bbdbacb81
commit
ec73fd5240
7 changed files with 120 additions and 18 deletions
|
|
@ -113,8 +113,10 @@ public class DynamicFluidContainerModel implements UnbakedGeometry {
|
|||
|
||||
// TODO: [Forge][Rendering] See if we can get rid of SimpleModelState and wrap transforms completely
|
||||
// If the fluid is lighter than air, rotate 180deg to turn it upside down
|
||||
if (flipGas && fluid != Fluids.EMPTY && fluid.getFluidType().isLighterThanAir())
|
||||
if (flipGas && fluid != Fluids.EMPTY && fluid.getFluidType().isLighterThanAir()) {
|
||||
transformation = transformation.compose(new Transformation(null, new Quaternionf(0, 0, 1, 0), null, null));
|
||||
state = new SimpleModelState(transformation);
|
||||
}
|
||||
|
||||
var buf = new QuadCollection.Builder();
|
||||
|
||||
|
|
|
|||
|
|
@ -5,17 +5,31 @@
|
|||
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.client.renderer.block.FluidModel;
|
||||
import net.minecraft.client.resources.model.sprite.Material;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraftforge.client.event.ModelEvent.BakeFluidModels;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import net.minecraftforge.common.SoundActions;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.gametest.GameTest;
|
||||
import net.minecraftforge.gametest.GameTestNamespace;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.test.BaseTestMod;
|
||||
|
||||
|
|
@ -24,26 +38,82 @@ import net.minecraftforge.test.BaseTestMod;
|
|||
public class FluidBucketModelTest extends BaseTestMod {
|
||||
public static final String MODID = "fluid_bucket_model";
|
||||
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(Registries.BLOCK, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(Registries.ITEM, MODID);
|
||||
private static final DeferredRegister<Fluid> FLUIDS = DeferredRegister.create(Registries.FLUID, MODID);
|
||||
private static final DeferredRegister<FluidType> FLUID_TYPES = DeferredRegister.create(ForgeRegistries.FLUID_TYPES, MODID);
|
||||
|
||||
|
||||
private static ForgeFlowingFluid.Properties FLUID_PROPERTIES;
|
||||
private static final RegistryObject<ForgeFlowingFluid.Source> GAS_STILL = FLUIDS.register("gas", () -> new ForgeFlowingFluid.Source(FLUID_PROPERTIES));
|
||||
private static final RegistryObject<ForgeFlowingFluid.Flowing> GAS_FLOWING = FLUIDS.register("gas_flowing", () -> new ForgeFlowingFluid.Flowing(FLUID_PROPERTIES));
|
||||
|
||||
private static final FluidType.Properties GAS_PROPERTIES = FluidType.Properties.create()
|
||||
.lightLevel(10)
|
||||
.density(-1600)
|
||||
.viscosity(100)
|
||||
.sound(SoundActions.BUCKET_FILL, SoundEvents.BUCKET_FILL)
|
||||
.sound(SoundActions.BUCKET_EMPTY, SoundEvents.BUCKET_EMPTY)
|
||||
.sound(SoundActions.FLUID_VAPORIZE, SoundEvents.FIRE_EXTINGUISH);
|
||||
|
||||
private static final Identifier GAS_STILL_TEXTURE = rl("minecraft", "block/water_still");
|
||||
private static final Identifier GAS_FLOWING_TEXTURE = rl("minecraft", "block/water_flow");
|
||||
|
||||
public static final RegistryObject<FluidType> GAS_TYPE = FLUID_TYPES.register("gas", () -> {
|
||||
return new FluidType(GAS_PROPERTIES) {
|
||||
@Override
|
||||
public void initializeClient(final Consumer<IClientFluidTypeExtensions> consumer) {
|
||||
consumer.accept(new IClientFluidTypeExtensions() {
|
||||
@Override
|
||||
public Identifier getStillTexture() {
|
||||
return GAS_STILL_TEXTURE;
|
||||
}
|
||||
@Override
|
||||
public Identifier getFlowingTexture() {
|
||||
return GAS_FLOWING_TEXTURE;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
public static final RegistryObject<LiquidBlock> GAS_BLOCK = BLOCKS.register("gas", () -> new LiquidBlock(
|
||||
GAS_STILL,
|
||||
Block.Properties.of()
|
||||
.replaceable()
|
||||
.noCollision()
|
||||
.strength(100)
|
||||
.pushReaction(PushReaction.DESTROY)
|
||||
.noLootTable()
|
||||
.liquid()
|
||||
.sound(SoundType.EMPTY)
|
||||
.setId(BLOCKS.key("gas"))
|
||||
));
|
||||
|
||||
public static final RegistryObject<BucketItem> GAS_BUCKET = ITEMS.register("gas_bucket", () -> new BucketItem(GAS_STILL, new Item.Properties().setId(ITEMS.key("gas_bucket"))));
|
||||
|
||||
static {
|
||||
FLUID_PROPERTIES = new ForgeFlowingFluid.Properties(GAS_TYPE, GAS_STILL, GAS_FLOWING).block(GAS_BLOCK).bucket(GAS_BUCKET);
|
||||
}
|
||||
|
||||
|
||||
public static final RegistryObject<Item> BUCKET = ITEMS.register("bucket", () -> new BucketItem(() -> Fluids.LAVA, new Item.Properties().setId(ITEMS.key("bucket"))));
|
||||
|
||||
public FluidBucketModelTest(FMLJavaModLoadingContext context) {
|
||||
super(context, false, true);
|
||||
this.testItem(lookup -> BUCKET.get().getDefaultInstance());
|
||||
BakeFluidModels.BUS.addListener(this::registerFluidModels);
|
||||
}
|
||||
|
||||
@GameTest
|
||||
public static void item_model(GameTestHelper helper) {
|
||||
var manager = Minecraft.getInstance().getModelManager();
|
||||
|
||||
var key = rl("pig_head");
|
||||
var model = manager.getItemModel(key);
|
||||
if (model == null)
|
||||
helper.fail("Failed to retreive " + key + " item model");
|
||||
|
||||
if (model == manager.getMissingModel())
|
||||
helper.fail("Itme Model was the missing model");
|
||||
|
||||
helper.succeed();
|
||||
private void registerFluidModels(BakeFluidModels event) {
|
||||
var gas_model = new FluidModel.Unbaked(
|
||||
new Material(GAS_STILL_TEXTURE),
|
||||
new Material(GAS_FLOWING_TEXTURE),
|
||||
null,
|
||||
null
|
||||
);
|
||||
var gas_baked = gas_model.bake(event.materials(), () -> "Gas");
|
||||
event.register(GAS_STILL.get(), gas_baked);
|
||||
event.register(GAS_FLOWING.get(), gas_baked);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "fluid_bucket_model:block/gas"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "fluid_bucket_model:item/gas_bucket"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"textures": {
|
||||
"particle": "minecraft:block/water_still"
|
||||
}
|
||||
}
|
||||
|
|
@ -2,5 +2,8 @@
|
|||
"parent": "forge:item/bucket",
|
||||
"flip_gas": true,
|
||||
"fluid": "minecraft:lava",
|
||||
"loader": "forge:fluid_container"
|
||||
"loader": "forge:fluid_container",
|
||||
"textures": {
|
||||
"particle": "minecraft:block/lava_still"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"parent": "forge:item/bucket",
|
||||
"flip_gas": true,
|
||||
"fluid": "fluid_bucket_model:gas",
|
||||
"loader": "forge:fluid_container",
|
||||
"textures": {
|
||||
"particle": "minecraft:block/water_still"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue