Skip to content

Commit

Permalink
move to mojmap
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Dec 30, 2023
1 parent 862d739 commit 97e7958
Show file tree
Hide file tree
Showing 37 changed files with 1,316 additions and 1,294 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ repositories {

dependencies {
minecraft libs.minecraft
mappings variantOf(libs.quilt.mappings) { classifier "intermediary-v2" }
mappings(loom.layered {
it.mappings variantOf(libs.quilt.mappings) { classifier 'intermediary-v2' }
it.parchment("${libs.parchment.mappings.get()}@zip")
it.officialMojangMappings { nameSyntheticMembers = false }
})

modImplementation libs.quilt.loader
modImplementation libs.quilted.fabric.api
Expand Down
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ quilt_mappings = "1.20.1+build.23"
quilt_loader = "0.22.0"

quilted_fabric_api = "7.4.0+0.90.0-1.20.1"

# The latest versions are available at https://parchmentmc.org/docs/getting-started
parchment = "2023.09.03"

midnightlib = "1.4.1-quilt"
modmenu = "7.2.2"
lazydfu = "0.1.3"
Expand All @@ -23,6 +27,7 @@ fabric-permissions-api = "0.2-SNAPSHOT"
[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
quilt_mappings = { module = "org.quiltmc:quilt-mappings", version.ref = "quilt_mappings" }
parchment_mappings = { module = "org.parchmentmc.data:parchment-1.20.1", version.ref = "parchment" }
quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" }

quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import dev.cammiescorner.camsbackpacks.core.registry.ModBlocks;
import dev.cammiescorner.camsbackpacks.core.registry.ModScreenHandlers;
import eu.midnightdust.lib.config.MidnightConfig;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.loader.api.QuiltLoader;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.networking.api.ServerPlayNetworking;

public class CamsBackpacks implements ModInitializer {

public static final String MOD_ID = "camsbackpacks";

@Override
Expand All @@ -34,7 +35,7 @@ public void onInitialize(ModContainer mod) {
UniversalGravesCompat.load();
}

public static Identifier id(String path) {
return new Identifier(MOD_ID, path);
public static ResourceLocation id(String path) {
return new ResourceLocation(MOD_ID, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,32 @@
import dev.cammiescorner.camsbackpacks.core.util.BackpackHelper;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;
import org.quiltmc.qsl.block.extensions.api.client.BlockRenderLayerMap;

import static dev.cammiescorner.camsbackpacks.core.registry.ModBlocks.*;

public class CamsBackpacksClient implements ClientModInitializer {
public static final EntityModelLayer BACKPACK = new EntityModelLayer(CamsBackpacks.id("backpack"), "main");
public static boolean backpackScreenIsOpen = true;
public static final ModelLayerLocation BACKPACK = new ModelLayerLocation(CamsBackpacks.id("backpack"), "main");
public static boolean backpackScreenIsOpen = true;

@Override
public void onInitializeClient(ModContainer mod) {
//-----Screen Registry-----//
HandledScreens.register(ModScreenHandlers.BACKPACK_SCREEN_HANDLER, BackpackScreen::new);
@Override
public void onInitializeClient(ModContainer mod) {
MenuScreens.register(ModScreenHandlers.BACKPACK_SCREEN_HANDLER, BackpackScreen::new);

//-----Entity Model Layers Registry-----//
EntityModelLayerRegistry.registerModelLayer(BACKPACK, BackpackModel::getTexturedModelData);
EntityModelLayerRegistry.registerModelLayer(BACKPACK, BackpackModel::getTexturedModelData);

//-----Colour Registry-----//
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> BackpackHelper.dyeToDecimal(((BackpackBlock) state.getBlock()).getColour()),
WHITE_BACKPACK, ORANGE_BACKPACK, MAGENTA_BACKPACK, LIGHT_BLUE_BACKPACK, YELLOW_BACKPACK, LIME_BACKPACK, PINK_BACKPACK,
GRAY_BACKPACK, LIGHT_GRAY_BACKPACK, CYAN_BACKPACK, PURPLE_BACKPACK, BLUE_BACKPACK, BROWN_BACKPACK, GREEN_BACKPACK,
RED_BACKPACK, BLACK_BACKPACK);
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> BackpackHelper.dyeToDecimal(((BackpackItem) stack.getItem()).getColour()),
WHITE_BACKPACK.asItem(), ORANGE_BACKPACK.asItem(), MAGENTA_BACKPACK.asItem(), LIGHT_BLUE_BACKPACK.asItem(),
YELLOW_BACKPACK.asItem(), LIME_BACKPACK.asItem(), PINK_BACKPACK.asItem(), GRAY_BACKPACK.asItem(),
LIGHT_GRAY_BACKPACK.asItem(), CYAN_BACKPACK.asItem(), PURPLE_BACKPACK.asItem(), BLUE_BACKPACK.asItem(),
BROWN_BACKPACK.asItem(), GREEN_BACKPACK.asItem(), RED_BACKPACK.asItem(), BLACK_BACKPACK);
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> BackpackHelper.dyeToDecimal(((BackpackBlock) state.getBlock()).getColour()), BuiltInRegistries.BLOCK.stream().filter(block -> block instanceof BackpackBlock backpack && (backpack.getColour() != DyeColor.WHITE || backpack == WHITE_BACKPACK)).toArray(Block[]::new));
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> BackpackHelper.dyeToDecimal(((BackpackItem) stack.getItem()).getColour()), BuiltInRegistries.ITEM.stream().filter(item -> item instanceof BackpackItem backpack && (backpack.getColour() != DyeColor.WHITE || backpack == WHITE_BACKPACK.asItem())).toArray(Item[]::new));

//-----Block Layers Registry-----//
BlockRenderLayerMap.put(RenderLayer.getCutout(), WHITE_BACKPACK, ORANGE_BACKPACK, MAGENTA_BACKPACK,
LIGHT_BLUE_BACKPACK, YELLOW_BACKPACK, LIME_BACKPACK, PINK_BACKPACK, GRAY_BACKPACK, LIGHT_GRAY_BACKPACK, CYAN_BACKPACK,
PURPLE_BACKPACK, BLUE_BACKPACK, BROWN_BACKPACK, GREEN_BACKPACK, RED_BACKPACK, BLACK_BACKPACK, GAY_BACKPACK,
LESBIAN_BACKPACK, QPOC_BACKPACK, BI_BACKPACK, PAN_BACKPACK, TRANS_BACKPACK, GENDERQUEER_BACKPACK,
GENDERFLUID_BACKPACK, ENBY_BACKPACK, ACE_BACKPACK, DEMI_BACKPACK, ARO_BACKPACK, AGENDER_BACKPACK);
}
BlockRenderLayerMap.put(RenderType.cutout(), BuiltInRegistries.BLOCK.stream().filter(BackpackBlock.class::isInstance).toArray(Block[]::new));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,53 @@
package dev.cammiescorner.camsbackpacks.client.models;

import com.google.common.collect.ImmutableList;
import net.minecraft.client.model.*;
import net.minecraft.client.render.entity.model.AnimalModel;
import net.minecraft.entity.LivingEntity;

public class BackpackModel<T extends LivingEntity> extends AnimalModel<T> {
private final ModelPart root;

public BackpackModel(ModelPart root) {
this.root = root.getChild("root");
}

public static TexturedModelData getTexturedModelData() {
ModelData modelData = new ModelData();
ModelPartData modelPartData = modelData.getRoot();
ModelPartData modelPartData1 = modelPartData.addChild("root", ModelPartBuilder.create(), ModelTransform.pivot(0.0F, 0.0F, 0.0F));
ModelPartData modelPartData2 = modelPartData1.addChild("straps", ModelPartBuilder.create().uv(0, 0).cuboid(-4.5F, -0.3F, -3.0F, 9.0F, 12.0F, 5.0F), ModelTransform.pivot(0.0F, 0.0F, 0.0F));
ModelPartData modelPartData3 = modelPartData2.addChild("backpack", ModelPartBuilder.create().uv(28, 0).cuboid(-4.5F, -3.0F, 2.0F, 9.0F, 16.0F, 6.0F), ModelTransform.pivot(0.0F, 0.0F, 0.0F));
modelPartData3.addChild("pocketRight", ModelPartBuilder.create().uv(0, 17).cuboid(3.5F, 7.0F, 3.0F, 3.0F, 5.0F, 4.0F), ModelTransform.pivot(0.0F, 0.0F, 0.0F));
modelPartData3.addChild("pocketLeft", ModelPartBuilder.create().uv(0, 17).cuboid(-6.5F, 7.0F, 3.0F, 3.0F, 5.0F, 4.0F), ModelTransform.pivot(0.0F, 0.0F, 0.0F));
modelPartData3.addChild("backPocket", ModelPartBuilder.create().uv(14, 20).cuboid(-3.0F, 1.0F, 8.0F, 6.0F, 8.0F, 2.0F), ModelTransform.pivot(0.0F, 0.0F, 0.0F));

return TexturedModelData.of(modelData, 64, 32);
}

@Override
public void setAngles(T entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
if(entity.isInSneakingPose()) {
root.pitch = 0.5F;
root.pivotY = 3.2F;
}
else {
root.pitch = 0.0F;
root.pivotY = 0.0F;
}
}

@Override
protected Iterable<ModelPart> getHeadParts() {
return ImmutableList.of();
}

@Override
protected Iterable<ModelPart> getBodyParts() {
return ImmutableList.of(root);
}
}
import net.minecraft.client.model.AgeableListModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.world.entity.LivingEntity;

public class BackpackModel<T extends LivingEntity> extends AgeableListModel<T> {
private final ModelPart root;

public BackpackModel(ModelPart root) {
this.root = root.getChild("root");
}

public static LayerDefinition getTexturedModelData() {
MeshDefinition modelData = new MeshDefinition();
PartDefinition modelPartData = modelData.getRoot();
PartDefinition modelPartData1 = modelPartData.addOrReplaceChild("root", CubeListBuilder.create(), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition modelPartData2 = modelPartData1.addOrReplaceChild("straps", CubeListBuilder.create().texOffs(0, 0).addBox(-4.5F, -0.3F, -3.0F, 9.0F, 12.0F, 5.0F), PartPose.offset(0.0F, 0.0F, 0.0F));
PartDefinition modelPartData3 = modelPartData2.addOrReplaceChild("backpack", CubeListBuilder.create().texOffs(28, 0).addBox(-4.5F, -3.0F, 2.0F, 9.0F, 16.0F, 6.0F), PartPose.offset(0.0F, 0.0F, 0.0F));
modelPartData3.addOrReplaceChild("pocketRight", CubeListBuilder.create().texOffs(0, 17).addBox(3.5F, 7.0F, 3.0F, 3.0F, 5.0F, 4.0F), PartPose.offset(0.0F, 0.0F, 0.0F));
modelPartData3.addOrReplaceChild("pocketLeft", CubeListBuilder.create().texOffs(0, 17).addBox(-6.5F, 7.0F, 3.0F, 3.0F, 5.0F, 4.0F), PartPose.offset(0.0F, 0.0F, 0.0F));
modelPartData3.addOrReplaceChild("backPocket", CubeListBuilder.create().texOffs(14, 20).addBox(-3.0F, 1.0F, 8.0F, 6.0F, 8.0F, 2.0F), PartPose.offset(0.0F, 0.0F, 0.0F));

return LayerDefinition.create(modelData, 64, 32);
}

@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
if (entity.isCrouching()) {
root.xRot = 0.5F;
root.y = 3.2F;
} else {
root.xRot = 0.0F;
root.y = 0.0F;
}
}

@Override
protected Iterable<ModelPart> headParts() {
return ImmutableList.of();
}

@Override
protected Iterable<ModelPart> bodyParts() {
return ImmutableList.of(root);
}
}
Loading

0 comments on commit 97e7958

Please sign in to comment.