Skip to content

Commit

Permalink
Merge pull request #1946 from CDAGaming/1.16.2
Browse files Browse the repository at this point in the history
✔️ 1.16.1 -> 1.16.2
  • Loading branch information
leijurv authored Aug 18, 2020
2 parents 3f3358d + 0b9bb9d commit 0102ce8
Show file tree
Hide file tree
Showing 31 changed files with 281 additions and 65 deletions.
31 changes: 31 additions & 0 deletions .gitmessage
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<emoji> <title> (<ticket>)

# 📝 Update README.md (WD-1234)
# ✅ Add unit test for inputs (WD-1234)

# <emoji> can be:
# 🎨 :art: when improving structure of the code
# ⚡️ :zap: when improving performance
# 🔥 :fire: when removing code or files
# ✨ :sparkles: when introducing new features
# 🚧 :construction: when work in progress
# 🔨 :hammer: when refactoring code
# 📝 :memo: when writing docs
# 💄 :lipstick: when updating the UI and style files
# 📈 :chart_with_upwards_trend: when adding analytics or tracking code
# 🌐 :globe_with_meridians: when adding internationalization and localization
# ✏️ :pencil2: when fixing typos
# 🚚 :truck: when moving or renaming files
# ✅ :white_check_mark: when adding tests

# 👌 :ok_hand: when updating code due to code review changes
# 🐛 :bug: when fixing a bug
# 🚑 :ambulance: when doing a critical hotfix
# 🚨 :rotating_light: when removing linter warnings

