Skip to content

Commit

Permalink
pathfinding
Browse files Browse the repository at this point in the history
  • Loading branch information
SoLegendary committed Nov 30, 2024
1 parent 05f98fb commit 34e1b31
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
4 changes: 2 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Features
- If the first unit in a group tries to go to an impossible path (eg. an island), then just send all other units
- in the group to the last pos in the node list of the first unit

- iv

Bugfixes
--------
Expand All @@ -51,7 +50,8 @@ Quality of Life

[❌] Only play 1 bell sound when calling multiple villagers to arms

[❌] Show refund resources popup when cancelling buildings
[🟡] Show refund resources popup when cancelling buildings
- consider switching to SC2 system? (flat 75% refund)

[❌] Shift queueing movements and buildings (not just placement)
- Add index to sendCommand packets
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'org.parchmentmc.librarian.forgegradle'

version = '1.0.10-pathfinding-fix'
version = '1.0.11'
group = 'com.solegendary.reignofnether' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'reignofnether'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,27 @@ public static void cancelBuilding(Building building) {

// AOE2-style refund: return the % of the non-built portion of the building
// eg. cancelling a building at 70% completion will refund only 30% cost
if (!building.isBuilt) {
// in survival, refund 50% of this amount
if (!building.isBuilt || SurvivalServerEvents.isEnabled()) {

float buildPercent = building.getBlocksPlacedPercent();
ResourcesServerEvents.addSubtractResources(new Resources(building.ownerName,
Math.round(building.foodCost * (1 - buildPercent)),
Math.round(building.woodCost * (1 - buildPercent)),
Math.round(building.oreCost * (1 - buildPercent))
));
int food = Math.round(building.foodCost * (1 - buildPercent));
int wood = Math.round(building.woodCost * (1 - buildPercent));
int ore = Math.round(building.oreCost * (1 - buildPercent));

if (building.isBuilt && SurvivalServerEvents.isEnabled()) {
food = Math.round(building.foodCost * 0.5f);
wood = Math.round(building.woodCost * 0.5f);
ore = Math.round(building.oreCost * 0.5f);
}
if (food > 0 || wood > 0 || ore > 0) {
ResourcesServerEvents.addSubtractResources(new Resources(building.ownerName, food, wood, ore));
Resources res = new Resources(building.ownerName, food, wood, ore);
ResourcesServerEvents.addSubtractResources(res);
ResourcesClientboundPacket.showFloatingText(res, building.centrePos);
}
}

building.destroy((ServerLevel) building.getLevel());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class TitleScreenMixin extends Screen {
private static final ResourceLocation LILYPAD_TEXTURE =
new ResourceLocation( "textures/gui/title/lilypad.png");

private static final String VERSION_STRING = "1.0.10-pathfinding-fix";
private static final String VERSION_STRING = "1.0.11";

@Shadow @Final private PanoramaRenderer panorama;
@Shadow @Final private boolean fading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,12 +751,14 @@ else if (preselectedUnits.contains(entity) && !HudClientEvents.isMouseOverAnyBut
}

// draw path nodes
/*
if (unit instanceof Mob mob && mob.getNavigation().getPath() != null) {
for (Node node : mob.getNavigation().getPath().nodes) {
BlockPos bp = new BlockPos(node.x, node.y, node.z).below();
MyRenderer.drawBlockFace(evt.getPoseStack(), Direction.UP, bp, 0, 1, 0, a);
}
}
*/
}
}
}
Expand Down

0 comments on commit 34e1b31

Please sign in to comment.