-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
14 changed files
with
154 additions
and
47 deletions.
There are no files selected for viewing
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
1 change: 0 additions & 1 deletion
1
src/main/java/net/killarexe/dimensional_expansion/common/entity/HeadedSkeleton.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
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
85 changes: 85 additions & 0 deletions
85
src/main/java/net/killarexe/dimensional_expansion/common/entity/goals/TakeFoodGoal.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,85 @@ | ||
package net.killarexe.dimensional_expansion.common.entity.goals; | ||
|
||
import net.killarexe.dimensional_expansion.common.entity.Mouvet; | ||
import net.minecraft.core.component.DataComponents; | ||
import net.minecraft.world.entity.ai.attributes.Attributes; | ||
import net.minecraft.world.entity.ai.goal.Goal; | ||
import net.minecraft.world.entity.item.ItemEntity; | ||
import net.minecraft.world.phys.AABB; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class TakeFoodGoal extends Goal { | ||
|
||
private final Mouvet mouvet; | ||
private final float catchRange; | ||
private final float moveSpeed; | ||
private final int randomInterval; | ||
|
||
private Optional<ItemEntity> targetItem; | ||
|
||
public TakeFoodGoal(Mouvet mouvet, float catchRange, float moveSpeed, int randomInterval) { | ||
this.mouvet = mouvet; | ||
this.catchRange = catchRange; | ||
this.randomInterval = randomInterval; | ||
this.moveSpeed = moveSpeed; | ||
this.targetItem = Optional.empty(); | ||
} | ||
|
||
@Override | ||
public boolean canUse() { | ||
if (this.randomInterval > 0 && mouvet.getRandom().nextInt(this.randomInterval) != 0) { | ||
return false; | ||
} | ||
findTarget(); | ||
return targetItem.filter(itemEntity -> itemEntity.getItem().get(DataComponents.FOOD) != null).isPresent() && !mouvet.getCurrentItem().isEmpty(); | ||
} | ||
|
||
protected AABB getTargetSearchArea(double pTargetDistance) { | ||
return mouvet.getBoundingBox().inflate(pTargetDistance, 4.0, pTargetDistance); | ||
} | ||
|
||
protected double getFollowDistance() { | ||
return mouvet.getAttributeValue(Attributes.FOLLOW_RANGE); | ||
} | ||
|
||
protected void findTarget() { | ||
List<ItemEntity> itemEntities = mouvet.level().getEntitiesOfClass(ItemEntity.class, this.getTargetSearchArea(getFollowDistance()), filter -> true); | ||
if (itemEntities.isEmpty()){ | ||
targetItem = Optional.empty(); | ||
return; | ||
} | ||
targetItem = Optional.of(itemEntities.getFirst()); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
if (mouvet.level().isClientSide) { | ||
return; | ||
} | ||
if (targetItem.isPresent()) { | ||
ItemEntity itemEntity = targetItem.get(); | ||
if(!(mouvet.position().distanceTo(itemEntity.position()) < catchRange)) { | ||
mouvet.getNavigation().moveTo(itemEntity, moveSpeed); | ||
return; | ||
} | ||
mouvet.setCurrentItem(itemEntity.getItem()); | ||
itemEntity.kill(); | ||
} | ||
} | ||
|
||
public void setTargetItem(ItemEntity entity) { | ||
targetItem = Optional.ofNullable(entity); | ||
} | ||
|
||
@Override | ||
public boolean canContinueToUse() { | ||
return canUse(); | ||
} | ||
|
||
@Override | ||
public boolean requiresUpdateEveryTick() { | ||
return true; | ||
} | ||
} |
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
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
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
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
17 changes: 9 additions & 8 deletions
17
src/main/resources/data/dimensional_expansion/worldgen/structure/village_origin_plains.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 |
---|---|---|
@@ -1,15 +1,16 @@ | ||
{ | ||
"type": "minecraft:jigsaw", | ||
"biomes": "#dimensional_expansion:has_structure/origin_village_plains", | ||
"max_distance_from_center": 80, | ||
"project_start_to_heightmap": "WORLD_SURFACE_WG", | ||
"size": 6, | ||
"step": "surface_structures", | ||
"spawn_overrides": {}, | ||
"terrain_adaptation": "beard_thin", | ||
"start_pool": "dimensional_expansion:origin_village/origin_plains/town_centers", | ||
"size": 6, | ||
"start_height": { | ||
"absolute": 0 | ||
}, | ||
"start_pool": "dimensional_expansion:origin_village/origin_plains/town_centers", | ||
"step": "surface_structures", | ||
"terrain_adaptation": "beard_thin", | ||
"use_expansion_hack": true | ||
} | ||
"project_start_to_heightmap": "WORLD_SURFACE_WG", | ||
"max_distance_from_center": 80, | ||
"use_expansion_hack": true, | ||
"liquid_settings": "apply_waterlogging" | ||
} |
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
27 changes: 14 additions & 13 deletions
27
...data/dimensional_expansion/worldgen/template_pool/origin_village/origin_plains/decor.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 |
---|---|---|
@@ -1,30 +1,31 @@ | ||
{ | ||
"fallback": "minecraft:empty", | ||
"elements": [ | ||
{ | ||
"weight": 2, | ||
"element": { | ||
"element_type": "minecraft:legacy_single_pool_element", | ||
"projection": "rigid", | ||
"location": "dimensional_expansion:origin_village/origin_plains/plains_lamp_1", | ||
"override_liquid_settings": "apply_waterlogging", | ||
"processors": { | ||
"processors": [] | ||
}, | ||
"projection": "rigid" | ||
}, | ||
"weight": 2 | ||
} | ||
} | ||
}, | ||
{ | ||
"weight": 1, | ||
"element": { | ||
"element_type": "minecraft:feature_pool_element", | ||
"feature": "dimensional_expansion:pile_savorleaf_placed", | ||
"projection": "rigid" | ||
}, | ||
"weight": 1 | ||
"projection": "rigid", | ||
"feature": "dimensional_expansion:pile_savorleaf_placed" | ||
} | ||
}, | ||
{ | ||
"weight": 2, | ||
"element": { | ||
"element_type": "minecraft:empty_pool_element" | ||
}, | ||
"weight": 2 | ||
} | ||
} | ||
], | ||
"fallback": "minecraft:empty" | ||
} | ||
] | ||
} |