Skip to content

Commit

Permalink
Merge branch '1.20.x' of https://github.com/Uraneptus/Sullys-Mod into…
Browse files Browse the repository at this point in the history
… 1.20.x
  • Loading branch information
KekeCreations committed Feb 16, 2024
2 parents 32dce86 + 17f2f4b commit 461c1af
Show file tree
Hide file tree
Showing 14 changed files with 609 additions and 230 deletions.
3 changes: 3 additions & 0 deletions src/generated/resources/assets/sullysmod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
"subtitles.entity.lanternfish.death": "Lanternfish dies",
"subtitles.entity.lanternfish.flop": "Lanternfish flops",
"subtitles.entity.lanternfish.hurt": "Lanternfish hurts",
"subtitles.entity.piranha.death": "Piranha dies",
"subtitles.entity.piranha.flop": "Piranha flops",
"subtitles.entity.piranha.hurt": "Piranha hurts",
"subtitles.entity.tortoise.ambient": "Tortoise chirps",
"subtitles.entity.tortoise.death": "Tortoise dies",
"subtitles.entity.tortoise.death_baby": "Tortoise baby dies",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"sullysmod:thrown_throwing_knife"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"values": [
"minecraft:iron_golem",
"minecraft:skeleton",
"minecraft:skeleton_horse",
"minecraft:allay",
"minecraft:stray",
"minecraft:vex",
"minecraft:wither",
"minecraft:wither_skeleton"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"values": [
"minecraft:bat",
"minecraft:bee",
"minecraft:chicken",
"minecraft:cod",
"minecraft:endermite",
"minecraft:salmon",
"minecraft:pufferfish",
"minecraft:rabbit",
"minecraft:silverfish",
"minecraft:tadpole",
"minecraft:tropical_fish"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.uraneptus.sullysmod.SullysMod;
import com.uraneptus.sullysmod.common.entities.Tortoise;
import net.minecraft.resources.ResourceLocation;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.DefaultedEntityGeoModel;

public class TortoiseModel <T extends Tortoise> extends DefaultedEntityGeoModel<T> {
Expand All @@ -24,4 +26,16 @@ public ResourceLocation getTextureResource(T object) {
public ResourceLocation getAnimationResource(T animatable) {
return SullysMod.modPrefix("animations/tortoise.animation.json");
}

@Override
public void setCustomAnimations(T animatable, long instanceId, AnimationState<T> animationState) {
super.setCustomAnimations(animatable, instanceId, animationState);
CoreGeoBone craftingSaddle = getAnimationProcessor().getBone("CraftingSaddle");

if (!animatable.hasCraftingTable) {
craftingSaddle.setHidden(true);
} else {
craftingSaddle.setHidden(false);
}
}
}
23 changes: 19 additions & 4 deletions src/main/java/com/uraneptus/sullysmod/common/entities/Piranha.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.uraneptus.sullysmod.common.entities;

import com.uraneptus.sullysmod.core.other.tags.SMEntityTags;
import com.uraneptus.sullysmod.core.registry.SMEntityTypes;
import com.uraneptus.sullysmod.core.registry.SMItems;
import com.uraneptus.sullysmod.core.registry.SMSounds;
Expand All @@ -24,6 +25,7 @@
import net.minecraft.world.entity.ai.goal.target.ResetUniversalAngerTargetGoal;
import net.minecraft.world.entity.animal.AbstractFish;
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
import net.minecraft.world.entity.animal.Bucketable;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.item.ItemStack;
Expand All @@ -47,11 +49,12 @@ public class Piranha extends AbstractSchoolingFish implements GeoEntity, Neutral
private final AnimatableInstanceCache instanceCache = GeckoLibUtil.createInstanceCache(this);
protected static final RawAnimation SWIMMING_ANIM = RawAnimation.begin().thenLoop("animation.piranha.swim");
protected static final RawAnimation SWIMMING_ANGRY_ANIM = RawAnimation.begin().thenLoop("animation.piranha.swim_angry");
//protected static final RawAnimation JUMPING_ANIM = RawAnimation.begin().thenPlay("animation.piranha.jump");
protected static final RawAnimation JUMPING_ANIM = RawAnimation.begin().thenPlay("animation.piranha.in_air");
private static final EntityDataAccessor<Integer> DATA_REMAINING_ANGER_TIME = SynchedEntityData.defineId(Piranha.class, EntityDataSerializers.INT);
private static final UniformInt PERSISTENT_ANGER_TIME = TimeUtil.rangeOfSeconds(5, 10);
@Nullable
private UUID persistentAngerTarget;
private boolean isBoatTarget;

public Piranha(EntityType<? extends AbstractSchoolingFish> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
Expand Down Expand Up @@ -79,7 +82,15 @@ public int getMaxSchoolSize() {
}

public boolean isPiranhaAngry(LivingEntity pTarget) {
return (isAngryAt(pTarget) || pTarget.getHealth() < pTarget.getMaxHealth()) && !(pTarget instanceof Piranha);
return (isAngryAt(pTarget)
|| pTarget.getHealth() < pTarget.getMaxHealth()
|| pTarget.isBaby()
|| pTarget.getType().is(SMEntityTags.PIRANHA_ALWAYS_ATTACKS)
) && !(pTarget instanceof Piranha
|| pTarget.getType().is(SMEntityTags.IS_LIVING_INORGANIC)
|| pTarget.hasCustomName()
|| (pTarget instanceof Bucketable bucketable && bucketable.fromBucket()))
||isBoatTarget;
}

public static boolean checkPiranhaSpawnRules(EntityType<? extends LivingEntity> entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random) {
Expand All @@ -106,8 +117,6 @@ public void readAdditionalSaveData(CompoundTag pCompound) {

public void tick() {
super.tick();
if (level().isClientSide()) System.out.println("Client: " + this.getTarget());
if (!level().isClientSide()) System.out.println("Server: " + this.getTarget());
}

@Override
Expand Down Expand Up @@ -182,6 +191,12 @@ public void startPersistentAngerTimer() {
this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random));
}

@Nullable
@Override
public LivingEntity getTarget() {
return this.isBoatTarget ? null : super.getTarget();
}

static class PiranhaSwimGoal extends RandomSwimmingGoal {
private final Piranha fish;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -65,6 +66,7 @@ public class Tortoise extends Animal implements GeoEntity {
protected static final RawAnimation HIDING_ANIM = RawAnimation.begin().thenPlayAndHold("animation.tortoise.hide").thenLoop("animation.tortoise.hiding");
protected static final RawAnimation REVEAL_ANIM = RawAnimation.begin().thenPlayAndHold("animation.tortoise.reveal");
private final AnimatableInstanceCache instanceCache = GeckoLibUtil.createInstanceCache(this);
public boolean hasCraftingTable = false;
int layEggCounter;

public Tortoise(EntityType<? extends Animal> entityType, Level level) {
Expand Down Expand Up @@ -179,14 +181,22 @@ protected void ageBoundaryReached() {

public @NotNull InteractionResult mobInteract(Player pPlayer, @NotNull InteractionHand pHand) {
boolean flag = this.isFood(pPlayer.getItemInHand(pHand)) || this.isBaby();
if (!flag && !this.isVehicle() && !pPlayer.isSecondaryUseActive()) {
if (!this.hasCraftingTable && pPlayer.getItemInHand(pHand).is(Items.CRAFTING_TABLE)) {
this.hasCraftingTable = true;
return InteractionResult.CONSUME;
}
return super.mobInteract(pPlayer, pHand);
/*
if (!flag && !this.isVehicle() && !pPlayer.isShiftKeyDown()) {
if (!this.level().isClientSide) {
pPlayer.startRiding(this);
this.setHideTimerDuration(100);
}
this.gameEvent(GameEvent.ENTITY_INTERACT, null);
return InteractionResult.sidedSuccess(this.level().isClientSide);
} else return super.mobInteract(pPlayer, pHand);
*/
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ protected void addTranslations() {
add("subtitles.entity.lanternfish.hurt", "Lanternfish hurts");
add("subtitles.entity.lanternfish.death", "Lanternfish dies");

add("subtitles.entity.piranha.flop", "Piranha flops");
add("subtitles.entity.piranha.hurt", "Piranha hurts");
add("subtitles.entity.piranha.death", "Piranha dies");

add("subtitles.entity.bouldering_zombie.ambient", "Bouldering Zombie groans");
add("subtitles.entity.bouldering_zombie.hurt", "Bouldering Zombie hurts");
add("subtitles.entity.bouldering_zombie.death", "Bouldering Zombie dies");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.EntityTypeTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.EntityTypeTags;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.Nullable;
Expand All @@ -21,6 +22,8 @@ public SMEntityTagsProvider(PackOutput packOutput, CompletableFuture<HolderLooku

@Override
protected void addTags(HolderLookup.Provider pProvider) {
tag(EntityTypeTags.IMPACT_PROJECTILES).add(SMEntityTypes.THROWN_THROWING_KNIFE.get());

tag(BlueprintEntityTypeTags.FISHES).add(
SMEntityTypes.LANTERNFISH.get(),
SMEntityTypes.PIRANHA.get()
Expand Down Expand Up @@ -81,5 +84,29 @@ protected void addTags(HolderLookup.Provider pProvider) {
EntityType.WITHER_SKULL,
EntityType.FISHING_BOBBER
).addOptional(new ResourceLocation("botania", "mana_burst"));

tag(SMEntityTags.IS_LIVING_INORGANIC).add(
EntityType.IRON_GOLEM,
EntityType.SKELETON,
EntityType.SKELETON_HORSE,
EntityType.ALLAY,
EntityType.STRAY,
EntityType.VEX,
EntityType.WITHER,
EntityType.WITHER_SKELETON
);
tag(SMEntityTags.PIRANHA_ALWAYS_ATTACKS).add(
EntityType.BAT,
EntityType.BEE,
EntityType.CHICKEN,
EntityType.COD,
EntityType.ENDERMITE,
EntityType.SALMON,
EntityType.PUFFERFISH,
EntityType.RABBIT,
EntityType.SILVERFISH,
EntityType.TADPOLE,
EntityType.TROPICAL_FISH
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.ai.goal.target.NonTameRandomTargetGoal;
import net.minecraft.world.entity.animal.Ocelot;
Expand All @@ -48,6 +45,7 @@
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand Down Expand Up @@ -206,11 +204,28 @@ public static void onEntityJoin(EntityJoinLevelEvent event) {
public static void onLivingDropEvent(LivingDropsEvent event) {
LivingEntity livingEntity = event.getEntity();
Entity killer = event.getSource().getEntity();

if (livingEntity instanceof Player) return;

if (killer instanceof Piranha || (SMConfig.ENABLE_WOLF_CARNIVORE.get() && killer instanceof Wolf)) {
event.getDrops().removeIf(itemEntity -> itemEntity.getItem().is(SMItemTags.CARNIVORE_CONSUMABLES));
}
}

@SubscribeEvent
public static void onLivingDeathEvent(LivingDeathEvent event) {
LivingEntity livingEntity = event.getEntity();
Entity killer = event.getSource().getEntity();
Level level = event.getEntity().level();

if (!(livingEntity instanceof Zombie zombie && !zombie.isBaby()) || !(killer instanceof Piranha)) return;

CompoundTag compoundtag = livingEntity.saveWithoutId(new CompoundTag());
compoundtag.remove("Health");
livingEntity.setRemoved(Entity.RemovalReason.DISCARDED);
livingEntity = EntityType.SKELETON.create(level);
if (livingEntity != null) {
livingEntity.load(compoundtag);
level.addFreshEntity(livingEntity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public class SMEntityTags {
public static final TagKey<EntityType<?>> CANNOT_BOUNCE = TagUtil.entityTypeTag(SullysMod.MOD_ID, "cannot_bounce");
public static final TagKey<EntityType<?>> CANNOT_BE_FLUNG = TagUtil.entityTypeTag(SullysMod.MOD_ID, "cannot_be_flung");
public static final TagKey<EntityType<?>> ATTACKS_BABY_TORTOISES = TagUtil.entityTypeTag(SullysMod.MOD_ID, "attacks_baby_tortoises");
public static final TagKey<EntityType<?>> IS_LIVING_INORGANIC = TagUtil.entityTypeTag(SullysMod.MOD_ID, "is_living_inorganic");
public static final TagKey<EntityType<?>> PIRANHA_ALWAYS_ATTACKS = TagUtil.entityTypeTag(SullysMod.MOD_ID, "piranha_awlways_attacks");
}
Loading

0 comments on commit 461c1af

Please sign in to comment.