Skip to content

Commit

Permalink
Patch portal, add models, textures
Browse files Browse the repository at this point in the history
  • Loading branch information
Killarexe committed Jul 25, 2024
1 parent e10fcba commit e51e681
Show file tree
Hide file tree
Showing 55 changed files with 578 additions and 607 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void teleport(Entity entity, BlockPos pos, ResourceKey<Level> dimension)
if(level != null) {
entity.changeDimension(level, new OriginTeleporter(level, pos));
}else {
DEMod.LOGGER.error("Dimension "+ dimension.toString() +" don't exsit!");
DEMod.LOGGER.error("Dimension "+ dimension +" don't exsit!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class HeadedSkeleton extends Monster implements RangedAttackMob{
.add(Attributes.MOVEMENT_SPEED, 0.0f)
.add(Attributes.KNOCKBACK_RESISTANCE, 10.0f)
.add(Attributes.JUMP_STRENGTH, 0.0f)
.add(Attributes.MAX_HEALTH, 30.0f);
.add(Attributes.MAX_HEALTH, 20.0f);

public HeadedSkeleton(EntityType<? extends HeadedSkeleton> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
Expand Down Expand Up @@ -66,7 +66,7 @@ public void aiStep() {
public SpawnGroupData finalizeSpawn(ServerLevelAccessor pLevel, DifficultyInstance pDifficulty,
MobSpawnType pReason, SpawnGroupData pSpawnData, CompoundTag pDataTag) {
setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.BOW));
this.goalSelector.addGoal(4, new RangedBowAttackGoal<HeadedSkeleton>(this, 1.0D, 20, 15.0F));
this.goalSelector.addGoal(4, new RangedBowAttackGoal<HeadedSkeleton>(this, 1.0D, 30, 15.0F));
return super.finalizeSpawn(pLevel, pDifficulty, pReason, pSpawnData, pDataTag);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;

public class Juger extends Monster{
public class Juger extends Monster {

private static final EntityDataAccessor<Boolean> IS_ATTACKING = SynchedEntityData.defineId(Juger.class, EntityDataSerializers.BOOLEAN);
private static final EntityDataAccessor<Integer> ATTACK_COOLDOWN = SynchedEntityData.defineId(Juger.class, EntityDataSerializers.INT);
Expand All @@ -36,8 +37,8 @@ public class Juger extends Monster{
public static final AttributeSupplier.Builder ATTRIBUTES = createMonsterAttributes()
.add(Attributes.MOVEMENT_SPEED, 0.25f)
.add(Attributes.JUMP_STRENGTH, 0.5f)
.add(Attributes.ATTACK_DAMAGE, 7.0f)
.add(Attributes.MAX_HEALTH, 40.0f);
.add(Attributes.ATTACK_DAMAGE, 5.0f)
.add(Attributes.MAX_HEALTH, 30.0f);

public Juger(EntityType<? extends Monster> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
Expand All @@ -46,7 +47,7 @@ public Juger(EntityType<? extends Monster> pEntityType, Level pLevel) {
@Override
protected void registerGoals() {
this.goalSelector.addGoal(1, new RandomLookAroundGoal(this));
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.25F, true));
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.125F, true));
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(2, new WaterAvoidingRandomStrollGoal(this, 1.0D));

Expand Down Expand Up @@ -79,7 +80,7 @@ protected SoundEvent getHurtSound(DamageSource pDamageSource) {
}

@Override
public MobType getMobType() {
public @NotNull MobType getMobType() {
return MobType.ARTHROPOD;
}

Expand All @@ -106,7 +107,7 @@ private void handleAnimationStates() {

@Override
public double getMeleeAttackRangeSqr(LivingEntity pEntity) {
return (double)(this.getBbWidth() * 1.0F * this.getBbWidth() * 1.0F + pEntity.getBbWidth());
return this.getBbWidth() * 1.0F * this.getBbWidth() * 1.0F + pEntity.getBbWidth();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import net.killarexe.dimensional_expansion.common.entity.goals.StealFoodGoal;
import net.killarexe.dimensional_expansion.common.entity.goals.TakeFoodGoal;
import net.killarexe.dimensional_expansion.init.DESoundEvents;
import net.minecraft.core.registries.BuiltInRegistries;
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.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.FloatGoal;
Expand All @@ -24,8 +24,13 @@
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class Mouvet extends Animal{

Expand All @@ -45,11 +50,11 @@ protected void registerGoals() {
this.goalSelector.addGoal(5, new RandomLookAroundGoal(this));
this.goalSelector.addGoal(4, new LookAtPlayerGoal(this, Mob.class, 10));
this.goalSelector.addGoal(3, new WaterAvoidingRandomStrollGoal(this, 1.0D));
this.goalSelector.addGoal(2, new TakeFoodGoal(this, 1.0F, 0.75F, 10));
this.goalSelector.addGoal(2, new TakeFoodGoal(this, 1.0F, 0.75F, 0));
this.goalSelector.addGoal(1, new PanicGoal(this, 1.15f));
this.goalSelector.addGoal(0, new FloatGoal(this));

this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<Player>(this, Player.class, true));
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Player.class, true));
this.targetSelector.addGoal(2, new StealFoodGoal(this, 1.0F));
}

Expand Down Expand Up @@ -88,6 +93,17 @@ protected void dropEquipment() {
super.dropEquipment();
}

@Override
public SpawnGroupData finalizeSpawn(ServerLevelAccessor pLevel, DifficultyInstance pDifficulty, MobSpawnType pReason, @Nullable SpawnGroupData pSpawnData, @Nullable CompoundTag pDataTag) {
if (pLevel.getRandom().nextInt(500) <= 10) {
List<Item> foodItems = BuiltInRegistries.ITEM.stream().filter(Item::isEdible).toList();
if (!foodItems.isEmpty()) {
setCurrentItem(new ItemStack(foodItems.get(random.nextInt(foodItems.size() - 1))));
}
}
return super.finalizeSpawn(pLevel, pDifficulty, pReason, pSpawnData, pDataTag);
}

public ItemStack getCurrentItem() {
return entityData.get(CURRENT_ITEM);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void tick() {
targetMob = mob.getTarget();
if(targetMob instanceof Player player) {
if(mob.canAttack(targetMob, TargetingConditions.forCombat().range(range))) {
ItemStack stack = player.getMainHandItem();
ItemStack stack = player.getItemInHand(player.getUsedItemHand());
if(stack.isEdible()) {
if(mob instanceof Mouvet mouvet) {
mouvet.setCurrentItem(stack.copy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean canUse() {
return false;
}
findTarget();
return targetItem.filter(itemEntity -> itemEntity.getItem().isEdible()).isPresent() && !mouvet.getCurrentItem().isEmpty();
return targetItem.isPresent() && mouvet.getCurrentItem().isEmpty();
}

protected AABB getTargetSearchArea(double pTargetDistance) {
Expand All @@ -44,7 +44,7 @@ protected double getFollowDistance() {
}

protected void findTarget() {
List<ItemEntity> itemEntities = mouvet.level().getEntitiesOfClass(ItemEntity.class, this.getTargetSearchArea(getFollowDistance()), filter -> true);
List<ItemEntity> itemEntities = mouvet.level().getEntitiesOfClass(ItemEntity.class, this.getTargetSearchArea(getFollowDistance()), filter -> filter.getItem().isEdible());
if (itemEntities.isEmpty()){
targetItem = Optional.empty();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public InteractionResult useOn(UseOnContext pContext) {

@Override
public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) {
if (entity instanceof Player) {
return super.onLeftClickEntity(stack, player, entity);
}
CompoundTag currentEntity = stack.getOrCreateTagElement("current_entity");
if(entity instanceof LivingEntity livingEntity && currentEntity.isEmpty()) {
stack.addTagElement("current_entity", livingEntity.serializeNBT());
Expand Down
Loading

0 comments on commit e51e681

Please sign in to comment.