mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-25 02:47:39 +00:00
Merge branch 'mc-1.19.x' into mc-1.20.x
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package dan200.computercraft.client.model;
|
||||
|
||||
import com.mojang.math.Transformation;
|
||||
import dan200.computercraft.client.model.turtle.ModelTransformer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
@@ -12,7 +13,6 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||
import net.minecraftforge.client.model.QuadTransformers;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -20,16 +20,15 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A {@link BakedModel} which applies a transformation matrix to its underlying quads.
|
||||
*
|
||||
* @see ModelTransformer
|
||||
*/
|
||||
public class TransformedBakedModel extends BakedModelWrapper<BakedModel> {
|
||||
private final Transformation transformation;
|
||||
private final boolean invert;
|
||||
private @Nullable TransformedQuads cache;
|
||||
private final ModelTransformer transformation;
|
||||
|
||||
public TransformedBakedModel(BakedModel model, Transformation transformation) {
|
||||
super(model);
|
||||
this.transformation = transformation;
|
||||
invert = transformation.getNormalMatrix().determinant() < 0;
|
||||
this.transformation = new ModelTransformer(transformation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,19 +38,6 @@ public class TransformedBakedModel extends BakedModelWrapper<BakedModel> {
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, ModelData extraData, @Nullable RenderType renderType) {
|
||||
var cache = this.cache;
|
||||
var quads = originalModel.getQuads(state, side, rand, extraData, renderType);
|
||||
if (quads.isEmpty()) return List.of();
|
||||
|
||||
// We do some basic caching here to avoid recomputing every frame. Most turtle models don't have culled faces,
|
||||
// so it's not worth being smarter here.
|
||||
if (cache != null && quads.equals(cache.original())) return cache.transformed();
|
||||
|
||||
var transformed = QuadTransformers.applying(transformation).process(quads);
|
||||
this.cache = new TransformedQuads(quads, transformed);
|
||||
return transformed;
|
||||
}
|
||||
|
||||
private record TransformedQuads(List<BakedQuad> original, List<BakedQuad> transformed) {
|
||||
return transformation.transform(originalModel.getQuads(state, side, rand, extraData, renderType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/orientable",
|
||||
"parent": "computercraft:block/computer_on",
|
||||
"textures": {
|
||||
"front": "computercraft:block/computer_advanced_front_blink",
|
||||
"cursor": "computercraft:block/computer_blink",
|
||||
"front": "computercraft:block/computer_advanced_front",
|
||||
"side": "computercraft:block/computer_advanced_side",
|
||||
"top": "computercraft:block/computer_advanced_top"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/orientable",
|
||||
"parent": "computercraft:block/computer_on",
|
||||
"textures": {
|
||||
"front": "computercraft:block/computer_advanced_front_on",
|
||||
"cursor": "computercraft:block/computer_on",
|
||||
"front": "computercraft:block/computer_advanced_front",
|
||||
"side": "computercraft:block/computer_advanced_side",
|
||||
"top": "computercraft:block/computer_advanced_top"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/orientable",
|
||||
"parent": "computercraft:block/computer_on",
|
||||
"textures": {
|
||||
"front": "computercraft:block/computer_command_front_blink",
|
||||
"cursor": "computercraft:block/computer_blink",
|
||||
"front": "computercraft:block/computer_command_front",
|
||||
"side": "computercraft:block/computer_command_side",
|
||||
"top": "computercraft:block/computer_command_top"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/orientable",
|
||||
"parent": "computercraft:block/computer_on",
|
||||
"textures": {
|
||||
"front": "computercraft:block/computer_command_front_on",
|
||||
"cursor": "computercraft:block/computer_on",
|
||||
"front": "computercraft:block/computer_command_front",
|
||||
"side": "computercraft:block/computer_command_side",
|
||||
"top": "computercraft:block/computer_command_top"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/orientable",
|
||||
"parent": "computercraft:block/computer_on",
|
||||
"textures": {
|
||||
"front": "computercraft:block/computer_normal_front_blink",
|
||||
"cursor": "computercraft:block/computer_blink",
|
||||
"front": "computercraft:block/computer_normal_front",
|
||||
"side": "computercraft:block/computer_normal_side",
|
||||
"top": "computercraft:block/computer_normal_top"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/orientable",
|
||||
"parent": "computercraft:block/computer_on",
|
||||
"textures": {
|
||||
"front": "computercraft:block/computer_normal_front_on",
|
||||
"cursor": "computercraft:block/computer_on",
|
||||
"front": "computercraft:block/computer_normal_front",
|
||||
"side": "computercraft:block/computer_normal_side",
|
||||
"top": "computercraft:block/computer_normal_top"
|
||||
}
|
||||
|
||||
6
projects/forge/src/generated/resources/assets/minecraft/atlases/blocks.json
generated
Normal file
6
projects/forge/src/generated/resources/assets/minecraft/atlases/blocks.json
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sources": [
|
||||
{"type": "minecraft:single", "resource": "computercraft:gui/turtle_upgrade_left"},
|
||||
{"type": "minecraft:single", "resource": "computercraft:gui/turtle_upgrade_right"}
|
||||
]
|
||||
}
|
||||
@@ -4,16 +4,16 @@
|
||||
{
|
||||
"condition": "minecraft:any_of",
|
||||
"terms": [
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/stronghold_library"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/woodland_mansion"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/stronghold_corridor"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/abandoned_mineshaft"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/simple_dungeon"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/village/village_cartographer"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/igloo_chest"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/jungle_temple"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/desert_pyramid"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/stronghold_crossing"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/stronghold_library"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/woodland_mansion"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/stronghold_corridor"},
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/abandoned_mineshaft"}
|
||||
{"condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/stronghold_crossing"}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
package dan200.computercraft.data;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.shared.platform.RegistryWrappers;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
@@ -14,18 +16,24 @@ import net.minecraft.data.models.BlockModelGenerators;
|
||||
import net.minecraft.data.models.ItemModelGenerators;
|
||||
import net.minecraft.data.tags.ItemTagsProvider;
|
||||
import net.minecraft.data.tags.TagsProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.common.data.BlockTagsProvider;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.common.data.JsonCodecProvider;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
@@ -48,6 +56,15 @@ public class Generators {
|
||||
return generator.addProvider(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void addFromCodec(String name, PackType type, String directory, Codec<T> codec, Consumer<BiConsumer<ResourceLocation, T>> output) {
|
||||
generator.addProvider(out -> {
|
||||
Map<ResourceLocation, T> map = new HashMap<>();
|
||||
output.accept(map::put);
|
||||
return new JsonCodecProvider<>(out, existingFiles, ComputerCraftAPI.MOD_ID, JsonOps.INSTANCE, type, directory, codec, map);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lootTable(List<LootTableProvider.SubProviderEntry> tables) {
|
||||
add(out -> new LootTableProvider(out, Set.of(), tables));
|
||||
|
||||
Reference in New Issue
Block a user