-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'architectury-1.18.1' into architectury-1.18.2
# Conflicts: # common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMBlockstateModelProvider.java
- Loading branch information
Showing
16 changed files
with
250 additions
and
20 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
74 changes: 74 additions & 0 deletions
74
common/src/main/java/com/unlikepaladin/pfm/blocks/models/ladder/UnbakedLadderModel.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,74 @@ | ||
package com.unlikepaladin.pfm.blocks.models.ladder; | ||
|
||
import com.mojang.datafixers.util.Pair; | ||
import com.unlikepaladin.pfm.PaladinFurnitureMod; | ||
import com.unlikepaladin.pfm.data.materials.StoneVariant; | ||
import com.unlikepaladin.pfm.data.materials.WoodVariant; | ||
import com.unlikepaladin.pfm.data.materials.WoodVariantRegistry; | ||
import dev.architectury.injectables.annotations.ExpectPlatform; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.render.model.ModelBakeSettings; | ||
import net.minecraft.client.render.model.ModelLoader; | ||
import net.minecraft.client.render.model.UnbakedModel; | ||
import net.minecraft.client.texture.Sprite; | ||
import net.minecraft.client.util.SpriteIdentifier; | ||
import net.minecraft.util.Identifier; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.*; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.function.Function; | ||
|
||
public class UnbakedLadderModel implements UnbakedModel { | ||
public static final Identifier[] LADDER_PARTS_BASE = new Identifier[] { | ||
new Identifier(PaladinFurnitureMod.MOD_ID, "block/simple_bunk_ladder/simple_ladder"), | ||
new Identifier(PaladinFurnitureMod.MOD_ID, "block/simple_bunk_ladder/simple_ladder_top") | ||
}; | ||
|
||
public static final Identifier LADDER_MODEL_ID = new Identifier(PaladinFurnitureMod.MOD_ID, "block/simple_bunk_ladder"); | ||
public static final List<Identifier> LADDER_MODEL_IDS = new ArrayList<>() { | ||
{ | ||
for(WoodVariant variant : WoodVariantRegistry.getVariants()){ | ||
|
||
add(new Identifier(PaladinFurnitureMod.MOD_ID, "item/" + variant.asString() + "_simple_bunk_ladder")); | ||
if (variant.hasStripped()) | ||
add(new Identifier(PaladinFurnitureMod.MOD_ID, "item/stripped_" + variant.asString() + "_simple_bunk_ladder")); | ||
} | ||
for(StoneVariant variant : StoneVariant.values()){ | ||
|
||
add(new Identifier(PaladinFurnitureMod.MOD_ID, "item/" + variant.asString() + "_simple_bunk_ladder")); | ||
} | ||
add(LADDER_MODEL_ID); | ||
} | ||
}; | ||
|
||
private static final Identifier PARENT = new Identifier("block/block"); | ||
public Collection<Identifier> getModelDependencies() { | ||
return List.of(PARENT); | ||
} | ||
|
||
@Override | ||
public Collection<SpriteIdentifier> getTextureDependencies(Function<Identifier, UnbakedModel> unbakedModelGetter, Set<Pair<String, String>> unresolvedTextureReferences) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
public static final Map<ModelBakeSettings, List<BakedModel>> CACHED_MODELS = new ConcurrentHashMap<>(); | ||
@Nullable | ||
@Override | ||
public BakedModel bake(ModelLoader loader, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) { | ||
if (CACHED_MODELS.containsKey(rotationContainer)) | ||
return getBakedModel(rotationContainer, CACHED_MODELS.get(rotationContainer)); | ||
|
||
List<BakedModel> bakedModelList = new ArrayList<>(); | ||
for (Identifier modelPart : LADDER_PARTS_BASE) { | ||
bakedModelList.add(loader.bake(modelPart, rotationContainer)); | ||
} | ||
CACHED_MODELS.put(rotationContainer, bakedModelList); | ||
return getBakedModel(rotationContainer, bakedModelList); | ||
} | ||
|
||
@ExpectPlatform | ||
public static BakedModel getBakedModel(ModelBakeSettings settings, List<BakedModel> modelParts) { | ||
throw new RuntimeException("Method wasn't replaced correctly"); | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...e_bunk_ladder/template/simple_ladder.json → ...ock/simple_bunk_ladder/simple_ladder.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
4 changes: 2 additions & 2 deletions
4
...nk_ladder/template/simple_ladder_top.json → ...simple_bunk_ladder/simple_ladder_top.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
52 changes: 52 additions & 0 deletions
52
...ic/src/main/java/com/unlikepaladin/pfm/blocks/models/ladder/fabric/FabricLadderModel.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,52 @@ | ||
package com.unlikepaladin.pfm.blocks.models.ladder.fabric; | ||
|
||
import com.unlikepaladin.pfm.blocks.SimpleBunkLadderBlock; | ||
import com.unlikepaladin.pfm.blocks.models.fabric.PFMFabricBakedModel; | ||
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; | ||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.render.model.ModelBakeSettings; | ||
import net.minecraft.client.texture.Sprite; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.BlockRenderView; | ||
|
||
import java.util.List; | ||
import java.util.Random; | ||
import java.util.function.Supplier; | ||
|
||
public class FabricLadderModel extends PFMFabricBakedModel { | ||
public FabricLadderModel(ModelBakeSettings settings, List<BakedModel> bakedModels) { | ||
super(settings, bakedModels); | ||
} | ||
|
||
@Override | ||
public Sprite pfm$getParticle(BlockState state) { | ||
return getSpriteList(state).get(0); | ||
} | ||
|
||
@Override | ||
public boolean isVanillaAdapter() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) { | ||
if (state != null && state.getBlock() instanceof SimpleBunkLadderBlock) { | ||
Sprite sprite = getSpriteList(state).get(0); | ||
pushTextureTransform(context, sprite); | ||
int offset = state.get(SimpleBunkLadderBlock.UP) ? 1 : 0; | ||
((FabricBakedModel)getTemplateBakedModels().get(offset)).emitBlockQuads(blockView, state, pos, randomSupplier, context); | ||
context.popTransform(); | ||
} | ||
} | ||
|
||
@Override | ||
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) { | ||
Sprite sprite = getSpriteList(stack).get(0); | ||
pushTextureTransform(context, sprite); | ||
((FabricBakedModel)getTemplateBakedModels().get(0)).emitItemQuads(stack, randomSupplier, context); | ||
context.popTransform(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...c/main/java/com/unlikepaladin/pfm/blocks/models/ladder/fabric/UnbakedLadderModelImpl.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,12 @@ | ||
package com.unlikepaladin.pfm.blocks.models.ladder.fabric; | ||
|
||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.render.model.ModelBakeSettings; | ||
|
||
import java.util.List; | ||
|
||
public class UnbakedLadderModelImpl { | ||
public static BakedModel getBakedModel(ModelBakeSettings settings, List<BakedModel> modelParts) { | ||
return new FabricLadderModel(settings, modelParts); | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
forge/src/main/java/com/unlikepaladin/pfm/blocks/models/ladder/forge/ForgeLadderModel.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,51 @@ | ||
package com.unlikepaladin.pfm.blocks.models.ladder.forge; | ||
|
||
import com.unlikepaladin.pfm.blocks.SimpleBunkLadderBlock; | ||
import com.unlikepaladin.pfm.blocks.models.forge.PFMForgeBakedModel; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.render.model.BakedQuad; | ||
import net.minecraft.client.render.model.ModelBakeSettings; | ||
import net.minecraft.client.texture.Sprite; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.BlockRenderView; | ||
import net.minecraftforge.client.model.data.IModelData; | ||
import net.minecraftforge.client.model.data.ModelDataMap; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
public class ForgeLadderModel extends PFMForgeBakedModel { | ||
|
||
public ForgeLadderModel(ModelBakeSettings settings, List<BakedModel> templateBakedModels) { | ||
super(settings, templateBakedModels); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull Random rand, @NotNull IModelData extraData) { | ||
if (state != null && state.getBlock() instanceof SimpleBunkLadderBlock) { | ||
int offset = state.get(SimpleBunkLadderBlock.UP) ? 1 : 0; | ||
Sprite sprite = getSpriteList(state).get(0); | ||
return getQuadsWithTexture(getTemplateBakedModels().get(offset).getQuads(state, side, rand, extraData), sprite); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public @NotNull IModelData getModelData(@NotNull BlockRenderView world, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull IModelData tileData) { | ||
return super.getModelData(world, pos, state, new ModelDataMap.Builder().build()); | ||
} | ||
|
||
@Override | ||
public List<BakedQuad> getQuads(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random) { | ||
Sprite sprite = getSpriteList(stack).get(0); | ||
return getQuadsWithTexture(getTemplateBakedModels().get(0).getQuads(state, face, random), sprite); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...rc/main/java/com/unlikepaladin/pfm/blocks/models/ladder/forge/UnbakedLadderModelImpl.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,12 @@ | ||
package com.unlikepaladin.pfm.blocks.models.ladder.forge; | ||
|
||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.render.model.ModelBakeSettings; | ||
|
||
import java.util.List; | ||
|
||
public class UnbakedLadderModelImpl { | ||
public static BakedModel getBakedModel(ModelBakeSettings settings, List<BakedModel> modelParts) { | ||
return new ForgeLadderModel(settings, modelParts); | ||
} | ||
} |
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