Skip to content

Commit

Permalink
Additions:
Browse files Browse the repository at this point in the history
1. @ coverwithsand (Cover lava with sands in nether).
2. @ coverwithblocks (Cover lava with blocks in nether).
3. @ meat (Get food that consists only of meat, without any vegetables).

Fixes:
1. ConcurrentModificationException
2. Fixed compatibility between meteor client.
3. Some fixes.

Improvements:
1. Some improvements.
  • Loading branch information
MarvionKirito committed Mar 12, 2023
1 parent 0ec5a5e commit 12111aa
Show file tree
Hide file tree
Showing 60 changed files with 1,597 additions and 973 deletions.
4 changes: 1 addition & 3 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 '7.1.2'
id 'com.github.johnrengelman.shadow' version '8.1.0'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -56,7 +56,6 @@ dependencies {
}
shadowJar {
configurations = [project.configurations.shadow]
classifier = 'shadow'
}

remapJar {
Expand Down Expand Up @@ -90,7 +89,6 @@ tasks.withType(JavaCompile) {
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ org.gradle.warning.mode=all
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.14
loader_version=0.14.17
# Mod Properties
mod_version=1.19.3-beta1
mod_version=1.19.3-beta2
maven_group=gaucho-matrero.altoclef
archives_base_name=altoclef
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.73.2+1.19.3
fabric_version=0.75.1+1.19.3
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 3 additions & 1 deletion src/main/java/adris/altoclef/AltoClefCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ public AltoClefCommands() throws CommandException {
new StopCommand(),
new TestCommand(),
new FoodCommand(),
new MeatCommand(),
new ReloadSettingsCommand(),
new GamerCommand(),
new MarvionCommand(),
new PunkCommand(),
new HeroCommand(),
new SetGammaCommand(),
new ListCommand(),
new CoverWithSandCommand()
new CoverWithSandCommand(),
new CoverWithBlocksCommand()
//new TestMoveInventoryCommand(),
// new TestSwapInventoryCommand()
);
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/adris/altoclef/BotBehaviour.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ public void setExclusivelyMineLogs(boolean value) {
}

public boolean shouldExcludeFromForcefield(Entity entity) {
for (Predicate<Entity> pred : current().excludeFromForceField) {
if (pred.test(entity)) return true;
if (!current().excludeFromForceField.isEmpty()) {
for (Predicate<Entity> pred : current().excludeFromForceField) {
if (pred.test(entity)) return true;
}
}
return false;
}
Expand Down Expand Up @@ -211,8 +213,10 @@ public void addGlobalHeuristic(BiFunction<Double, BlockPos, Double> heuristic) {
}

public boolean shouldAvoidDodgingProjectile(Entity entity) {
for (Predicate<Entity> test : current().avoidDodgingProjectile) {
if (test.test(entity)) return true;
if (!current().avoidDodgingProjectile.isEmpty()) {
for (Predicate<Entity> test : current().avoidDodgingProjectile) {
if (test.test(entity)) return true;
}
}
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/adris/altoclef/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,10 @@ public Item[] getSupportedFuelItems() {
}

public boolean isPositionExplicitlyProtected(BlockPos pos) {
for (BlockRange protection : areasToProtect) {
if (protection.contains(pos)) return true;
if (!areasToProtect.isEmpty()) {
for (BlockRange protection : areasToProtect) {
if (protection.contains(pos)) return true;
}
}
return false;
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/adris/altoclef/chains/FoodChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ private void startEat(AltoClef mod, Item food) {
mod.getInputControls().hold(Input.CLICK_RIGHT);
mod.getExtraBaritoneSettings().setInteractionPaused(true);
}

private void stopEat(AltoClef mod) {
if (_isTryingToEat) {
if (mod.getItemStorage().hasItem(Items.SHIELD) || mod.getItemStorage().hasItemInOffhand(Items.SHIELD)) {
Expand All @@ -73,6 +72,10 @@ private void stopEat(AltoClef mod) {
}
}

public boolean isTryingToEat() {
return _isTryingToEat;
}

@Override
public float getPriority(AltoClef mod) {
if (WorldHelper.isInNetherPortal(mod)) {
Expand Down
258 changes: 143 additions & 115 deletions src/main/java/adris/altoclef/chains/MobDefenseChain.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public float getPriority(AltoClef mod) {
if (bestToolSlot.isPresent() && !bestToolSlot.get().equals(currentEquipped)) {
// ONLY equip if the item class is STRICTLY different (otherwise we swap around a lot)
if (StorageHelper.getItemStackInSlot(currentEquipped).getItem() != StorageHelper.getItemStackInSlot(bestToolSlot.get()).getItem()) {
boolean isAllowedToManage = !mod.getClientBaritone().getPathingBehavior().isPathing() || bestToolSlot.get().getInventorySlot() >= 9;
boolean isAllowedToManage = (!mod.getClientBaritone().getPathingBehavior().isPathing() ||
bestToolSlot.get().getInventorySlot() >= 9) && !mod.getFoodChain().isTryingToEat();
if (isAllowedToManage) {
Debug.logMessage("Found better tool in inventory, equipping.");
ItemStack bestToolItemStack = StorageHelper.getItemStackInSlot(bestToolSlot.get());
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/adris/altoclef/chains/SingleTaskChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public boolean isActive() {

@Override
public void onInterrupt(AltoClef mod, TaskChain other) {
Debug.logInternal("Chain Interrupted: " + this + " by " + other.toString());
if (other != null) {
Debug.logInternal("Chain Interrupted: " + this + " by " + other);
}
// Stop our task. When we're started up again, let our task know we need to run.
_interrupted = true;
if (_mainTask != null && _mainTask.isActive()) {
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/adris/altoclef/commands/CoverWithBlocksCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package adris.altoclef.commands;

import adris.altoclef.AltoClef;
import adris.altoclef.commandsystem.ArgParser;
import adris.altoclef.commandsystem.Command;
import adris.altoclef.commandsystem.CommandException;
import adris.altoclef.tasks.construction.CoverWithBlocksTask;

public class CoverWithBlocksCommand extends Command {
public CoverWithBlocksCommand() {
super("coverwithblocks", "Cover nether lava with blocks.");
}

@Override
protected void call(AltoClef mod, ArgParser parser) throws CommandException {
mod.runUserTask(new CoverWithBlocksTask(), this::finish);
}
}
2 changes: 1 addition & 1 deletion src/main/java/adris/altoclef/commands/FoodCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class FoodCommand extends Command {
public FoodCommand() throws CommandException {
super("food", "Collects a certain amount of food", new Arg(Integer.class, "count"));
super("food", "Collects a certain amount of food", new Arg<>(Integer.class, "count"));
}

@Override
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/adris/altoclef/commands/MeatCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package adris.altoclef.commands;

import adris.altoclef.AltoClef;
import adris.altoclef.commandsystem.Arg;
import adris.altoclef.commandsystem.ArgParser;
import adris.altoclef.commandsystem.Command;
import adris.altoclef.commandsystem.CommandException;
import adris.altoclef.tasks.resources.CollectMeatTask;

public class MeatCommand extends Command {
public MeatCommand() throws CommandException {
super("meat", "Collects a certain amount of meat", new Arg<>(Integer.class, "count"));
}

@Override
protected void call(AltoClef mod, ArgParser parser) throws CommandException {
mod.runUserTask(new CollectMeatTask(parser.get(Integer.class)), this::finish);
}
}
30 changes: 17 additions & 13 deletions src/main/java/adris/altoclef/control/KillAura.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,27 @@ private void attack(AltoClef mod, Entity entity, boolean equipSword) {
}

public void startShielding(AltoClef mod) {
ItemStack handItem = StorageHelper.getItemStackInSlot(PlayerSlot.getEquipSlot());
ItemStack cursor = StorageHelper.getItemStackInCursorSlot();
if (handItem.isFood()) {
mod.getSlotHandler().clickSlot(PlayerSlot.getEquipSlot(), 0, SlotActionType.PICKUP);
}
if (cursor.isFood()) {
Optional<Slot> toMoveTo = mod.getItemStorage().getSlotThatCanFitInPlayerInventory(cursor, false).or(() -> StorageHelper.getGarbageSlot(mod));
if (toMoveTo.isPresent()) {
Slot garbageSlot = toMoveTo.get();
mod.getSlotHandler().clickSlot(garbageSlot, 0, SlotActionType.PICKUP);
}
}
_shielding = true;
mod.getInputControls().hold(Input.SNEAK);
mod.getInputControls().hold(Input.CLICK_RIGHT);
mod.getClientBaritone().getPathingBehavior().softCancelIfSafe();
_shielding = true;
mod.getExtraBaritoneSettings().setInteractionPaused(true);
if (!mod.getPlayer().isBlocking()) {
ItemStack handItem = StorageHelper.getItemStackInSlot(PlayerSlot.getEquipSlot());
if (handItem.isFood()) {
List<ItemStack> spaceSlots = mod.getItemStorage().getItemStacksPlayerInventory(false);
if (!spaceSlots.isEmpty()) {
for (ItemStack spaceSlot : spaceSlots) {
if (spaceSlot.isEmpty()) {
mod.getSlotHandler().clickSlot(PlayerSlot.getEquipSlot(), 0, SlotActionType.QUICK_MOVE);
return;
}
}
}
Optional<Slot> garbage = StorageHelper.getGarbageSlot(mod);
garbage.ifPresent(slot -> mod.getSlotHandler().forceEquipItem(StorageHelper.getItemStackInSlot(slot).getItem()));
}
}
}

public void stopShielding(AltoClef mod) {
Expand Down
23 changes: 12 additions & 11 deletions src/main/java/adris/altoclef/control/SlotHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ public void forceEquipItemToOffhand(Item toEquip) {
}
List<Slot> currentItemSlot = _mod.getItemStorage().getSlotsWithItemPlayerInventory(false,
toEquip);
Slot itemInSlot = currentItemSlot.get(0);
if (!Slot.isCursor(itemInSlot)) {
_mod.getSlotHandler().clickSlot(itemInSlot, 0, SlotActionType.PICKUP);
} else {
_mod.getSlotHandler().clickSlot(PlayerSlot.OFFHAND_SLOT, 0, SlotActionType.PICKUP);
for (Slot CurrentItemSlot : currentItemSlot) {
if (!Slot.isCursor(CurrentItemSlot)) {
_mod.getSlotHandler().clickSlot(CurrentItemSlot, 0, SlotActionType.PICKUP);
} else {
_mod.getSlotHandler().clickSlot(PlayerSlot.OFFHAND_SLOT, 0, SlotActionType.PICKUP);
}
}
}

Expand All @@ -111,14 +112,14 @@ public boolean forceEquipItem(Item toEquip) {

List<Slot> itemSlots = _mod.getItemStorage().getSlotsWithItemScreen(toEquip);
if (itemSlots.size() != 0) {
Slot slot = itemSlots.get(0);
int hotbar = 1;
//_mod.getPlayer().getInventory().swapSlotWithHotbar();
clickSlotForce(Objects.requireNonNull(slot), inCursor ? 0 : hotbar, inCursor ? SlotActionType.PICKUP : SlotActionType.SWAP);
//registerSlotAction();
for (Slot ItemSlots : itemSlots) {
int hotbar = 1;
//_mod.getPlayer().getInventory().swapSlotWithHotbar();
clickSlotForce(Objects.requireNonNull(ItemSlots), inCursor ? 0 : hotbar, inCursor ? SlotActionType.PICKUP : SlotActionType.SWAP);
//registerSlotAction();
}
return true;
}

return false;
}

Expand Down
12 changes: 8 additions & 4 deletions src/main/java/adris/altoclef/tasks/CraftInInventoryTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ protected Task onResourceTick(AltoClef mod) {
if (StorageHelper.isPlayerInventoryOpen()) {
if (StorageHelper.getItemStackInCursorSlot().isEmpty()) {
Item outputItem = StorageHelper.getItemStackInSlot(PlayerSlot.CRAFT_OUTPUT_SLOT).getItem();
for (ItemTarget target : _itemTargets) {
if (target.matches(outputItem)) {
return new ReceiveCraftingOutputSlotTask(PlayerSlot.CRAFT_OUTPUT_SLOT, target.getTargetCount());
if (_itemTargets != null) {
for (ItemTarget target : _itemTargets) {
if (target.matches(outputItem)) {
return new ReceiveCraftingOutputSlotTask(PlayerSlot.CRAFT_OUTPUT_SLOT, target.getTargetCount());
}
}
}
}
Expand Down Expand Up @@ -98,7 +100,9 @@ protected void onResourceStop(AltoClef mod, Task interruptTask) {
if (!cursorStack.isEmpty()) {
List<Slot> moveTo = mod.getItemStorage().getSlotsThatCanFitInPlayerInventory(cursorStack, false);
if (!moveTo.isEmpty()) {
mod.getSlotHandler().clickSlot(moveTo.get(0), 0, SlotActionType.PICKUP);
for (Slot MoveTo : moveTo) {
mod.getSlotHandler().clickSlot(MoveTo, 0, SlotActionType.PICKUP);
}
} else {
Optional<Slot> garbageSlot = StorageHelper.getGarbageSlot(mod);
if (garbageSlot.isPresent()) {
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/adris/altoclef/tasks/InteractWithBlockTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ private static Goal createGoalForInteract(BlockPos target, int reachDistance, Di
}

private boolean isAnnoying(AltoClef mod, BlockPos pos) {
for (Block AnnoyingBlocks : annoyingBlocks) {
return mod.getWorld().getBlockState(pos).getBlock() == AnnoyingBlocks ||
mod.getWorld().getBlockState(pos).getBlock() instanceof DoorBlock ||
mod.getWorld().getBlockState(pos).getBlock() instanceof FenceBlock ||
mod.getWorld().getBlockState(pos).getBlock() instanceof FenceGateBlock ||
mod.getWorld().getBlockState(pos).getBlock() instanceof FlowerBlock;
if (annoyingBlocks != null) {
for (Block AnnoyingBlocks : annoyingBlocks) {
return mod.getWorld().getBlockState(pos).getBlock() == AnnoyingBlocks ||
mod.getWorld().getBlockState(pos).getBlock() instanceof DoorBlock ||
mod.getWorld().getBlockState(pos).getBlock() instanceof FenceBlock ||
mod.getWorld().getBlockState(pos).getBlock() instanceof FenceGateBlock ||
mod.getWorld().getBlockState(pos).getBlock() instanceof FlowerBlock;
}
}
return false;
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/adris/altoclef/tasks/ResourceTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ protected String toDebugString() {
StringBuilder result = new StringBuilder();
result.append(toDebugStringName()).append(": [");
int c = 0;
for (ItemTarget target : _itemTargets) {
result.append(target != null ? target.toString() : "(null)");
if (++c != _itemTargets.length) {
result.append(", ");
if (_itemTargets != null) {
for (ItemTarget target : _itemTargets) {
result.append(target != null ? target.toString() : "(null)");
if (++c != _itemTargets.length) {
result.append(", ");
}
}
}
result.append("]");
Expand Down
Loading

0 comments on commit 12111aa

Please sign in to comment.