From b005ce8e6b18036802cd0233902194fff504f36c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Thu, 17 Jan 2019 18:54:37 -0800 Subject: [PATCH] mega cancer render cached chunks --- .../launch/mixins/MixinChunkCache.java | 46 +++++++++++++++++++ src/launch/resources/mixins.baritone.json | 1 + src/main/java/baritone/Baritone.java | 7 ++- .../java/baritone/event/GameEventHandler.java | 4 ++ 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/launch/java/baritone/launch/mixins/MixinChunkCache.java diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkCache.java b/src/launch/java/baritone/launch/mixins/MixinChunkCache.java new file mode 100644 index 00000000..17fefb6d --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinChunkCache.java @@ -0,0 +1,46 @@ +/* + * This file is part of Baritone. + * + * Baritone is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Baritone is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Baritone. If not, see . + */ + +package baritone.launch.mixins; + +import baritone.Baritone; +import baritone.api.BaritoneAPI; +import baritone.api.utils.IPlayerContext; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ChunkCache; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ChunkCache.class) +public class MixinChunkCache { + @Inject( + method = "getBlockState", + at = @At("HEAD"), + cancellable = true + ) + private void getBlockState(BlockPos pos, CallbackInfoReturnable ci) { + Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); + IPlayerContext ctx = baritone.getPlayerContext(); + if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { + ci.setReturnValue(baritone.bsi.get0(pos)); + //ci.setReturnValue(Blocks.DIRT.getDefaultState()); + } + } +} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 09ebbafd..eab28fdb 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -10,6 +10,7 @@ "client": [ "MixinAnvilChunkLoader", "MixinBlockPos", + "MixinChunkCache", "MixinChunkProviderClient", "MixinChunkProviderServer", "MixinEntity", diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index c3a8e272..3414fdf3 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -29,10 +29,7 @@ import baritone.process.CustomGoalProcess; import baritone.process.FollowProcess; import baritone.process.GetToBlockProcess; import baritone.process.MineProcess; -import baritone.utils.BaritoneAutoTest; -import baritone.utils.ExampleBaritoneControl; -import baritone.utils.InputOverrideHandler; -import baritone.utils.PathingControlManager; +import baritone.utils.*; import baritone.utils.player.PrimaryPlayerContext; import net.minecraft.client.Minecraft; @@ -89,6 +86,8 @@ public class Baritone implements IBaritone { private IPlayerContext playerContext; private WorldProvider worldProvider; + public BlockStateInterface bsi; + Baritone() { this.gameEventHandler = new GameEventHandler(this); } diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index e85c46de..55bf21b7 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -23,6 +23,7 @@ import baritone.api.event.events.type.EventState; import baritone.api.event.listener.IEventBus; import baritone.api.event.listener.IGameEventListener; import baritone.cache.WorldProvider; +import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; @@ -46,6 +47,9 @@ public final class GameEventHandler implements IEventBus, Helper { @Override public final void onTick(TickEvent event) { + try { + baritone.bsi = new BlockStateInterface(baritone.getPlayerContext(), true); + } catch (Exception ex) {} listeners.forEach(l -> l.onTick(event)); }