generated from Team-Abode/abode-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
28 changed files
with
601 additions
and
14 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
src/main/generated/assets/rods_n_reels/models/item/goldfish.json
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "rods_n_reels:item/goldfish" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/generated/assets/rods_n_reels/models/item/goldfish_bucket.json
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "rods_n_reels:item/goldfish_bucket" | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/generated/data/rods_n_reels/loot_table/entities/goldfish.json
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"type": "minecraft:entity", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"functions": [ | ||
{ | ||
"add": false, | ||
"count": 1.0, | ||
"function": "minecraft:set_count" | ||
} | ||
], | ||
"name": "rods_n_reels:goldfish" | ||
} | ||
], | ||
"rolls": 1.0 | ||
}, | ||
{ | ||
"bonus_rolls": 0.0, | ||
"conditions": [ | ||
{ | ||
"chance": 0.05, | ||
"condition": "minecraft:random_chance" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "minecraft:bone_meal" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
] | ||
} |
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
59 changes: 59 additions & 0 deletions
59
src/main/java/com/teamabode/rodsnreels/client/model/GoldfishModel.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.teamabode.rodsnreels.client.model; | ||
|
||
import com.teamabode.rodsnreels.RodsNReels; | ||
import com.teamabode.rodsnreels.common.entity.goldfish.Goldfish; | ||
import net.minecraft.client.model.HierarchicalModel; | ||
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.util.Mth; | ||
|
||
public class GoldfishModel extends HierarchicalModel<Goldfish> { | ||
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(RodsNReels.id("goldfish"), "main"); | ||
|
||
private final ModelPart body; | ||
private final ModelPart leftFin; | ||
private final ModelPart rightFin; | ||
private final ModelPart head; | ||
private final ModelPart tailFin; | ||
|
||
public GoldfishModel(ModelPart root) { | ||
this.body = root.getChild("body"); | ||
this.leftFin = body.getChild("left_fin"); | ||
this.rightFin = body.getChild("right_fin"); | ||
this.head = body.getChild("head"); | ||
this.tailFin = body.getChild("tail_fin"); | ||
} | ||
|
||
public static LayerDefinition createBodyLayer() { | ||
MeshDefinition mesh = new MeshDefinition(); | ||
PartDefinition root = mesh.getRoot(); | ||
|
||
PartDefinition body = root.addOrReplaceChild("body", CubeListBuilder.create().texOffs(8, 10).addBox(0.0F, 3.0F, -1.0F, 0.0F, 2.0F, 3.0F, new CubeDeformation(0.0F)) | ||
.texOffs(0, 0).addBox(-2.0F, -2.0F, -4.0F, 4.0F, 5.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 20.0F, 0.0F)); | ||
PartDefinition leftFin = body.addOrReplaceChild("left_fin", CubeListBuilder.create() | ||
.texOffs(0, 1).addBox(0.0F, 0.0F, 0.0F, 0.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(2.0F, 1.0F, -4.0F, 0.0F, 0.3927F, 0.0F)); | ||
PartDefinition rightFin = body.addOrReplaceChild("right_fin", CubeListBuilder.create() | ||
.texOffs(0, -1).addBox(0.0F, 0.0F, 0.0F, 0.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-2.0F, 1.0F, -4.0F, 0.0F, -0.3927F, 0.0F)); | ||
PartDefinition head = body.addOrReplaceChild("head", CubeListBuilder.create() | ||
.texOffs(0, 17).addBox(-2.0F, -1.0F, -3.0F, 4.0F, 4.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.0F, -4.0F)); | ||
PartDefinition tailFin = body.addOrReplaceChild("tail_fin", CubeListBuilder.create() | ||
.texOffs(14, 9).addBox(1.0F, -4.0F, 1.0F, 0.0F, 5.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(-1.0F, 2.0F, 3.0F)); | ||
return LayerDefinition.create(mesh, 32, 32); | ||
} | ||
|
||
@Override | ||
public void setupAnim(Goldfish entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { | ||
float k = 1.0f; | ||
if (!entity.isInWater()) { | ||
k = 1.5f; | ||
} | ||
this.tailFin.yRot = -k * 0.45f * Mth.sin(0.6f * ageInTicks); | ||
} | ||
|
||
@Override | ||
public ModelPart root() { | ||
return this.body; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/teamabode/rodsnreels/client/renderer/GoldfishRenderer.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.teamabode.rodsnreels.client.renderer; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.math.Axis; | ||
import com.teamabode.rodsnreels.RodsNReels; | ||
import com.teamabode.rodsnreels.client.model.GoldfishModel; | ||
import com.teamabode.rodsnreels.common.entity.goldfish.Goldfish; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
import net.minecraft.client.renderer.entity.MobRenderer; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.Mth; | ||
|
||
public class GoldfishRenderer extends MobRenderer<Goldfish, GoldfishModel> { | ||
public static final ResourceLocation TEXTURE = RodsNReels.id("textures/entity/goldfish.png"); | ||
|
||
public GoldfishRenderer(EntityRendererProvider.Context context) { | ||
super(context, new GoldfishModel(context.bakeLayer(GoldfishModel.LAYER_LOCATION)), 0.4f); | ||
} | ||
|
||
@Override | ||
protected void setupRotations(Goldfish goldfish, PoseStack poseStack, float f, float g, float h, float i) { | ||
super.setupRotations(goldfish, poseStack, f, g, h, i); | ||
|
||
float rot = 4.3F * Mth.sin(0.6F * f); | ||
poseStack.mulPose(Axis.YP.rotationDegrees(rot)); | ||
|
||
if (!goldfish.isInWater()) { | ||
poseStack.translate(0.1F, 0.1F, -0.1F); | ||
poseStack.mulPose(Axis.ZP.rotationDegrees(90.0F)); | ||
} | ||
} | ||
|
||
@Override | ||
public ResourceLocation getTextureLocation(Goldfish entity) { | ||
return TEXTURE; | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
src/main/java/com/teamabode/rodsnreels/common/entity/goldfish/Goldfish.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 |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package com.teamabode.rodsnreels.common.entity.goldfish; | ||
|
||
import com.teamabode.rodsnreels.common.entity.goldfish.goals.SwimTowardsOwnerGoal; | ||
import com.teamabode.rodsnreels.core.registry.RNRItems; | ||
import com.teamabode.rodsnreels.core.registry.RNRSoundEvents; | ||
import net.minecraft.core.component.DataComponents; | ||
import net.minecraft.core.particles.ParticleTypes; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.syncher.EntityDataAccessor; | ||
import net.minecraft.network.syncher.EntityDataSerializers; | ||
import net.minecraft.network.syncher.SynchedEntityData; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.OwnableEntity; | ||
import net.minecraft.world.entity.ai.goal.PanicGoal; | ||
import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; | ||
import net.minecraft.world.entity.animal.AbstractFish; | ||
import net.minecraft.world.entity.animal.Bucketable; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.component.CustomData; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
public class Goldfish extends AbstractFish implements OwnableEntity { | ||
private static final EntityDataAccessor<Optional<UUID>> OWNER_ID = SynchedEntityData.defineId(Goldfish.class, EntityDataSerializers.OPTIONAL_UUID); | ||
|
||
public Goldfish(EntityType<? extends Goldfish> entityType, Level level) { | ||
super(entityType, level); | ||
} | ||
|
||
public void spawnHeartParticles() { | ||
for(int i = 0; i < 7; i++) { | ||
double d = this.random.nextGaussian() * 0.02; | ||
double e = this.random.nextGaussian() * 0.02; | ||
double f = this.random.nextGaussian() * 0.02; | ||
this.level().addParticle(ParticleTypes.HEART, this.getRandomX(1.0), this.getRandomY() + 0.5, this.getRandomZ(1.0), d, e, f); | ||
} | ||
} | ||
|
||
public boolean unableToFollowOwner() { | ||
return this.isPassenger() || this.isPanicking() || this.getOwner() != null && this.getOwner().isSpectator(); | ||
} | ||
|
||
@Override | ||
public void handleEntityEvent(byte flag) { | ||
if (flag == 7) { | ||
this.spawnHeartParticles(); | ||
} | ||
else { | ||
super.handleEntityEvent(flag); | ||
} | ||
} | ||
|
||
@Override | ||
protected void defineSynchedData(SynchedEntityData.Builder builder) { | ||
super.defineSynchedData(builder); | ||
builder.define(OWNER_ID, Optional.empty()); | ||
} | ||
|
||
@Override | ||
public void addAdditionalSaveData(CompoundTag compoundTag) { | ||
super.addAdditionalSaveData(compoundTag); | ||
if (this.getOwnerUUID() != null) { | ||
compoundTag.putUUID("owner", this.getOwnerUUID()); | ||
} | ||
} | ||
|
||
@Override | ||
public void readAdditionalSaveData(CompoundTag compoundTag) { | ||
super.readAdditionalSaveData(compoundTag); | ||
if (compoundTag.hasUUID("owner")) { | ||
this.setOwnerUUID(compoundTag.getUUID("owner")); | ||
} | ||
} | ||
|
||
@Override | ||
public void saveToBucketTag(ItemStack stack) { | ||
Bucketable.saveDefaultDataToBucketTag(this, stack); | ||
CustomData.update(DataComponents.BUCKET_ENTITY_DATA, stack, (tag) -> { | ||
if (this.getOwnerUUID() != null) { | ||
tag.putUUID("owner", this.getOwnerUUID()); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void loadFromBucketTag(CompoundTag tag) { | ||
Bucketable.loadDefaultDataFromBucketTag(this, tag); | ||
if (tag.contains("owner")) { | ||
this.setOwnerUUID(tag.getUUID("owner")); | ||
} | ||
} | ||
|
||
@Override | ||
protected void registerGoals() { | ||
this.goalSelector.addGoal(0, new PanicGoal(this, 1.25)); | ||
this.goalSelector.addGoal(2, new RandomSwimmingGoal(this, 1.0f, 40)); | ||
this.goalSelector.addGoal(4, new SwimTowardsOwnerGoal(this, 10)); | ||
} | ||
|
||
@Override | ||
public ItemStack getBucketItemStack() { | ||
return new ItemStack(RNRItems.GOLDFISH_BUCKET); | ||
} | ||
|
||
@Override | ||
public SoundEvent getAmbientSound() { | ||
return RNRSoundEvents.ENTITY_GOLDFISH_AMBIENT; | ||
} | ||
|
||
@Override | ||
public SoundEvent getDeathSound() { | ||
return RNRSoundEvents.ENTITY_GOLDFISH_DEATH; | ||
} | ||
|
||
@Override | ||
public SoundEvent getHurtSound(DamageSource damageSource) { | ||
return RNRSoundEvents.ENTITY_GOLDFISH_HURT; | ||
} | ||
|
||
@Override | ||
public SoundEvent getFlopSound() { | ||
return RNRSoundEvents.ENTITY_GOLDFISH_FLOP; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public UUID getOwnerUUID() { | ||
return this.entityData.get(OWNER_ID).orElse(null); | ||
} | ||
|
||
public void setOwnerUUID(UUID id) { | ||
this.entityData.set(OWNER_ID, Optional.ofNullable(id)); | ||
} | ||
} |
Oops, something went wrong.