Skip to content

Commit

Permalink
Updated to 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvionKirito committed Mar 31, 2023
1 parent 32915bb commit 98c8492
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 45 deletions.
Binary file not shown.
Empty file.
Binary file added .vs/AltoclefMarvionGithub/v17/.wsuo
Binary file not shown.
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
11 changes: 11 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"ExpandedNodes": [
"",
"\\src",
"\\src\\main",
"\\src\\main\\java",
"\\src\\main\\java\\adris",
"\\src\\main\\java\\adris\\altoclef"
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "fabric-loom" version "1.1-SNAPSHOT"
id "maven-publish"
id 'com.github.johnrengelman.shadow' version '8.1.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -32,21 +32,21 @@ dependencies {
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")

// Jackson JSON
implementation 'com.fasterxml.jackson.core:jackson-core:2.14.2'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
implementation 'com.fasterxml.jackson.core:jackson-core:2.15.0-rc1'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.0-rc1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.0-rc1'

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
shadow('com.fasterxml.jackson.core:jackson-core:2.14.2')
shadow('com.fasterxml.jackson.core:jackson-annotations:2.14.2')
shadow('com.fasterxml.jackson.core:jackson-databind:2.14.2')
shadow('com.fasterxml.jackson.core:jackson-core:2.15.0-rc1')
shadow('com.fasterxml.jackson.core:jackson-annotations:2.15.0-rc1')
shadow('com.fasterxml.jackson.core:jackson-databind:2.15.0-rc1')

// Thank you georgeagostino for fixing my garbage
// if (getProject().hasProperty("altoclef.development")) {
// Must run build from baritone-plus once
modImplementation 'baritone-api-fabric:baritone-fabric-unoptimized-1.19.3-beta1'
include "baritone-api-fabric:baritone-fabric-unoptimized-1.19.3-beta1"
modImplementation 'baritone-api-fabric:baritone-unoptimized-fabric-1.19.4-beta1'
include "baritone-api-fabric:baritone-unoptimized-fabric-1.19.4-beta1"
//} else {
// modImplementation "cabaletta:baritone-unoptimized-fabric:1.18.2"
// include "cabaletta:baritone-unoptimized-fabric:1.18.2"
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ org.gradle.caching=true
org.gradle.warning.mode=all
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.17
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.18
# Mod Properties
mod_version=1.19.3-beta2
mod_version=1.19.4-beta1
maven_group=gaucho-matrero.altoclef
archives_base_name=altoclef
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.75.1+1.19.3
fabric_version=0.76.0+1.19.4
1 change: 1 addition & 0 deletions src/main/java/adris/altoclef/AltoClef.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ private void onClientRenderOverlay(MatrixStack matrixStack) {
}

private void initializeBaritoneSettings() {
getExtraBaritoneSettings().canWalkOnEndPortal(false);
getClientBaritoneSettings().freeLook.value = false;
getClientBaritoneSettings().overshootTraverse.value = false;
getClientBaritoneSettings().allowOvershootDiagonalDescend.value = true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/adris/altoclef/control/SlotHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void forceDeequipRightClickableItem() {
|| item instanceof OnAStickItem
|| item == Items.COMPASS
|| item instanceof EmptyMapItem
|| item instanceof Wearable
|| item instanceof Equipment
|| item == Items.LEAD
|| item == Items.SHIELD;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;

import java.util.List;
import java.util.Optional;
Expand All @@ -31,21 +32,22 @@ public class LocateStrongholdCoordinatesTask extends Task {
private LocateStrongholdCoordinatesTask.EyeDirection _cachedEyeDirection = null;
private LocateStrongholdCoordinatesTask.EyeDirection _cachedEyeDirection2 = null;
private Entity _currentThrownEye = null;
private Vec3d _strongholdEstimatePos = null;
private Vec3i _strongholdEstimatePos = null;

public LocateStrongholdCoordinatesTask(int targetEyes) {
_targetEyes = targetEyes;
}

@SuppressWarnings("UnnecessaryLocalVariable")
static Vec3d calculateIntersection(Vec3d start1, Vec3d direction1, Vec3d start2, Vec3d direction2) {
static Vec3i calculateIntersection(Vec3d start1, Vec3d direction1, Vec3d start2, Vec3d direction2) {
Vec3d s1 = start1;
Vec3d s2 = start2;
Vec3d d1 = direction1;
Vec3d d2 = direction2;
// Solved for s1 + d1 * t1 = s2 + d2 * t2
double t2 = ((d1.z * s2.x) - (d1.z * s1.x) - (d1.x * s2.z) + (d1.x * s1.z)) / ((d1.x * d2.z) - (d1.z * d2.x));
return start2.add(direction2.multiply(t2));
BlockPos blockPos = BlockPos.ofFloored(start2.add(direction2.multiply(t2)));
return new Vec3i(blockPos.getX(), blockPos.getY(), blockPos.getZ());
}

@Override
Expand Down Expand Up @@ -114,14 +116,14 @@ protected Task onTick(AltoClef mod) {


_strongholdEstimatePos = calculateIntersection(throwOrigin, throwDelta, throwOrigin2, throwDelta2); // stronghold estimate
Debug.logMessage("Stronghold is at " + (int) _strongholdEstimatePos.getX() + ", " + (int) _strongholdEstimatePos.getZ() + " (" + (int) mod.getPlayer().getPos().distanceTo(_strongholdEstimatePos) + " blocks away)");
Debug.logMessage("Stronghold is at " + (int) _strongholdEstimatePos.getX() + ", " + (int) _strongholdEstimatePos.getZ() + " (" + (int) mod.getPlayer().getPos().distanceTo(Vec3d.of(_strongholdEstimatePos)) + " blocks away)");
}
}


// Re-throw the eyes after reaching the estimation to get a more accurate estimate of where the stronghold is.
if (_strongholdEstimatePos != null) {
if (((mod.getPlayer().getPos().distanceTo(_strongholdEstimatePos) < EYE_RETHROW_DISTANCE) && WorldHelper.getCurrentDimension() == Dimension.OVERWORLD)) {
if (((mod.getPlayer().getPos().distanceTo(Vec3d.of(_strongholdEstimatePos)) < EYE_RETHROW_DISTANCE) && WorldHelper.getCurrentDimension() == Dimension.OVERWORLD)) {
_strongholdEstimatePos = null;
_cachedEyeDirection = null;
_cachedEyeDirection2 = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
Expand Down Expand Up @@ -99,13 +99,15 @@ private static boolean isFallDeadly(BlockPos pos) {
}

private static double calculateFallDamageToLandOn(BlockPos pos) {
ClientWorld world = MinecraftClient.getInstance().world;
PlayerEntity player = MinecraftClient.getInstance().player;
assert player != null;
double totalFallDistance = player.fallDistance + (player.getY() - pos.getY() - 1);
// Copied from living entity I think, somewhere idk you get the picture.
double baseFallDamage = MathHelper.ceil(totalFallDistance - 3.0F);
// Be a bit conservative, assume MORE damage
return EntityHelper.calculateResultingPlayerDamage(player, DamageSource.FALL, baseFallDamage);
assert world != null;
return EntityHelper.calculateResultingPlayerDamage(player, world.getDamageSources().fall(), baseFallDamage);
}

private static void moveLeftRight(AltoClef mod, int delta) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ private BlockPos doSimpleSearchForEndPortal(AltoClef mod) {
Vec3d average = frames.stream()
.reduce(Vec3d.ZERO, (accum, bpos) -> accum.add(bpos.getX() + 0.5, bpos.getY() + 0.5, bpos.getZ() + 0.5), Vec3d::add)
.multiply(1.0f / frames.size());
return new BlockPos(average.x, average.y, average.z);
return new BlockPos((int) average.x, (int) average.y, (int) average.z);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ Get in position (XZ)
return null;
}
// Wait for dragon head to be close enough to the bed's head...
BlockPos bedHead = WorldHelper.getBedHead(mod, bedTargetPosition);
assert bedHead != null;
BlockPos bedfoot = WorldHelper.getBedFoot(mod, bedTargetPosition);
assert bedfoot != null;
Vec3d headPos = dragon.head.getBoundingBox().getCenter(); // dragon.head.getPos();
double dist = headPos.distanceTo(WorldHelper.toVec3d(bedHead));
double dist = headPos.distanceTo(WorldHelper.toVec3d(bedfoot));
Debug.logMessage("Dist: " + dist);
if (dist < BeatMinecraft2Task.getConfig().dragonHeadCloseEnoughClickBedRange) {
// Interact with the bed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import adris.altoclef.util.helpers.*;
import adris.altoclef.util.slots.Slot;
import adris.altoclef.util.time.TimerGame;
import baritone.api.utils.input.Input;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
Expand All @@ -42,7 +41,6 @@
import net.minecraft.nbt.NbtElement;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.biome.BiomeKeys;
import org.apache.commons.lang3.ArrayUtils;
Expand Down Expand Up @@ -293,6 +291,7 @@ private List<Item> lootableItems(AltoClef mod) {

@Override
protected void onStop(AltoClef mod, Task interruptTask) {
mod.getExtraBaritoneSettings().canWalkOnEndPortal(false);
mod.getBehaviour().pop();
mod.getBlockTracker().stopTracking(ItemHelper.itemsToBlocks(ItemHelper.BED));
mod.getBlockTracker().stopTracking(TRACK_BLOCKS);
Expand All @@ -315,7 +314,7 @@ private boolean endPortalFound(AltoClef mod, BlockPos endPortalCenter) {
if (endPortalOpened(mod, endPortalCenter)) {
return true;
}
return getFrameBlocks(endPortalCenter).stream().allMatch(frame -> mod.getBlockTracker().blockIsValid(frame, Blocks.END_PORTAL_FRAME));
return getFrameBlocks(endPortalCenter).stream().anyMatch(frame -> mod.getBlockTracker().blockIsValid(frame, Blocks.END_PORTAL_FRAME));
}

private boolean endPortalOpened(AltoClef mod, BlockPos endPortalCenter) {
Expand Down Expand Up @@ -826,6 +825,9 @@ protected Task onTick(AltoClef mod) {
setDebugState("WOOHOO");
_dragonIsDead = true;
_enterindEndPortal = true;
if (!mod.getExtraBaritoneSettings().isCanWalkOnEndPortal()) {
mod.getExtraBaritoneSettings().canWalkOnEndPortal(true);
}
return new DoToClosestBlockTask(
blockPos -> new GetToBlockTask(blockPos.up()),
Blocks.END_PORTAL
Expand Down Expand Up @@ -1047,7 +1049,9 @@ protected Task onTick(AltoClef mod) {
// We're as ready as we'll ever be, hop into the portal!
setDebugState("Entering End");
_enterindEndPortal = true;
mod.getInputControls().tryPress(Input.MOVE_FORWARD);
if (!mod.getExtraBaritoneSettings().isCanWalkOnEndPortal()) {
mod.getExtraBaritoneSettings().canWalkOnEndPortal(true);
}
return new DoToClosestBlockTask(
blockPos -> new GetToBlockTask(blockPos.up()),
Blocks.END_PORTAL
Expand Down Expand Up @@ -1247,14 +1251,13 @@ private BlockPos doSimpleSearchForEndPortal(AltoClef mod) {
List<BlockPos> frames = mod.getBlockTracker().getKnownLocations(Blocks.END_PORTAL_FRAME);
if (frames.size() >= END_PORTAL_FRAME_COUNT) {
// Get the center of the frames.
Vec3d average = frames.stream()
.reduce(Vec3d.ZERO, (accum, bpos) -> accum.add(bpos.getX() + 0.5, bpos.getY() + 0.5, bpos.getZ() + 0.5), Vec3d::add)
.multiply(1.0f / frames.size());
return new BlockPos(average.x, average.y, average.z);
Vec3i average = frames.stream()
.reduce(Vec3i.ZERO, (accum, bpos) -> accum.add((int) Math.round(bpos.getX() + 0.5), (int) Math.round(bpos.getY() + 0.5), (int) Math.round(bpos.getZ() + 0.5)), Vec3i::add)
.multiply(1 / frames.size());
return new BlockPos(average);
}
return null;
}

private int getFilledPortalFrames(AltoClef mod, BlockPos endPortalCenter) {
// If we have our end portal, this doesn't matter.
if (endPortalFound(mod, endPortalCenter)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import adris.altoclef.Debug;
import adris.altoclef.TaskCatalogue;
import adris.altoclef.tasks.entity.DoToClosestEntityTask;
import adris.altoclef.tasks.entity.KillEntitiesTask;
import adris.altoclef.tasks.movement.GetToXZTask;
import adris.altoclef.tasks.movement.GetToYTask;
import adris.altoclef.tasks.movement.RunAwayFromPositionTask;
Expand All @@ -17,6 +18,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.decoration.EndCrystalEntity;
import net.minecraft.entity.mob.EndermanEntity;
import net.minecraft.entity.projectile.DragonFireballEntity;
import net.minecraft.item.Items;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -70,6 +72,17 @@ protected void onStart(AltoClef mod) {

@Override
protected Task onTick(AltoClef mod) {
Iterable<Entity> entities = mod.getWorld().getEntities();
if (entities != null) {
for (Entity entity : entities) {
if (entity instanceof EndermanEntity enderman) {
if (enderman.isAngryAt(mod.getPlayer()) && enderman.isAngry()) {
setDebugState("Kill angry enderman first.");
return new KillEntitiesTask(enderman.getClass());
}
}
}
}
if (_throwPearlTask != null && _throwPearlTask.isActive() && !_throwPearlTask.isFinished(mod)) {
setDebugState("Throwing pearl!");
return _throwPearlTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.registry.DynamicRegistryManager;

import java.util.*;
import java.util.stream.Collectors;
Expand All @@ -21,7 +22,7 @@ private static void reloadRecipeMapping() {
RecipeManager recipes = MinecraftClient.getInstance().getNetworkHandler().getRecipeManager();
if (recipes != null) {
for (Recipe<?> recipe : recipes.values()) {
Item output = recipe.getOutput().getItem();
Item output = recipe.getOutput(DynamicRegistryManager.EMPTY).getItem();
if (!_recipeMapping.containsKey(output)) {
_recipeMapping.put(output, new ArrayList<>());
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/adris/altoclef/util/helpers/EntityHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageTypes;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.mob.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.tag.DamageTypeTags;

/**
* Helper functions to interpret entity state
Expand Down Expand Up @@ -67,14 +69,14 @@ public static double calculateResultingPlayerDamage(PlayerEntity player, DamageS
return 0;

// Armor Base
if (!source.bypassesArmor()) {
if (!source.isIn(DamageTypeTags.BYPASSES_ARMOR)) {
damageAmount = DamageUtil.getDamageLeft((float) damageAmount, (float) player.getArmor(), (float) player.getAttributeValue(EntityAttributes.GENERIC_ARMOR_TOUGHNESS));
}

// Enchantments & Potions
if (!source.isUnblockable()) {
if (!source.isIn(DamageTypeTags.BYPASSES_SHIELD)) {
int k;
if (player.hasStatusEffect(StatusEffects.RESISTANCE) && source != DamageSource.OUT_OF_WORLD) {
if (player.hasStatusEffect(StatusEffects.RESISTANCE) && source.isOf(DamageTypes.OUT_OF_WORLD)) {
//noinspection ConstantConditions
k = (player.getStatusEffect(StatusEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - k;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/adris/altoclef/util/helpers/LookHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ private static boolean isCollidingInteractable(AltoClef mod) {
HitResult result = MinecraftClient.getInstance().crosshairTarget;
if (result == null) return false;
if (result.getType() == HitResult.Type.BLOCK) {
return WorldHelper.isInteractableBlock(mod, new BlockPos(result.getPos()));
Vec3i resultGetPosOrigin = new Vec3i((int) result.getPos().getX(), (int) result.getPos().getY(), (int) result.getPos().getZ());
return WorldHelper.isInteractableBlock(mod, new BlockPos(resultGetPosOrigin));
} else if (result.getType() == HitResult.Type.ENTITY) {
if (result instanceof EntityHitResult) {
Entity entity = ((EntityHitResult) result).getEntity();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/adris/altoclef/util/helpers/WorldHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ static Vec3d toVec3d(Vec3i pos) {
}

static Vec3i toVec3i(Vec3d pos) {
return new Vec3i(pos.getX(), pos.getY(), pos.getZ());
return new Vec3i((int) pos.getX(), (int) pos.getY(), (int) pos.getZ());
}

static BlockPos toBlockPos(Vec3d pos) {
return new BlockPos(pos.getX(), pos.getY(), pos.getZ());
return new BlockPos((int) pos.getX(), (int) pos.getY(), (int) pos.getZ());
}

static boolean isSourceBlock(AltoClef mod, BlockPos pos, boolean onlyAcceptStill) {
Expand Down Expand Up @@ -315,8 +315,8 @@ static Iterable<BlockPos> getBlocksTouchingPlayer(AltoClef mod) {
}

static Iterable<BlockPos> getBlocksTouchingBox(AltoClef mod, Box box) {
BlockPos min = new BlockPos(box.minX, box.minY, box.minZ);
BlockPos max = new BlockPos(box.maxX, box.maxY, box.maxZ);
BlockPos min = new BlockPos((int) box.minX, (int) box.minY, (int) box.minZ);
BlockPos max = new BlockPos((int) box.maxX, (int) box.maxY, (int) box.maxZ);
return scanRegion(mod, min, max);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "altoclef",
"version": "1.19.3-beta2",
"version": "1.19.4-beta1",
"name": "Alto Clef",
"description": "Plays Block Game",
"authors": [
Expand Down

0 comments on commit 98c8492

Please sign in to comment.