Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ subprojects {
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
}
maven {
name = "Curse Maven"
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
name = "Modrinth Maven"
url = "https://api.modrinth.com/maven"
}
}

Expand Down
3 changes: 1 addition & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ architectury {
dependencies {
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "software.bernie.geckolib:geckolib-fabric-${minecraft_version}:${geckolib_version}"

modApi "curse.maven:jade-324717:${jade_id_fabric}"
modApi "maven.modrinth:jade:${jade_version}+fabric"
}

1 change: 1 addition & 0 deletions common/src/main/java/net/untitledduckmod/DuckMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void preInit() {
ModSoundEvents.init();
ModStatusEffects.init();
ModPotions.init();
ModScreenHandlers.init();
}

public static void postInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@ public Identifier getModelResource(DuckEntity object) {
public Identifier getTextureResource(DuckEntity animatable) {
if (animatable.isBaby()) {
return ModelIdentifiers.DUCKLING_TEXTURE;
} else {
if (animatable.hasCustomName()) {
String name = Objects.requireNonNull(animatable.getCustomName()).getString().toLowerCase();
switch (name) {
case "pekin" -> {
return ModelIdentifiers.PEKIN_TEXTURE;
}
}
}
}
var variant = animatable.getVariant();

return switch (variant) {
case 1 -> ModelIdentifiers.FEMALE_TEXTURE;
case 2 -> ModelIdentifiers.CAMPBELL_TEXTURE;
case 3 -> ModelIdentifiers.PEKIN_TEXTURE;
default -> ModelIdentifiers.NORMAL_TEXTURE;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public Identifier getModelResource(GooseEntity object) {
}

@Override
public Identifier getTextureResource(GooseEntity entity) {
if (entity.isBaby()) {
public Identifier getTextureResource(GooseEntity animatable) {
if (animatable.isBaby()) {
return ModelIdentifiers.GOSLING_TEXTURE;
} else {
if (entity.hasCustomName()) {
String name = Objects.requireNonNull(entity.getCustomName()).getString().toLowerCase();
if (animatable.hasCustomName()) {
String name = Objects.requireNonNull(animatable.getCustomName()).getString().toLowerCase();
switch (name) {
case "ping" -> {
return ModelIdentifiers.PING_GOOSE_TEXTURE;
Expand All @@ -37,8 +37,13 @@ public Identifier getTextureResource(GooseEntity entity) {
}
}
}
var variant = animatable.getVariant();

return entity.getVariant() == 0 ? ModelIdentifiers.GOOSE_TEXTURE : ModelIdentifiers.CANADIAN_GOOSE_TEXTURE;
return switch (variant) {
case 1 -> ModelIdentifiers.CANADIAN_GOOSE_TEXTURE;
case 2 -> ModelIdentifiers.GREYLAG_GOOSE_TEXTURE;
default -> ModelIdentifiers.GOOSE_TEXTURE;
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ModelIdentifiers {
public static final Identifier GOOSE_ANIMATION_FILE_LOCATION = DuckMod.id("animations/goose.animation.json");
public static final Identifier GOOSE_TEXTURE = DuckMod.id("textures/entity/goose.png");
public static final Identifier CANADIAN_GOOSE_TEXTURE = DuckMod.id("textures/entity/canadian_goose.png");
public static final Identifier GREYLAG_GOOSE_TEXTURE = DuckMod.id("textures/entity/greylag_goose.png");
public static final Identifier GOSLING_TEXTURE = DuckMod.id("textures/entity/gosling.png");

public static final Identifier PING_GOOSE_TEXTURE = DuckMod.id("textures/entity/ping_goose.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.render.item.HeldItemRenderer;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.RotationAxis;
import net.untitledduckmod.common.entity.DuckEntity;
Expand Down Expand Up @@ -67,18 +68,22 @@ public void renderRecursively(MatrixStack poseStack, T animatable, GeoBone bone,
if (bone.getName().equals("beak") && !mainHand.isEmpty()) {
poseStack.push();
if (animatable instanceof DuckEntity) {
poseStack.translate(0.0, 0.50, -0.40);
poseStack.translate(-0.05, 0.50, -0.30);
} else if (animatable instanceof GooseEntity) {
poseStack.translate(0.0, 1.15, -0.45);
poseStack.translate(0.15, 1.15, -0.40);
if (mainHand.getItem() instanceof BlockItem) {
poseStack.translate(-0.15, 0, 0.0);
}
}

poseStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-90f));
poseStack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(-45f));
poseStack.scale(0.7f, 0.7f, 0.7f);

heldItemRenderer.renderItem(animatable, mainHand, ModelTransformationMode.GROUND, false, poseStack, bufferSource, packedLight);
poseStack.pop();

buffer = bufferSource.getBuffer(RenderLayer.getEntityCutout(this.getTexture(animatable)));
buffer = bufferSource.getBuffer(renderType);
}
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.untitledduckmod.client.screen;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.untitledduckmod.common.entity.WaterfowlEntity;
import net.untitledduckmod.common.screen.MouthScreenHandler;

public class MouthScreen extends HandledScreen<MouthScreenHandler> {
private static final Identifier TEXTURE = new Identifier("textures/gui/container/horse.png");
private WaterfowlEntity renderEntity;
private float mouseX;
private float mouseY;

public MouthScreen(MouthScreenHandler handler, PlayerInventory inventory, Text title) {
super(handler, inventory, title);
Entity entity = inventory.player.getEntityWorld().getEntityById(handler.getEntityId());
if (entity instanceof WaterfowlEntity waterfowl) {
renderEntity = waterfowl;
}
}

@Override
protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
int x = (this.width - this.backgroundWidth) / 2;
int y = (this.height - this.backgroundHeight) / 2;

context.drawTexture(TEXTURE, x, y, 0, 0, this.backgroundWidth, this.backgroundHeight);

context.drawTexture(TEXTURE, x + 7, y + 17, 0, this.backgroundHeight, 18, 18);

if (this.renderEntity != null) {
InventoryScreen.drawEntity(context, x + 51, y + 60, 30, (float)(x + 51) - this.mouseX, (float)(y + 75 - 50) - this.mouseY, this.renderEntity);
}
}

public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.renderBackground(context);
this.mouseX = (float)mouseX;
this.mouseY = (float)mouseY;
super.render(context, mouseX, mouseY, delta);
this.drawMouseoverTooltip(context, mouseX, mouseY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,31 @@ public static boolean gooseBabyRandomSize() {
throw new AssertionError();
}

@ExpectPlatform
public static boolean enableForceEat() {
throw new AssertionError();
}

@ExpectPlatform
public static int forceEatRandomMinTick() {
throw new AssertionError();
}

@ExpectPlatform
public static int forceEatRandomMaxTick() {
throw new AssertionError();
}

@ExpectPlatform
public static int minEggLayTime() {
throw new AssertionError();
}

@ExpectPlatform
public static int maxEggLayTime() {
throw new AssertionError();
}

@ExpectPlatform
public static float foodHealingValue() {
throw new AssertionError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.entity.SpawnGroup;

public enum CustomSpawnGroup {
WATERFOWL("waterfowl", 10, true, false, 128);
WATERFOWL("waterfowl", 10, true, true, 128);

public SpawnGroup spawnGroup;
public final String name;
Expand All @@ -15,7 +15,7 @@ public enum CustomSpawnGroup {
public static final String WATERFOWL_NAME = "waterfowl";
public static final int WATERFOWL_SPAWN_CAP = 10;
public static final boolean WATERFOWL_PEACEFUL = true;
public static final boolean WATERFOWL_RARE = false;
public static final boolean WATERFOWL_RARE = true;
public static final int WATERFOWL_IMMEDIATE_DESPAWN_RANGE = 128;

CustomSpawnGroup(String name, int spawnCap, boolean peaceful, boolean rare, int immediateDespawnRange) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class DuckEntity extends WaterfowlEntity implements Vibrations, Animation
private static final RawAnimation DIVE_ANIM = RawAnimation.begin().thenPlay("dive").thenPlay("idle_swim");
private static final RawAnimation DANCE_ANIM = RawAnimation.begin().thenPlay("dance");

public static final Ingredient FOOD_INGREDIENT = Ingredient.fromTag(ModTags.ItemTags.DUCK_FOOD);
public static final Ingredient BREEDING_INGREDIENT = Ingredient.fromTag(ModTags.ItemTags.DUCK_BREEDING_FOOD);
public static final Ingredient TAMING_INGREDIENT = Ingredient.fromTag(ModTags.ItemTags.DUCK_TAMING_FOOD);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
Expand All @@ -98,7 +99,7 @@ public class DuckEntity extends WaterfowlEntity implements Vibrations, Animation
public DuckEntity(EntityType<? extends WaterfowlEntity> entityType, World world) {
super(entityType, world);

this.maxVariant = 3;
this.maxVariant = 4;
this.vibrationCallback = new VibrationCallback();
this.vibrationListenerData = new Vibrations.ListenerData();
this.jukeboxEventHandler = new EntityGameEventHandler<>(new DuckEntity.JukeboxEventListener(this.vibrationCallback.getPositionSource(), GameEvent.JUKEBOX_PLAY.getRange()));
Expand Down Expand Up @@ -136,7 +137,6 @@ public static boolean checkDuckSpawnRules(EntityType<DuckEntity> duck, WorldAcce
return isValidSurface && hasEnoughSpace;
}


@Override
protected void initDataTracker() {
super.initDataTracker();
Expand Down Expand Up @@ -222,14 +222,19 @@ public void updateEventHandler(BiConsumer<EntityGameEventHandler<?>, ServerWorld
}
}

@Override
public int getMouthHolderType() {
return 2;
}

@Override
protected void initGoals() {
this.goalSelector.add(0, new SwimGoal(this));
this.goalSelector.add(1, new EscapeDangerGoal(this, 1.6D));
this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D));
this.goalSelector.add(2, new EatGoal(this));
this.goalSelector.add(3, new SitGoal(this));
this.goalSelector.add(4, new TemptGoal(this, 1.0D, BREEDING_INGREDIENT, false));
this.goalSelector.add(4, new TemptGoal(this, 1.0D, FOOD_INGREDIENT, false));
this.goalSelector.add(5, new WFollowParentGoal(this, 1.1D));
this.goalSelector.add(6, new WFollowOwnerGoal(this, 1.6D, 10.0F, 2.0F, false));
this.goalSelector.add(6, new CleanGoal(this));
Expand All @@ -239,6 +244,10 @@ protected void initGoals() {
this.goalSelector.add(8, new LookAroundGoal(this));
}

public boolean isEdibleFood(ItemStack stack) {
return !stack.isEmpty() && FOOD_INGREDIENT.test(stack);
}

@Override
public boolean isBreedingItem(ItemStack stack) {
if (this.isTamed()) {
Expand Down Expand Up @@ -475,7 +484,12 @@ protected void loot(ItemEntity item) {

@Override
public boolean canPickupItem(ItemStack stack) {
if (stack.isIn(ModTags.ItemTags.COOKED_MEAT) || stack.isIn(ModTags.ItemTags.RAW_MEAT)) {
return false;
}

ItemStack mainHandStack = getMainHandStack();

// If the main hand is empty, allow pickup if it's a breeding or fish item
if (mainHandStack.isEmpty()) {
return isBreedingItem(stack) || isTamableItem(stack);
Expand Down
Loading
Loading