# 🔀 :twisted_rightwards_arrows: when merging branches
# ⬆️ :arrow_up: when upgrading dependencies
# ⬇️ :arrow_down: when downgrading dependencies
# 🔧 :wrench: when changing configuration files
# 🔖 :bookmark: when releasing / version tagging
# 💚 :green_heart: when fixing the CI build
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ For 1.15.2, [click here](https://www.youtube.com/watch?v=j1qKtCZFURM) and see de
This project is an updated version of [MineBot](https://github.com/leijurv/MineBot/),
the original version of the bot for Minecraft 1.8.9, rebuilt for 1.12.2 through 1.15.2. Baritone focuses on reliability and particularly performance (it's over [30x faster](https://github.com/cabaletta/baritone/pull/180#issuecomment-423822928) than MineBot at calculating paths).

Have committed at least once a day from Aug 1 2018 to Aug 1 2019.
Have committed at least once a day from Aug 1, 2018, to Aug 1, 2019.

1Leijurv3DWTrGAfmmiTphjhXLvQiHg7K2

Expand Down Expand Up @@ -71,7 +71,7 @@ The API is heavily documented, you can find the Javadocs for the latest release
Please note that usage of anything located outside of the ``baritone.api`` package is not supported by the API release
jar.

Below is an example of basic usage for changing some settings, and then pathing to a X/Z goal.
Below is an example of basic usage for changing some settings, and then pathing to an X/Z goal.

```
BaritoneAPI.getSettings().allowSprint.value = true;
Expand All @@ -84,7 +84,7 @@ BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAnd

## Can I use Baritone as a library in my custom utility client?

That's what it's for, sure! (As long as usage is in compliance with the LGPL 3.0 License)
That's what it's for, sure! (As long as usage complies with the LGPL 3.0 License)

## How is it so fast?

Expand Down
13 changes: 9 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

group 'baritone'
version '1.6.1'
version '1.6.2'

buildscript {
repositories {
Expand All @@ -28,6 +28,9 @@ buildscript {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
}
jcenter()
}

Expand Down Expand Up @@ -85,7 +88,7 @@ task sourceJar(type: Jar, dependsOn: classes) {
}

minecraft {
mappings channel: 'snapshot', version: '20200723-1.16.1'
mappings channel: 'snapshot', version: '20200813-1.16.1'

if (getProject().hasProperty("baritone.forge_build")) {
reobfMappings 'searge'
Expand Down Expand Up @@ -138,15 +141,17 @@ repositories {
name = 'spongepowered-repo'
url = 'http://repo.spongepowered.org/maven/'
}

maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
}
}

dependencies {
minecraft 'com.github.ImpactDevelopment:Vanilla:1.16.1'
minecraft 'com.github.ImpactDevelopment:Vanilla:1.16.2'

runtime launchCompile('net.minecraft:launchwrapper:1.12') {
exclude module: 'lwjgl'
Expand Down
7 changes: 7 additions & 0 deletions scripts/proguard.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@

-keep class baritone.api.utils.MyChunkPos { *; } # even in standalone we need to keep this for gson reflect

# Keep any class or member annotated with @KeepName so we dont have to put everything in the script
-keep,allowobfuscation @interface baritone.KeepName
-keep @baritone.KeepName class *
-keepclassmembers class * {
@baritone.KeepName *;
}

# setting names are reflected from field names, so keep field names
-keepclassmembers class baritone.api.Settings {
public <fields>;
Expand Down
54 changes: 53 additions & 1 deletion src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ public final class Settings {
*/
public final Setting<Boolean> allowInventory = new Setting<>(false);

/**
* Disable baritone's auto-tool at runtime, but still assume that another mod will provide auto tool functionality
* <p>
* Specifically, path calculation will still assume that an auto tool wil run at execution time, even though
* Baritone itself will not do that.
*/
public final Setting<Boolean> assumeExternalAutoTool = new Setting<>(false);

/**
* If this setting is on, no auto tool will occur at all, not at calculation time nor execution time
*/
public final Setting<Boolean> disableAutoTool = new Setting<>(false);

/**
* It doesn't actually take twenty ticks to place a block, this cost is so high
* because we want to generally conserve blocks which might be limited.
Expand Down Expand Up @@ -190,6 +203,15 @@ public final class Settings {

)));

/**
* A list of blocks to become air
* <p>
* If a schematic asks for a block on this list, only air will be accepted at that location (and nothing on buildIgnoreBlocks)
*/
public final Setting<List<Block>> okIfAir = new Setting<>(new ArrayList<>(Arrays.asList(

)));

/**
* If this is true, the builder will treat all non-air blocks as correct. It will only place new blocks.
*/
Expand Down Expand Up @@ -432,6 +454,11 @@ public final class Settings {
*/
public final Setting<Boolean> simplifyUnloadedYCoord = new Setting<>(true);

/**
* Whenever a block changes, repack the whole chunk that it's in
*/
public final Setting<Boolean> repackOnAnyBlockChange = new Setting<>(true);

/**
* If a movement takes this many ticks more than its initial cost estimate, cancel it
*/
Expand Down Expand Up @@ -1060,10 +1087,35 @@ public final class Settings {
public final Setting<Boolean> renderSelectionCorners = new Setting<>(true);

/**
* Desktop Notifications
* Desktop notifications
*/
public final Setting<Boolean> desktopNotifications = new Setting<>(false);

/**
* Desktop notification on path complete
*/
public final Setting<Boolean> notificationOnPathComplete = new Setting<>(true);

/**
* Desktop notification on farm fail
*/
public final Setting<Boolean> notificationOnFarmFail = new Setting<>(true);

/**
* Desktop notification on build finished
*/
public final Setting<Boolean> notificationOnBuildFinished = new Setting<>(true);

/**
* Desktop notification on explore finished
*/
public final Setting<Boolean> notificationOnExploreFinished = new Setting<>(true);

/**
* Desktop notification on mine fail
*/
public final Setting<Boolean> notificationOnMineFail = new Setting<>(true);

/**
* A map of lowercase setting field names to their respective setting
*/
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/baritone/api/command/datatypes/BlockById.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum BlockById implements IDatatypeFor<Block> {
public Block get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
Block block;
if ((block = Registry.BLOCK.getValue(id).orElse(null)) == null) {
if ((block = Registry.BLOCK.func_241873_b(id).orElse(null)) == null) {
throw new IllegalArgumentException("no block found by that id");
}
return block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
public EntityType get(IDatatypeContext ctx) throws CommandException {
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
EntityType entity;
if ((entity = Registry.ENTITY_TYPE.getValue(id).orElse(null)) == null) {
if ((entity = Registry.ENTITY_TYPE.func_241873_b(id).orElse(null)) == null) {
throw new IllegalArgumentException("no entity found by that id");
}
return entity;
Expand Down
5 changes: 3 additions & 2 deletions src/api/java/baritone/api/utils/BlockOptionalMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Unit;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;

import javax.annotation.Nonnull;
import java.util.*;
Expand Down Expand Up @@ -132,7 +133,7 @@ public BlockState getAnyBlockState() {

public static LootTableManager getManager() {
if (manager == null) {
ResourcePackList<?> rpl = new ResourcePackList<>(ResourcePackInfo::new, new ServerPackFinder());
ResourcePackList rpl = new ResourcePackList(ResourcePackInfo::new, new ServerPackFinder());
rpl.reloadPacksFromFinders();
IResourcePack thePack = rpl.getAllPacks().iterator().next().getResourcePack();
IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
Expand Down Expand Up @@ -163,7 +164,7 @@ private static synchronized List<Item> drops(Block b) {
getManager().getLootTableFromLocation(lootTableLocation).generate(
new LootContext.Builder(null)
.withRandom(new Random())
.withParameter(LootParameters.POSITION, BlockPos.ZERO)
.withParameter(LootParameters.field_237457_g_, Vector3d.copy(BlockPos.NULL_VECTOR))
.withParameter(LootParameters.TOOL, ItemStack.EMPTY)
.withNullableParameter(LootParameters.BLOCK_ENTITY, null)
.withParameter(LootParameters.BLOCK_STATE, block.getDefaultState())
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/baritone/api/utils/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static Block stringToBlockNullable(String name) {
if (resourceCache.containsKey(name)) {
return null; // cached as null
}
block = Registry.BLOCK.getValue(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
block = Registry.BLOCK.func_241873_b(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name)).orElse(null);
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
copy.put(name, block);
resourceCache = copy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@

package baritone.launch.mixins;

import baritone.Baritone;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.ChunkEvent;
import baritone.api.event.events.type.EventState;
import baritone.cache.CachedChunk;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.network.play.server.SChangeBlockPacket;
import net.minecraft.network.play.server.SChunkDataPacket;
import net.minecraft.network.play.server.SCombatPacket;
import net.minecraft.network.play.server.SUnloadChunkPacket;
import net.minecraft.network.play.server.SMultiBlockChangePacket;
import net.minecraft.util.math.ChunkPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down Expand Up @@ -83,30 +87,58 @@ private void postHandleChunkData(SChunkDataPacket packetIn, CallbackInfo ci) {
}

@Inject(
method = "processChunkUnload",
at = @At("HEAD")
method = "handleBlockChange",
at = @At("RETURN")
)
private void preChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
private void postHandleBlockChange(SChangeBlockPacket packetIn, CallbackInfo ci) {
if (!Baritone.settings().repackOnAnyBlockChange.value) {
return;
}
if (!CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(packetIn.getState().getBlock())) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
new ChunkEvent(
EventState.POST,
ChunkEvent.Type.POPULATE_FULL,
packetIn.getPos().getX() >> 4,
packetIn.getPos().getZ() >> 4
)
);
}
}
}

@Inject(
method = "processChunkUnload",
method = "handleMultiBlockChange",
at = @At("RETURN")
)
private void postChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
private void postHandleMultiBlockChange(SMultiBlockChangePacket packetIn, CallbackInfo ci) {
if (!Baritone.settings().repackOnAnyBlockChange.value) {
return;
}
ChunkPos[] chunkPos = new ChunkPos[1];
packetIn.func_244310_a((pos, state) -> {
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(state.getBlock())) {
chunkPos[0] = new ChunkPos(pos);
}
});
if (chunkPos[0] == null) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
ClientPlayerEntity player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
new ChunkEvent(
EventState.POST,
ChunkEvent.Type.POPULATE_FULL,
chunkPos[0].x,
chunkPos[0].z
)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public class MixinCommandSuggestionHelper {

@Shadow
@Final
private TextFieldWidget field_228095_d_;
private TextFieldWidget inputField;

@Shadow
@Final
private List<String> field_228103_l_;
private List<String> exceptionList;

@Shadow
private CompletableFuture<Suggestions> suggestionsFuture;
Expand All @@ -61,7 +61,7 @@ public class MixinCommandSuggestionHelper {
)
private void preUpdateSuggestion(CallbackInfo ci) {
// Anything that is present in the input text before the cursor position
String prefix = this.field_228095_d_.getText().substring(0, Math.min(this.field_228095_d_.getText().length(), this.field_228095_d_.getCursorPosition()));
String prefix = this.inputField.getText().substring(0, Math.min(this.inputField.getText().length(), this.inputField.getCursorPosition()));

TabCompleteEvent event = new TabCompleteEvent(prefix);
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onPreTabComplete(event);
Expand All @@ -75,14 +75,14 @@ private void preUpdateSuggestion(CallbackInfo ci) {
ci.cancel();

// TODO: Support populating the command usage
this.field_228103_l_.clear();
this.exceptionList.clear();

if (event.completions.length == 0) {
this.suggestionsFuture = Suggestions.empty();
} else {
int offset = this.field_228095_d_.getText().endsWith(" ")
? this.field_228095_d_.getCursorPosition()
: this.field_228095_d_.getText().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes
int offset = this.inputField.getText().endsWith(" ")
? this.inputField.getCursorPosition()
: this.inputField.getText().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes

List<Suggestion> suggestionList = Stream.of(event.completions)
.map(s -> new Suggestion(StringRange.between(offset, offset + s.length()), s))
Expand Down
Loading

0 comments on commit 0102ce8

Please sign in to comment.