Skip to content

Commit

Permalink
SNALE!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver-makes-code committed May 4, 2024
1 parent 6223322 commit 0004e5b
Show file tree
Hide file tree
Showing 26 changed files with 574 additions and 44 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"replace":false,"values":[{"required":false,"id":"copper_block"},{"required":false,"id":"exposed_copper"},{"required":false,"id":"weathered_copper"},{"required":false,"id":"oxidized_copper"},{"required":false,"id":"waxed_copper_block"},{"required":false,"id":"waxed_exposed_copper"},{"required":false,"id":"waxed_weathered_copper"},{"required":false,"id":"waxed_oxidized_copper"},{"required":false,"id":"cut_copper"},{"required":false,"id":"exposed_cut_copper"},{"required":false,"id":"weathered_cut_copper"},{"required":false,"id":"oxidized_cut_copper"},{"required":false,"id":"waxed_cut_copper"},{"required":false,"id":"waxed_exposed_cut_copper"},{"required":false,"id":"waxed_weathered_cut_copper"},{"required":false,"id":"waxed_oxidized_cut_copper"},{"required":false,"id":"cut_copper_stairs"},{"required":false,"id":"exposed_cut_copper_stairs"},{"required":false,"id":"weathered_cut_copper_stairs"},{"required":false,"id":"oxidized_cut_copper_stairs"},{"required":false,"id":"waxed_cut_copper"},{"required":false,"id":"waxed_exposed_cut_copper_stairs"},{"required":false,"id":"waxed_weathered_cut_copper_stairs"},{"required":false,"id":"waxed_oxidized_cut_copper_stairs"},{"required":false,"id":"cut_copper_slab"},{"required":false,"id":"exposed_cut_copper_slab"},{"required":false,"id":"weathered_cut_copper_slab"},{"required":false,"id":"oxidized_cut_copper_slab"},{"required":false,"id":"waxed_cut_copper_slab"},{"required":false,"id":"waxed_exposed_cut_copper_slab"},{"required":false,"id":"waxed_weathered_cut_copper_slab"},{"required":false,"id":"waxed_oxidized_cut_copper_slab"},{"required":false,"id":"chiseled_copper"},{"required":false,"id":"exposed_chiseled_copper"},{"required":false,"id":"weathered_chiseled_copper"},{"required":false,"id":"oxidized_chiseled_copper"},{"required":false,"id":"waxed_chiseled_copper"},{"required":false,"id":"waxed_exposed_chiseled_copper"},{"required":false,"id":"waxed_weathered_chiseled_copper"},{"required":false,"id":"waxed_oxidized_chiseled_copper"},{"required":false,"id":"copper_grate"},{"required":false,"id":"exposed_copper_grate"},{"required":false,"id":"weathered_copper_grate"},{"required":false,"id":"oxidized_copper_grate"},{"required":false,"id":"waxed_copper_grate"},{"required":false,"id":"waxed_exposed_copper_grate"},{"required":false,"id":"waxed_weathered_copper_grate"},{"required":false,"id":"waxed_oxidized_copper_grate"},{"required":false,"id":"copper_bulb"},{"required":false,"id":"exposed_copper_bulb"},{"required":false,"id":"weathered_copper_bulb"},{"required":false,"id":"oxidized_copper_bulb"},{"required":false,"id":"waxed_copper_bulb"},{"required":false,"id":"waxed_exposed_copper_bulb"},{"required":false,"id":"waxed_weathered_copper_bulb"},{"required":false,"id":"waxed_oxidized_copper_bulb"},{"required":false,"id":"copper_door"},{"required":false,"id":"exposed_copper_door"},{"required":false,"id":"weathered_copper_door"},{"required":false,"id":"oxidized_copper_door"},{"required":false,"id":"waxed_copper_door"},{"required":false,"id":"waxed_exposed_copper_door"},{"required":false,"id":"waxed_weathered_copper_door"},{"required":false,"id":"waxed_oxidized_copper_door"},{"required":false,"id":"copper_trapdoor"},{"required":false,"id":"exposed_copper_trapdoor"},{"required":false,"id":"weathered_copper_trapdoor"},{"required":false,"id":"oxidized_copper_trapdoor"},{"required":false,"id":"waxed_copper_trapdoor"},{"required":false,"id":"waxed_exposed_copper_trapdoor"},{"required":false,"id":"waxed_weathered_copper_trapdoor"},{"required":false,"id":"waxed_oxidized_copper_trapdoor"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"replace":false,"values":[{"required":false,"id":"kelp"}]}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.sweetberry.wwizardry;

import dev.sweetberry.wwizardry.content.ContentInitializer;
import dev.sweetberry.wwizardry.content.block.BlockInitializer;
import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -23,6 +24,8 @@ public static void init(String platform) {
init = true;
WanderingWizardry.LOGGER.info("*tips altar* w'wizardry");
ContentInitializer.init();

BlockInitializer.registerSecondaryBlockFunctions();
}

public static ResourceLocation id(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@

import dev.sweetberry.wwizardry.api.Lazy;
import dev.sweetberry.wwizardry.client.WanderingWizardryClient;
import dev.sweetberry.wwizardry.client.render.model.SnailModel;
import dev.sweetberry.wwizardry.client.render.entity.SnailRenderer;
import dev.sweetberry.wwizardry.client.render.model.AltarCatalyzerModel;
import dev.sweetberry.wwizardry.content.block.BlockInitializer;
import dev.sweetberry.wwizardry.content.block.entity.AltarCatalyzerBlockEntity;
import dev.sweetberry.wwizardry.content.block.entity.AltarPedestalBlockEntity;
import dev.sweetberry.wwizardry.client.render.blockentity.AltarCatalyzerBlockEntityRenderer;
import dev.sweetberry.wwizardry.client.render.blockentity.AltarPedestalBlockEntityRenderer;
import dev.sweetberry.wwizardry.content.block.sign.ModdedSignBlock;
import dev.sweetberry.wwizardry.content.component.BoatComponent;
import dev.sweetberry.wwizardry.content.entity.EntityInitializer;
import dev.sweetberry.wwizardry.content.item.ItemInitializer;
import net.minecraft.client.model.BoatModel;
import net.minecraft.client.model.ChestBoatModel;
import net.minecraft.client.model.geom.LayerDefinitions;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.ChestRenderer;
import net.minecraft.client.renderer.blockentity.HangingSignRenderer;
import net.minecraft.client.renderer.blockentity.SignRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.apache.logging.log4j.util.TriConsumer;

Expand All @@ -42,14 +45,29 @@ public static void registerModelPredicates(TriConsumer<Lazy<Item>, String, Clamp
);
}

public static void registerEntityRenderers(BiConsumer<Lazy<BlockEntityType<?>>, BlockEntityRendererProvider<?>> consumer) {
private static <T extends Entity> EntityRendererProvider<Entity> get(EntityRendererProvider<T> provider) {
return (EntityRendererProvider<Entity>) provider;
}

private static <T extends BlockEntity> BlockEntityRendererProvider<BlockEntity> get(BlockEntityRendererProvider<T> provider) {
return (BlockEntityRendererProvider<BlockEntity>) provider;
}

public static void registerEntityRenderers(BiConsumer<Lazy<EntityType<Entity>>, EntityRendererProvider<Entity>> consumer) {
consumer.accept(
(Lazy<BlockEntityType<?>>)(Object) BlockInitializer.ALTAR_PEDESTAL_TYPE,
(BlockEntityRendererProvider<AltarPedestalBlockEntity>) AltarPedestalBlockEntityRenderer::new
(Lazy<EntityType<Entity>>) (Object) EntityInitializer.SNAIL,
get(SnailRenderer::new)
);
}

public static void registerBlockEntityRenderers(BiConsumer<Lazy<BlockEntityType<BlockEntity>>, BlockEntityRendererProvider<BlockEntity>> consumer) {
consumer.accept(
(Lazy<BlockEntityType<BlockEntity>>)(Object) BlockInitializer.ALTAR_PEDESTAL_TYPE,
get(AltarPedestalBlockEntityRenderer::new)
);
consumer.accept(
(Lazy<BlockEntityType<?>>)(Object) BlockInitializer.ALTAR_CATALYZER_TYPE,
(BlockEntityRendererProvider<AltarCatalyzerBlockEntity>) AltarCatalyzerBlockEntityRenderer::new
(Lazy<BlockEntityType<BlockEntity>>)(Object) BlockInitializer.ALTAR_CATALYZER_TYPE,
get(AltarCatalyzerBlockEntityRenderer::new)
);
}

Expand All @@ -72,5 +90,8 @@ public static void registerModelLayers(BiConsumer<ModelLayerLocation, Supplier<L

var altarModel = AltarCatalyzerModel.createLayer();
consumer.accept(AltarCatalyzerModel.LAYER_LOCATION, () -> altarModel);

var snailModel = SnailModel.createBodyLayer();
consumer.accept(SnailModel.LAYER_LOCATION, () -> snailModel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package dev.sweetberry.wwizardry.client.render.entity;

import com.mojang.blaze3d.vertex.PoseStack;
import dev.sweetberry.wwizardry.WanderingWizardry;
import dev.sweetberry.wwizardry.client.render.model.SnailModel;
import dev.sweetberry.wwizardry.content.entity.Snail;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;

public class SnailRenderer extends MobRenderer<Snail, SnailModel> {
public SnailRenderer(EntityRendererProvider.Context context) {
super(context, new SnailModel(context.bakeLayer(SnailModel.LAYER_LOCATION)), 0.2f);
}

@Override
public ResourceLocation getTextureLocation(Snail snail) {
return WanderingWizardry.id(snail.getVariant().getTextureName());
}

@Override
public void render(Snail snail, float $$1, float $$2, PoseStack stack, MultiBufferSource buffer, int $$5) {
stack.pushPose();
final float scale = 0.6f;
if (snail.isBaby())
stack.scale(scale, scale, scale);

super.render(snail, $$1, $$2, stack, buffer, $$5);
stack.popPose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public static LayerDefinition createLayer() {

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
WanderingWizardry.id(timeToCraft + "");
var seconds = ticks / 20;
seconds %= 4;
poseStack.pushPose();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package dev.sweetberry.wwizardry.client.render.model;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import dev.sweetberry.wwizardry.WanderingWizardry;
import dev.sweetberry.wwizardry.content.entity.Snail;
import net.minecraft.client.model.EntityModel;
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.*;

public class SnailModel extends EntityModel<Snail> {
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(WanderingWizardry.id("snail"), "main");
private final ModelPart body;
private final ModelPart leftEye;
private final ModelPart rightEye;
private final ModelPart shell;

public SnailModel(ModelPart root) {
this.body = root.getChild("Body");
this.leftEye = root.getChild("EyeL");
this.rightEye = root.getChild("EyeR");
this.shell = root.getChild("Shell");
}

public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();

PartDefinition body = partdefinition.addOrReplaceChild("Body", CubeListBuilder.create().texOffs(0, 0).addBox(-1.5F, -1.0F, -3.5F, 3.0F, 1.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F));

PartDefinition leftEye = partdefinition.addOrReplaceChild("EyeL", CubeListBuilder.create().texOffs(0, 0).addBox(-0.5F, -3.0F, -0.5F, 1.0F, 3.0F, 1.0F, new CubeDeformation(0.01F)), PartPose.offsetAndRotation(1.0F, 23.25F, -3.0F, 0.0873F, 0.0F, 0.0873F));

PartDefinition rightEye = partdefinition.addOrReplaceChild("EyeR", CubeListBuilder.create().texOffs(0, 0).addBox(-0.5F, -3.0F, -0.5F, 1.0F, 3.0F, 1.0F, new CubeDeformation(0.01F)), PartPose.offsetAndRotation(-1.0F, 23.25F, -3.0F, 0.0873F, 0.0F, -0.0873F));

PartDefinition shell = partdefinition.addOrReplaceChild("Shell", CubeListBuilder.create().texOffs(0, 8).addBox(-1.5F, -2.0F, -2.0F, 3.0F, 4.0F, 4.0F, new CubeDeformation(0.01F)), PartPose.offsetAndRotation(0.0F, 21.25F, 1.0F, -0.0873F, 0.0F, 0.0F));

PartDefinition shroom = shell.addOrReplaceChild("shroom", CubeListBuilder.create().texOffs(13, 4).addBox(-2.0F, -1.5F, 0.5F, 3.0F, 3.0F, 0.0F, new CubeDeformation(0.0F))
.texOffs(13, 1).addBox(-0.5F, -1.5F, -1.0F, 0.0F, 3.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-0.25F, -3.25F, 1.25F, -0.1309F, -0.7854F, -0.0436F));

return LayerDefinition.create(meshdefinition, 32, 32);
}

@Override
public void setupAnim(Snail entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
body.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
leftEye.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
rightEye.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
shell.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.sweetberry.wwizardry.content.component.ComponentInitializer;
import dev.sweetberry.wwizardry.content.criterion.CriterionInitializer;
import dev.sweetberry.wwizardry.content.datagen.DatagenInitializer;
import dev.sweetberry.wwizardry.content.entity.EntityInitializer;
import dev.sweetberry.wwizardry.content.events.EventInitializer;
import dev.sweetberry.wwizardry.content.item.ItemInitializer;
import dev.sweetberry.wwizardry.content.net.NetworkingInitializer;
Expand All @@ -15,6 +16,7 @@
import net.minecraft.advancements.CriterionTrigger;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.decoration.PaintingVariant;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
Expand Down Expand Up @@ -44,5 +46,6 @@ public static void listenToAll(RegistryCallback<?> listener) {
RecipeInitializer.RECIPES.listen((RegistryCallback<RecipeType<?>>) listener);
WorldgenInitializer.STRUCTURE_PROCESSORS.listen((RegistryCallback<StructureProcessorType<?>>) listener);
SoundInitializer.SOUNDS.listen((RegistryCallback<SoundEvent>) listener);
EntityInitializer.ENTITIES.listen((RegistryCallback<EntityType<?>>) listener);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dev.sweetberry.wwizardry.content.entity;

import dev.sweetberry.wwizardry.WanderingWizardry;
import dev.sweetberry.wwizardry.api.Lazy;
import dev.sweetberry.wwizardry.api.registry.RegistryContext;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.phys.Vec3;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.function.Supplier;

public class EntityInitializer {
public static final RegistryContext<EntityType<?>> ENTITIES = new RegistryContext<>(BuiltInRegistries.ENTITY_TYPE);
public static final List<AttributeSupplierData> SUPPLIER_DATA = new ArrayList<>();

public static final Lazy<EntityType<Snail>> SNAIL = registerEntity(
"snail",
() -> EntityType.Builder
.of(Snail::new, MobCategory.CREATURE)
.sized(0.4f, 0.4f)
.passengerAttachments(new Vec3(0, 0.3125f, -0.0625f))
.eyeHeight(0.125f)
.clientTrackingRange(10)
.build("wwizardry:snail"),
Snail::createAttributes
);

public static void init() {}

public static <T extends Entity> Lazy<EntityType<T>> registerEntity(String id, Supplier<EntityType<T>> entity, Supplier<AttributeSupplier> supplier) {
var value = EntityInitializer.<T>entities().register(WanderingWizardry.id(id), entity);
SUPPLIER_DATA.add(new AttributeSupplierData((Supplier<EntityType<?>>) (Object) value, supplier.get()));
return value;
}

public static <T extends Entity> RegistryContext<EntityType<T>> entities() {
return (RegistryContext<EntityType<T>>) (Object) ENTITIES;
}

public record AttributeSupplierData(Supplier<EntityType<?>> entity, AttributeSupplier supplier) {}
}
Loading

0 comments on commit 0004e5b

Please sign in to comment.