Skip to content

Commit

Permalink
[~] Fixed Hamster rendering + pickup + version change.
Browse files Browse the repository at this point in the history
  • Loading branch information
crispytwig committed Feb 19, 2024
1 parent 89bd54f commit faea119
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mapping_version=1.20.1
mod_id=hamsters
mod_name=Hamsters
mod_license=MIT
mod_version=1.0.2
mod_version=1.0.3
mod_group_id=com.starfish_studios
mod_authors=Starfish Studios, Ninni, crispytwig
mod_description=Introducing small, fluffy, and adorable hamsters to Minecraft!
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.starfish_studios.hamsters.Hamsters;
import com.starfish_studios.hamsters.block.entity.HamsterWheelBlockEntity;
import com.starfish_studios.hamsters.entity.Hamster;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
Expand All @@ -26,6 +27,11 @@ public ResourceLocation getAnimationResource(Hamster animatable) {
return new ResourceLocation(Hamsters.MOD_ID, "animations/hamster.animation.json");
}

@Override
public RenderType getRenderType(Hamster animatable, ResourceLocation texture) {
return RenderType.entityCutoutNoCull(texture);
}

@Override
public void setCustomAnimations(Hamster animatable, long instanceId, AnimationState<Hamster> animationState) {
super.setCustomAnimations(animatable, instanceId, animationState);
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/starfish_studios/hamsters/entity/Hamster.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,11 @@ public InteractionResult mobInteract(Player player, InteractionHand interactionH
} else {
InteractionResult interactionResult;
if (this.isTame()) {
if (this.isOwnedBy(player)) {
if (this.getHealth() < this.getMaxHealth()) {
if (this.isOwnedBy(player) && this.isFood(itemStack) && (this.getHealth() < this.getMaxHealth())) {
this.usePlayerItem(player, interactionHand, itemStack);
this.heal(2.0F);
return InteractionResult.CONSUME;
}

} else if (this.isOwnedBy(player)) {
interactionResult = super.mobInteract(player, interactionHand);
if (!interactionResult.consumesAction() || this.isBaby()) {
this.setOrderedToSit(!this.isOrderedToSit());
Expand Down Expand Up @@ -195,6 +193,12 @@ public boolean isFood(ItemStack itemStack) {
public InteractionResult catchHamster(Player player) {
ItemStack output = this.getCaughtItemStack();
saveDefaultDataToItemTag(this, output);
if (!player.getInventory().add(output)) {
ItemEntity itemEntity = new ItemEntity(level(), this.getX(), this.getY() + 0.5, this.getZ(), output);
itemEntity.setPickUpDelay(0);
itemEntity.setDeltaMovement(itemEntity.getDeltaMovement().multiply(0, 1, 0));
level().addFreshEntity(itemEntity);
}
this.discard();
player.getInventory().add(output);
return InteractionResult.sidedSuccess(true);
Expand Down

0 comments on commit faea119

Please sign in to comment.