actually works

This commit is contained in:
Leijurv
2019-01-28 17:34:14 -08:00
parent b005ce8e6b
commit 735cf47c35
5 changed files with 74 additions and 2 deletions

View File

@@ -38,9 +38,21 @@ public class MixinChunkCache {
private void getBlockState(BlockPos pos, CallbackInfoReturnable<IBlockState> ci) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) {
ci.setReturnValue(baritone.bsi.get0(pos));
//ci.setReturnValue(Blocks.DIRT.getDefaultState());
}
}
@Inject(
method = "isEmpty",
at = @At("HEAD"),
cancellable = true
)
private void isEmpty(CallbackInfoReturnable<Boolean> ci) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) {
ci.setReturnValue(false);
}
}
}

View File

@@ -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 <https://www.gnu.org/licenses/>.
*/
package baritone.launch.mixins;
import baritone.Baritone;
import baritone.api.BaritoneAPI;
import baritone.api.utils.IPlayerContext;
import net.minecraft.client.renderer.chunk.ChunkRenderWorker;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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(ChunkRenderWorker.class)
public class MixinChunkRenderWorker {
@Inject(
method = "isChunkExisting",
at = @At("HEAD"),
cancellable = true
)
private void isChunkExisting(BlockPos pos, World world, CallbackInfoReturnable<Boolean> ci) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null && Baritone.settings().renderCachedChunks.get()) {
ci.setReturnValue(baritone.bsi.isLoaded(pos.getX(), pos.getZ()));
}
}
}

View File

@@ -13,6 +13,7 @@
"MixinChunkCache",
"MixinChunkProviderClient",
"MixinChunkProviderServer",
"MixinChunkRenderWorker",
"MixinEntity",
"MixinEntityLivingBase",
"MixinEntityPlayerSP",