forked from MinecraftForge/MinecraftForge
-
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.
Allow faces of an "elements" model to have disabled ambient occlusion (…
- Loading branch information
Showing
25 changed files
with
341 additions
and
11 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
32 changes: 32 additions & 0 deletions
32
patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch
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,32 @@ | ||
--- a/net/minecraft/client/renderer/block/model/BakedQuad.java | ||
+++ b/net/minecraft/client/renderer/block/model/BakedQuad.java | ||
@@ -12,13 +_,19 @@ | ||
protected final Direction f_111294_; | ||
protected final TextureAtlasSprite f_111295_; | ||
private final boolean f_111296_; | ||
+ private final boolean hasAmbientOcclusion; | ||
|
||
public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_) { | ||
+ this(p_111298_, p_111299_, p_111300_, p_111301_, p_111302_, true); | ||
+ } | ||
+ | ||
+ public BakedQuad(int[] p_111298_, int p_111299_, Direction p_111300_, TextureAtlasSprite p_111301_, boolean p_111302_, boolean hasAmbientOcclusion) { | ||
this.f_111292_ = p_111298_; | ||
this.f_111293_ = p_111299_; | ||
this.f_111294_ = p_111300_; | ||
this.f_111295_ = p_111301_; | ||
this.f_111296_ = p_111302_; | ||
+ this.hasAmbientOcclusion = hasAmbientOcclusion; | ||
} | ||
|
||
public TextureAtlasSprite m_173410_() { | ||
@@ -43,5 +_,9 @@ | ||
|
||
public boolean m_111307_() { | ||
return this.f_111296_; | ||
+ } | ||
+ | ||
+ public boolean hasAmbientOcclusion() { | ||
+ return this.hasAmbientOcclusion; | ||
} | ||
} |
15 changes: 11 additions & 4 deletions
15
patches/minecraft/net/minecraft/client/renderer/block/model/BlockElementFace.java.patch
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,33 +1,40 @@ | ||
--- a/net/minecraft/client/renderer/block/model/BlockElementFace.java | ||
+++ b/net/minecraft/client/renderer/block/model/BlockElementFace.java | ||
@@ -19,12 +_,18 @@ | ||
@@ -19,12 +_,24 @@ | ||
public final int f_111355_; | ||
public final String f_111356_; | ||
public final BlockFaceUV f_111357_; | ||
+ public final int emissivity; | ||
+ public final boolean hasAmbientOcclusion; | ||
|
||
public BlockElementFace(@Nullable Direction p_111359_, int p_111360_, String p_111361_, BlockFaceUV p_111362_) { | ||
+ this(p_111359_, p_111360_, p_111361_, p_111362_, 0); | ||
+ this(p_111359_, p_111360_, p_111361_, p_111362_, 0, true); | ||
+ } | ||
+ | ||
+ public BlockElementFace(@Nullable Direction p_111359_, int p_111360_, String p_111361_, BlockFaceUV p_111362_, int emissivity) { | ||
+ this(p_111359_, p_111360_, p_111361_, p_111362_, emissivity, true); | ||
+ } | ||
+ | ||
+ public BlockElementFace(@Nullable Direction p_111359_, int p_111360_, String p_111361_, BlockFaceUV p_111362_, int emissivity, boolean hasAmbientOcclusion) { | ||
this.f_111354_ = p_111359_; | ||
this.f_111355_ = p_111360_; | ||
this.f_111356_ = p_111361_; | ||
this.f_111357_ = p_111362_; | ||
+ this.emissivity = emissivity; | ||
+ this.hasAmbientOcclusion = hasAmbientOcclusion; | ||
} | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
@@ -37,7 +_,10 @@ | ||
@@ -37,7 +_,11 @@ | ||
int i = this.m_111368_(jsonobject); | ||
String s = this.m_111370_(jsonobject); | ||
BlockFaceUV blockfaceuv = p_111367_.deserialize(jsonobject, BlockFaceUV.class); | ||
- return new BlockElementFace(direction, i, s, blockfaceuv); | ||
+ int emissivity = GsonHelper.m_13824_(jsonobject, "emissivity", 0); | ||
+ if (emissivity != net.minecraft.util.Mth.m_14045_(emissivity, 0, 15)) | ||
+ throw new JsonParseException("The emissivity value must be between 0 and 15. Found: " + emissivity); | ||
+ return new BlockElementFace(direction, i, s, blockfaceuv, emissivity); | ||
+ boolean hasAmbientOcclusion = GsonHelper.m_13855_(jsonobject, "ambientocclusion", true); | ||
+ return new BlockElementFace(direction, i, s, blockfaceuv, emissivity, hasAmbientOcclusion); | ||
} | ||
|
||
protected int m_111368_(JsonObject p_111369_) { |
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
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
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
46 changes: 46 additions & 0 deletions
46
src/test/java/net/minecraftforge/debug/client/AmbientOcclusionElementsTest.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,46 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.minecraftforge.debug.client; | ||
|
||
import net.minecraft.world.item.BlockItem; | ||
import net.minecraft.world.item.CreativeModeTab; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
import net.minecraft.world.level.material.Material; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
import net.minecraftforge.registries.DeferredRegister; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import net.minecraftforge.registries.RegistryObject; | ||
|
||
/** | ||
* Test mod that demos disabling ambient occlusion on specific faces of "elements" models. | ||
*/ | ||
@Mod(AmbientOcclusionElementsTest.MOD_ID) | ||
public class AmbientOcclusionElementsTest | ||
{ | ||
public static final String MOD_ID = "ambient_occlusion_elements_test"; | ||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID); | ||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID); | ||
|
||
public static final RegistryObject<Block> AO_BLOCK_SHADE = BLOCKS.register("ambient_occlusion_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); | ||
public static final RegistryObject<Block> AO_BLOCK_NO_SHADE = BLOCKS.register("ambient_occlusion_no_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); | ||
public static final RegistryObject<Block> NO_AO_BLOCK_SHADE = BLOCKS.register("no_ambient_occlusion_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); | ||
public static final RegistryObject<Block> NO_AO_BLOCK_NO_SHADE = BLOCKS.register("no_ambient_occlusion_no_shade", () -> new Block(BlockBehaviour.Properties.of(Material.STONE))); | ||
public static final RegistryObject<Item> AO_BLOCK_SHADE_ITEM = ITEMS.register("ambient_occlusion_shade", () -> new BlockItem(AO_BLOCK_SHADE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); | ||
public static final RegistryObject<Item> AO_BLOCK_NO_SHADE_ITEM = ITEMS.register("ambient_occlusion_no_shade", () -> new BlockItem(AO_BLOCK_NO_SHADE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); | ||
public static final RegistryObject<Item> NO_AO_BLOCK_SHADE_ITEM = ITEMS.register("no_ambient_occlusion_shade", () -> new BlockItem(NO_AO_BLOCK_SHADE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); | ||
public static final RegistryObject<Item> NO_AO_BLOCK_NO_SHADE_ITEM = ITEMS.register("no_ambient_occlusion_no_shade", () -> new BlockItem(NO_AO_BLOCK_NO_SHADE.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS))); | ||
|
||
public AmbientOcclusionElementsTest() | ||
{ | ||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); | ||
BLOCKS.register(modEventBus); | ||
ITEMS.register(modEventBus); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
...ources/assets/ambient_occlusion_elements_test/blockstates/ambient_occlusion_no_shade.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 @@ | ||
{ | ||
"variants": { | ||
"": { "model": "ambient_occlusion_elements_test:block/ambient_occlusion_no_shade" } | ||
} | ||
} |
Oops, something went wrong.