generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8df6179
commit ce3c431
Showing
18 changed files
with
211 additions
and
113 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
src/generated/resources/.cache/95583de0eb8d8e3516fdd3206575fd55adfcdb08
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
64 changes: 63 additions & 1 deletion
64
src/main/java/com/leclowndu93150/carbort/CarbortClient.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 |
---|---|---|
@@ -1,21 +1,83 @@ | ||
package com.leclowndu93150.carbort; | ||
|
||
import com.leclowndu93150.carbort.client.models.BedrockDrillHeadModel; | ||
import com.leclowndu93150.carbort.client.renderer.blockentities.BedrockDrillBER; | ||
import com.leclowndu93150.carbort.content.screen.ChunkAnalyzerScreen; | ||
import com.leclowndu93150.carbort.registries.CBBlockEntities; | ||
import com.leclowndu93150.carbort.registries.CBDataComponents; | ||
import com.leclowndu93150.carbort.registries.CBItems; | ||
import com.leclowndu93150.carbort.registries.CBMenus; | ||
import net.minecraft.client.model.HumanoidModel; | ||
import net.minecraft.client.resources.model.ModelResourceLocation; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.FastColor; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.neoforge.client.event.EntityRenderersEvent; | ||
import net.neoforged.neoforge.client.event.ModelEvent; | ||
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent; | ||
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; | ||
import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions; | ||
import net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@Mod(value = CarbortClient.MODID, dist = Dist.CLIENT) | ||
public class CarbortClient { | ||
public final class CarbortClient { | ||
public static final String MODID = "carbort"; | ||
|
||
public CarbortClient(IEventBus modEventBus) { | ||
modEventBus.addListener(this::registerBakedModels); | ||
modEventBus.addListener(this::registerBERs); | ||
modEventBus.addListener(this::registerMenuScreens); | ||
modEventBus.addListener(this::registerColorHandlers); | ||
modEventBus.addListener(this::registerClientExtensions); | ||
modEventBus.addListener(this::registerModels); | ||
} | ||
|
||
private void registerBERs(EntityRenderersEvent.RegisterRenderers event) { | ||
event.registerBlockEntityRenderer(CBBlockEntities.BEDROCK_DRILL.get(), BedrockDrillBER::new); | ||
} | ||
|
||
private void registerMenuScreens(RegisterMenuScreensEvent event) { | ||
event.register(CBMenus.CHUNK_ANALYZER_MENU.get(), ChunkAnalyzerScreen::new); | ||
} | ||
|
||
private void registerColorHandlers(RegisterColorHandlersEvent.Item event) { | ||
event.register((stack, tintIndex) -> { | ||
if (stack.has(CBDataComponents.TIMER)) { | ||
int remainingTime = stack.getOrDefault(CBDataComponents.TIMER, 0); | ||
int maxTime = 100; | ||
|
||
float progress = Math.max(0, Math.min(1, (float) remainingTime / maxTime)); | ||
|
||
int red = 255; | ||
int green = (int) (255 * progress); | ||
int blue = (int) (255 * progress); | ||
|
||
return FastColor.ARGB32.opaque((red << 16) | (green << 8) | blue); | ||
} | ||
return FastColor.ARGB32.opaque(0xFFFFFF); | ||
}, CBItems.UNSTABLE_INGOT); | ||
} | ||
|
||
private void registerClientExtensions(RegisterClientExtensionsEvent event) { | ||
event.registerItem(new IClientItemExtensions() { | ||
@Override | ||
public HumanoidModel.@NotNull ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack itemStack) { | ||
return HumanoidModel.ArmPose.CROSSBOW_CHARGE; | ||
} | ||
}, CBItems.IRON_GREAT_SWORD); | ||
} | ||
|
||
private void registerBakedModels(ModelEvent.RegisterAdditional event) { | ||
event.register(ModelResourceLocation.standalone(ResourceLocation.fromNamespaceAndPath(MODID, "block/bedrock_drill_head"))); | ||
} | ||
|
||
private void registerModels(EntityRenderersEvent.RegisterLayerDefinitions event) { | ||
event.registerLayerDefinition(BedrockDrillHeadModel.LAYER_LOCATION, BedrockDrillHeadModel::createBodyLayer); | ||
} | ||
} |
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
70 changes: 45 additions & 25 deletions
70
src/main/java/com/leclowndu93150/carbort/client/models/BedrockDrillHeadModel.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 |
---|---|---|
@@ -1,30 +1,50 @@ | ||
package com.leclowndu93150.carbort.client.models; | ||
|
||
import com.leclowndu93150.carbort.Carbort; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import net.minecraft.client.model.Model; | ||
import net.minecraft.client.model.geom.ModelLayerLocation; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import net.minecraft.client.model.geom.PartPose; | ||
import net.minecraft.client.model.geom.builders.*; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.resources.model.Material; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.inventory.InventoryMenu; | ||
|
||
public class BedrockDrillHeadModel {}// extends Model { | ||
// public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("modid", "custommodel"), "main"); | ||
// private final ModelPart drill_head; | ||
// | ||
// public BedrockDrillHeadModel(ModelPart root) { | ||
// this.drill_head = root.getChild("drill_head"); | ||
// } | ||
// | ||
// public static LayerDefinition createBodyLayer() { | ||
// MeshDefinition meshdefinition = new MeshDefinition(); | ||
// PartDefinition partdefinition = meshdefinition.getRoot(); | ||
// | ||
// PartDefinition drill_head = partdefinition.addOrReplaceChild("drill_head", CubeListBuilder.create().texOffs(0, 0).addBox(-2.0F, -14.0F, -2.0F, 4.0F, 20.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 16.0F, 0.0F)); | ||
// | ||
// PartDefinition cube_r1 = drill_head.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(16, 14).addBox(-2.0F, 2.0F, -1.0F, 4.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 1.0503F, 5.5355F, -0.7854F, 0.0F, 0.0F)); | ||
// | ||
// PartDefinition cube_r2 = drill_head.addOrReplaceChild("cube_r2", CubeListBuilder.create().texOffs(16, 6).addBox(-1.0F, 2.0F, -2.0F, 2.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-5.5355F, 1.0503F, 0.0F, 0.0F, 0.0F, -0.7854F)); | ||
// | ||
// PartDefinition cube_r3 = drill_head.addOrReplaceChild("cube_r3", CubeListBuilder.create().texOffs(0, 24).addBox(-1.0F, 2.0F, -2.0F, 2.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(5.5355F, 1.0503F, 0.0F, 0.0F, 0.0F, 0.7854F)); | ||
// | ||
// PartDefinition cube_r4 = drill_head.addOrReplaceChild("cube_r4", CubeListBuilder.create().texOffs(16, 0).addBox(-2.0F, -1.0F, 2.0F, 4.0F, 2.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 1.0503F, -5.5355F, -0.7854F, 0.0F, 0.0F)); | ||
// | ||
// return LayerDefinition.create(meshdefinition, 32, 32); | ||
// } | ||
//} | ||
public class BedrockDrillHeadModel extends Model { | ||
public static final Material CRUCIBLE_LOCATION = new Material( | ||
InventoryMenu.BLOCK_ATLAS, ResourceLocation.fromNamespaceAndPath(Carbort.MODID, "entity/bedrock_drill_head") | ||
); | ||
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(Carbort.MODID, "bedrock_drill_head"), "main"); | ||
private final ModelPart drill_head; | ||
|
||
public BedrockDrillHeadModel(ModelPart root) { | ||
super(RenderType::entitySolid); | ||
this.drill_head = root.getChild("drill_head"); | ||
} | ||
|
||
public static LayerDefinition createBodyLayer() { | ||
MeshDefinition meshdefinition = new MeshDefinition(); | ||
PartDefinition partdefinition = meshdefinition.getRoot(); | ||
|
||
PartDefinition drill_head = partdefinition.addOrReplaceChild("drill_head", CubeListBuilder.create().texOffs(0, 0).addBox(-2.0F, -14.0F, -2.0F, 4.0F, 20.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 16.0F, 0.0F)); | ||
|
||
PartDefinition cube_r1 = drill_head.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(16, 14).addBox(-2.0F, 2.0F, -1.0F, 4.0F, 4.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 1.0503F, 5.5355F, -0.7854F, 0.0F, 0.0F)); | ||
|
||
PartDefinition cube_r2 = drill_head.addOrReplaceChild("cube_r2", CubeListBuilder.create().texOffs(16, 6).addBox(-1.0F, 2.0F, -2.0F, 2.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-5.5355F, 1.0503F, 0.0F, 0.0F, 0.0F, -0.7854F)); | ||
|
||
PartDefinition cube_r3 = drill_head.addOrReplaceChild("cube_r3", CubeListBuilder.create().texOffs(0, 24).addBox(-1.0F, 2.0F, -2.0F, 2.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(5.5355F, 1.0503F, 0.0F, 0.0F, 0.0F, 0.7854F)); | ||
|
||
PartDefinition cube_r4 = drill_head.addOrReplaceChild("cube_r4", CubeListBuilder.create().texOffs(16, 0).addBox(-2.0F, -1.0F, 2.0F, 4.0F, 2.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 1.0503F, -5.5355F, -0.7854F, 0.0F, 0.0F)); | ||
|
||
return LayerDefinition.create(meshdefinition, 32, 32); | ||
} | ||
|
||
@Override | ||
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, int color) { | ||
drill_head.y = 0; | ||
drill_head.render(poseStack, buffer, packedLight, packedOverlay); | ||
} | ||
} |
25 changes: 8 additions & 17 deletions
25
src/main/java/com/leclowndu93150/carbort/client/renderer/blockentities/BedrockDrillBER.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
22 changes: 21 additions & 1 deletion
22
src/main/java/com/leclowndu93150/carbort/content/blockentities/BedrockDrillBE.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
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
35 changes: 0 additions & 35 deletions
35
src/main/java/com/leclowndu93150/carbort/events/CarbortClientEvents.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.