Skip to content

Commit

Permalink
[~] Fixed Hamster render type + catching feature
Browse files Browse the repository at this point in the history
  • Loading branch information
crispytwig committed Feb 19, 2024
1 parent 3d38a65 commit 549f87e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,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 549f87e

Please sign in to comment.