diff --git a/src/api/java/baritone/api/event/events/RotationMoveEvent.java b/src/api/java/baritone/api/event/events/RotationMoveEvent.java index f9b7ba434..3d78b4b73 100644 --- a/src/api/java/baritone/api/event/events/RotationMoveEvent.java +++ b/src/api/java/baritone/api/event/events/RotationMoveEvent.java @@ -75,7 +75,7 @@ public final class RotationMoveEvent { /** * Called when the player jumps. * - * @see EntityLivingBase#jump + * @see LivingEntity#jump */ JUMP } diff --git a/src/api/java/baritone/api/utils/IPlayerController.java b/src/api/java/baritone/api/utils/IPlayerController.java index 905825644..82a195dbd 100644 --- a/src/api/java/baritone/api/utils/IPlayerController.java +++ b/src/api/java/baritone/api/utils/IPlayerController.java @@ -25,6 +25,7 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameType; import net.minecraft.world.World; @@ -49,7 +50,7 @@ public interface IPlayerController { return this.getGameType().isCreative() ? 5.0F : 4.5F; } - ActionResultType processRightClickBlock(ClientPlayerEntity player, World world, BlockPos pos, Direction direction, Vec3d vec, Hand hand); + ActionResultType processRightClickBlock(ClientPlayerEntity player, World world, Hand hand, BlockRayTraceResult result); ActionResultType processRightClick(ClientPlayerEntity player, World world, Hand hand); } diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java deleted file mode 100644 index dc35f7570..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderContainer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ChunkRenderContainer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.chunk.RenderChunk; -import net.minecraft.util.math.BlockPos; -import org.lwjgl.opengl.GL14; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import static org.lwjgl.opengl.GL11.GL_ONE; -import static org.lwjgl.opengl.GL11.GL_ZERO; -import static org.lwjgl.opengl.GL14.GL_CONSTANT_ALPHA; -import static org.lwjgl.opengl.GL14.GL_ONE_MINUS_CONSTANT_ALPHA; - -@Mixin(ChunkRenderContainer.class) -public class MixinChunkRenderContainer { - - @Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second - method = "preRenderChunk", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/renderer/chunk/RenderChunk.getPosition()Lnet/minecraft/util/math/BlockPos;" - ) - ) - private BlockPos getPosition(RenderChunk renderChunkIn) { - if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer() && Minecraft.getInstance().world.getChunk(renderChunkIn.getPosition()).isEmpty()) { - GlStateManager.enableAlphaTest(); - GlStateManager.enableBlend(); - GL14.glBlendColor(0, 0, 0, Baritone.settings().cachedChunksOpacity.value); - GlStateManager.blendFuncSeparate(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_ONE, GL_ZERO); - } - return renderChunkIn.getPosition(); - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java b/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java deleted file mode 100644 index 6e02d0f9c..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinChunkRenderWorker.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.client.Minecraft; -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.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ChunkRenderWorker.class) -public abstract class MixinChunkRenderWorker { - - @Shadow - protected abstract boolean isChunkExisting(BlockPos pos, World worldIn); - - @Redirect( - method = "processTask", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/renderer/chunk/ChunkRenderWorker.isChunkExisting(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;)Z" - ) - ) - private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) { - if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) { - Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); - IPlayerContext ctx = baritone.getPlayerContext(); - if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { - return baritone.bsi.isLoaded(pos.getX(), pos.getZ()) || this.isChunkExisting(pos, world); - } - } - - return this.isChunkExisting(pos, world); - } -} - diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkProviderClient.java b/src/launch/java/baritone/launch/mixins/MixinClientChunkProvider.java similarity index 88% rename from src/launch/java/baritone/launch/mixins/MixinChunkProviderClient.java rename to src/launch/java/baritone/launch/mixins/MixinClientChunkProvider.java index b4cada6ef..cdfd1cf56 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkProviderClient.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientChunkProvider.java @@ -19,14 +19,14 @@ package baritone.launch.mixins; import baritone.utils.accessor.IChunkProviderClient; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import net.minecraft.client.multiplayer.ChunkProviderClient; +import net.minecraft.client.multiplayer.ClientChunkProvider; import net.minecraft.world.chunk.Chunk; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -@Mixin(ChunkProviderClient.class) -public class MixinChunkProviderClient implements IChunkProviderClient { +@Mixin(ClientChunkProvider.class) +public class MixinClientChunkProvider implements IChunkProviderClient { @Shadow @Final diff --git a/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java b/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java similarity index 78% rename from src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java rename to src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java index a2d041c82..0562f24ae 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetHandlerPlayClient.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java @@ -21,10 +21,10 @@ import baritone.api.BaritoneAPI; import baritone.api.IBaritone; import baritone.api.event.events.ChunkEvent; import baritone.api.event.events.type.EventState; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.network.play.server.SPacketChunkData; -import net.minecraft.network.play.server.SPacketCombatEvent; -import net.minecraft.network.play.server.SPacketUnloadChunk; +import net.minecraft.client.network.play.ClientPlayNetHandler; +import net.minecraft.network.play.server.SChunkDataPacket; +import net.minecraft.network.play.server.SCombatPacket; +import net.minecraft.network.play.server.SUnloadChunkPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -34,10 +34,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; * @author Brady * @since 8/3/2018 */ -@Mixin(NetHandlerPlayClient.class) -public class MixinNetHandlerPlayClient { +@Mixin(ClientPlayNetHandler.class) +public class MixinClientPlayNetHandler { - @Inject( + // unused lol + /*@Inject( method = "handleChunkData", at = @At( value = "INVOKE", @@ -57,15 +58,15 @@ public class MixinNetHandlerPlayClient { ); } } - } + }*/ @Inject( method = "handleChunkData", at = @At("RETURN") ) - private void postHandleChunkData(SPacketChunkData packetIn, CallbackInfo ci) { + private void postHandleChunkData(SChunkDataPacket packetIn, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { + if (ibaritone.getPlayerContext().player().field_71174_a == (ClientPlayNetHandler) (Object) this) { ibaritone.getGameEventHandler().onChunkEvent( new ChunkEvent( EventState.POST, @@ -82,9 +83,9 @@ public class MixinNetHandlerPlayClient { method = "processChunkUnload", at = @At("HEAD") ) - private void preChunkUnload(SPacketUnloadChunk packet, CallbackInfo ci) { + private void preChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { + if (ibaritone.getPlayerContext().player().field_71174_a == (ClientPlayNetHandler) (Object) this) { ibaritone.getGameEventHandler().onChunkEvent( new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ()) ); @@ -96,9 +97,9 @@ public class MixinNetHandlerPlayClient { method = "processChunkUnload", at = @At("RETURN") ) - private void postChunkUnload(SPacketUnloadChunk packet, CallbackInfo ci) { + private void postChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { + if (ibaritone.getPlayerContext().player().field_71174_a == (ClientPlayNetHandler) (Object) this) { ibaritone.getGameEventHandler().onChunkEvent( new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ()) ); @@ -110,12 +111,12 @@ public class MixinNetHandlerPlayClient { method = "handleCombatEvent", at = @At( value = "INVOKE", - target = "net/minecraft/client/Minecraft.displayScreen(Lnet/minecraft/client/gui/Screen;)V" + target = "net/minecraft/client/Minecraft.displayGuiScreen(Lnet/minecraft/client/gui/screen/Screen;)V" ) ) - private void onPlayerDeath(SPacketCombatEvent packetIn, CallbackInfo ci) { + private void onPlayerDeath(SCombatPacket packetIn, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player().connection == (NetHandlerPlayClient) (Object) this) { + if (ibaritone.getPlayerContext().player().field_71174_a == (ClientPlayNetHandler) (Object) this) { ibaritone.getGameEventHandler().onPlayerDeath(); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java b/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java similarity index 92% rename from src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java rename to src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java index 392323f02..c10a4831d 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityPlayerSP.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java @@ -24,9 +24,9 @@ import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.SprintStateEvent; import baritone.api.event.events.type.EventState; import baritone.behavior.LookBehavior; -import net.minecraft.client.entity.ClientPlayerEntity; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.player.PlayerCapabilities; +import net.minecraft.entity.player.PlayerAbilities; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -61,7 +61,7 @@ public class MixinClientPlayerEntity { method = "tick", at = @At( value = "INVOKE", - target = "net/minecraft/client/entity/ClientPlayerEntity.isPassenger()Z", + target = "net/minecraft/client/entity/player/ClientPlayerEntity.isPassenger()Z", shift = At.Shift.BY, by = -3 ) @@ -77,7 +77,7 @@ public class MixinClientPlayerEntity { method = "tick", at = @At( value = "INVOKE", - target = "net/minecraft/client/entity/ClientPlayerEntity.onUpdateWalkingPlayer()V", + target = "net/minecraft/client/entity/player/ClientPlayerEntity.onUpdateWalkingPlayer()V", shift = At.Shift.BY, by = 2 ) @@ -93,10 +93,10 @@ public class MixinClientPlayerEntity { method = "livingTick", at = @At( value = "FIELD", - target = "net/minecraft/entity/player/PlayerCapabilities.allowFlying:Z" + target = "net/minecraft/entity/player/PlayerAbilities.allowFlying:Z" ) ) - private boolean isAllowFlying(PlayerCapabilities capabilities) { + private boolean isAllowFlying(PlayerAbilities capabilities) { IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this); if (baritone == null) { return capabilities.allowFlying; diff --git a/src/launch/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java new file mode 100644 index 000000000..9cd2a3c96 --- /dev/null +++ b/src/launch/java/baritone/launch/mixins/MixinEntity.java @@ -0,0 +1,60 @@ +/* + * 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.api.BaritoneAPI; +import baritone.api.event.events.RotationMoveEvent; +import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Entity.class) +public class MixinEntity { + + @Shadow + private float rotationYaw; + + float yawRestore; + + @Inject( + method = "moveRelative", + at = @At("HEAD") + ) + private void moveRelativeHead(CallbackInfo info) { + this.yawRestore = this.rotationYaw; + // noinspection ConstantConditions + if (!ClientPlayerEntity.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) == null) { + return; + } + RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); + BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent); + this.rotationYaw = motionUpdateRotationEvent.getYaw(); + } + + @Inject( + method = "moveRelative", + at = @At("RETURN") + ) + private void moveRelativeReturn(CallbackInfo info) { + this.rotationYaw = this.yawRestore; + } +} diff --git a/src/launch/java/baritone/launch/mixins/MixinGameRenderer.java b/src/launch/java/baritone/launch/mixins/MixinGameRenderer.java index 57de55c7d..fb279ba0f 100644 --- a/src/launch/java/baritone/launch/mixins/MixinGameRenderer.java +++ b/src/launch/java/baritone/launch/mixins/MixinGameRenderer.java @@ -33,7 +33,7 @@ public class MixinGameRenderer { method = "updateCameraAndRender(FJ)V", at = @At( value = "INVOKE_STRING", - target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", + target = "Lnet/minecraft/profiler/IProfiler;endStartSection(Ljava/lang/String;)V", args = {"ldc=hand"} ) ) diff --git a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java b/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java similarity index 62% rename from src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java rename to src/launch/java/baritone/launch/mixins/MixinLivingEntity.java index 5cddbc7d7..45c5d4643 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntityLivingBase.java +++ b/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java @@ -20,10 +20,11 @@ package baritone.launch.mixins; import baritone.api.BaritoneAPI; import baritone.api.IBaritone; import baritone.api.event.events.RotationMoveEvent; -import net.minecraft.client.entity.ClientPlayerEntity; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -37,15 +38,15 @@ import static org.spongepowered.asm.lib.Opcodes.GETFIELD; * @author Brady * @since 9/10/2018 */ -@Mixin(EntityLivingBase.class) -public abstract class MixinEntityLivingBase extends Entity { +@Mixin(LivingEntity.class) +public abstract class MixinLivingEntity extends Entity { /** * Event called to override the movement direction when jumping */ private RotationMoveEvent jumpRotationEvent; - public MixinEntityLivingBase(EntityType entityTypeIn, World worldIn) { + public MixinLivingEntity(EntityType entityTypeIn, World worldIn) { super(entityTypeIn, worldIn); } @@ -69,34 +70,15 @@ public abstract class MixinEntityLivingBase extends Entity { at = @At( value = "FIELD", opcode = GETFIELD, - target = "net/minecraft/entity/EntityLivingBase.rotationYaw:F" + target = "net/minecraft/entity/LivingEntity.rotationYaw:F" ) ) - private float overrideYaw(EntityLivingBase self) { + private float overrideYaw(LivingEntity self) { if (self instanceof ClientPlayerEntity && BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) != null) { return this.jumpRotationEvent.getYaw(); } return self.rotationYaw; } - @Redirect( - method = "travel", - at = @At( - value = "INVOKE", - target = "net/minecraft/entity/EntityLivingBase.moveRelative(FFFF)V" - ) - ) - private void travel(EntityLivingBase self, float strafe, float up, float forward, float friction) { - // noinspection ConstantConditions - if (!ClientPlayerEntity.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this) == null) { - moveRelative(strafe, up, forward, friction); - return; - } - RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); - BaritoneAPI.getProvider().getBaritoneForPlayer((ClientPlayerEntity) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent); - float originalYaw = this.rotationYaw; - this.rotationYaw = motionUpdateRotationEvent.getYaw(); - this.moveRelative(strafe, up, forward, friction); - this.rotationYaw = originalYaw; - } + } diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index 3490e359e..03951e68c 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -26,12 +26,12 @@ import baritone.api.event.events.WorldEvent; import baritone.api.event.events.type.EventState; import baritone.utils.BaritoneAutoTest; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.ClientPlayerEntity; -import net.minecraft.client.gui.Screen; -import net.minecraft.client.multiplayer.ClientWorld; +import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.world.ClientWorld; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import org.spongepowered.asm.lib.Opcodes; import org.spongepowered.asm.mixin.Mixin; @@ -78,7 +78,7 @@ public class MixinMinecraft { at = @At( value = "FIELD", opcode = Opcodes.GETFIELD, - target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/Screen;", + target = "net/minecraft/client/Minecraft.field_71462_r:Lnet/minecraft/client/gui/screen/Screen;", ordinal = 5, shift = At.Shift.BY, by = -3 @@ -97,10 +97,10 @@ public class MixinMinecraft { } @Inject( - method = "loadWorld(Lnet/minecraft/client/multiplayer/ClientWorld;Lnet/minecraft/client/gui/Screen;)V", + method = "loadWorld(Lnet/minecraft/client/world/ClientWorld;)V", at = @At("HEAD") ) - private void preLoadWorld(ClientWorld world, Screen loadingScreen, CallbackInfo ci) { + private void preLoadWorld(ClientWorld world, CallbackInfo ci) { // If we're unloading the world but one doesn't exist, ignore it if (this.world == null && world == null) { return; @@ -117,10 +117,10 @@ public class MixinMinecraft { } @Inject( - method = "loadWorld(Lnet/minecraft/client/multiplayer/ClientWorld;Lnet/minecraft/client/gui/Screen;)V", + method = "loadWorld(Lnet/minecraft/client/world/ClientWorld;)V", at = @At("RETURN") ) - private void postLoadWorld(ClientWorld world, Screen loadingScreen, CallbackInfo ci) { + private void postLoadWorld(ClientWorld world, CallbackInfo ci) { // still fire event for both null, as that means we've just finished exiting a world // mc.world changing is only the primary baritone @@ -137,19 +137,19 @@ public class MixinMinecraft { at = @At( value = "FIELD", opcode = Opcodes.GETFIELD, - target = "net/minecraft/client/gui/Screen.allowUserInput:Z" + target = "net/minecraft/client/gui/screen/Screen.passEvents:Z" ) ) - private boolean isAllowUserInput(Screen screen) { + private boolean passEvents(Screen screen) { // allow user input is only the primary baritone - return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.allowUserInput; + return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.passEvents; } @Inject( method = "clickMouse", at = @At( value = "INVOKE", - target = "net/minecraft/client/multiplayer/PlayerControllerMP.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/Direction;)Z" + target = "net/minecraft/client/multiplayer/PlayerController.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/Direction;)Z" ), locals = LocalCapture.CAPTURE_FAILHARD ) @@ -162,11 +162,11 @@ public class MixinMinecraft { method = "rightClickMouse", at = @At( value = "INVOKE", - target = "net/minecraft/client/entity/ClientPlayerEntity.swingArm(Lnet/minecraft/util/EnumHand;)V" + target = "net/minecraft/client/entity/player/ClientPlayerEntity.swingArm(Lnet/minecraft/util/Hand;)V" ), locals = LocalCapture.CAPTURE_FAILHARD ) - private void onBlockUse(CallbackInfo ci, EnumHand var1[], int var2, int var3, EnumHand enumhand, ItemStack itemstack, BlockPos blockpos, int i, EnumActionResult enumactionresult) { + private void onBlockUse(CallbackInfo ci, Hand var1[], int var2, int var3, Hand enumhand, ItemStack itemstack, BlockPos blockpos, int i, ActionResultType enumactionresult) { // rightClickMouse is only for the main player BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE)); } diff --git a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java index 895d2df7e..f781e4c4f 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java +++ b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java @@ -25,9 +25,9 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; -import net.minecraft.network.EnumPacketDirection; +import net.minecraft.network.IPacket; import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; +import net.minecraft.network.PacketDirection; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -47,19 +47,19 @@ public class MixinNetworkManager { @Shadow @Final - private EnumPacketDirection direction; + private PacketDirection field_179294_g; @Inject( method = "dispatchPacket", at = @At("HEAD") ) - private void preDispatchPacket(Packet inPacket, final GenericFutureListener> futureListeners, CallbackInfo ci) { - if (this.direction != EnumPacketDirection.CLIENTBOUND) { + private void preDispatchPacket(IPacket inPacket, final GenericFutureListener> futureListeners, CallbackInfo ci) { + if (this.field_179294_g != PacketDirection.CLIENTBOUND) { return; } for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) { + if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().field_71174_a.getNetworkManager() == (NetworkManager) (Object) this) { ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, inPacket)); } } @@ -69,13 +69,13 @@ public class MixinNetworkManager { method = "dispatchPacket", at = @At("RETURN") ) - private void postDispatchPacket(Packet inPacket, final GenericFutureListener> futureListeners, CallbackInfo ci) { - if (this.direction != EnumPacketDirection.CLIENTBOUND) { + private void postDispatchPacket(IPacket inPacket, final GenericFutureListener> futureListeners, CallbackInfo ci) { + if (this.field_179294_g != PacketDirection.CLIENTBOUND) { return; } for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) { + if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().field_71174_a.getNetworkManager() == (NetworkManager) (Object) this) { ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, inPacket)); } } @@ -85,15 +85,15 @@ public class MixinNetworkManager { method = "channelRead0", at = @At( value = "INVOKE", - target = "net/minecraft/network/NetworkManager.processPacket(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;)V" + target = "net/minecraft/network/NetworkManager.processPacket(Lnet/minecraft/network/IPacket;Lnet/minecraft/network/INetHandler;)V" ) ) - private void preProcessPacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - if (this.direction != EnumPacketDirection.CLIENTBOUND) { + private void preProcessPacket(ChannelHandlerContext context, IPacket packet, CallbackInfo ci) { + if (this.field_179294_g != PacketDirection.CLIENTBOUND) { return; } for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) { + if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().field_71174_a.getNetworkManager() == (NetworkManager) (Object) this) { ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, packet)); } } @@ -103,12 +103,12 @@ public class MixinNetworkManager { method = "channelRead0", at = @At("RETURN") ) - private void postProcessPacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - if (!this.channel.isOpen() || this.direction != EnumPacketDirection.CLIENTBOUND) { + private void postProcessPacket(ChannelHandlerContext context, IPacket packet, CallbackInfo ci) { + if (!this.channel.isOpen() || this.field_179294_g != PacketDirection.CLIENTBOUND) { return; } for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) { + if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().field_71174_a.getNetworkManager() == (NetworkManager) (Object) this) { ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, packet)); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java b/src/launch/java/baritone/launch/mixins/MixinRegionFileCache.java similarity index 82% rename from src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java rename to src/launch/java/baritone/launch/mixins/MixinRegionFileCache.java index 8b3ea0afb..b9d8b2144 100644 --- a/src/launch/java/baritone/launch/mixins/MixinAnvilChunkLoader.java +++ b/src/launch/java/baritone/launch/mixins/MixinRegionFileCache.java @@ -18,7 +18,7 @@ package baritone.launch.mixins; import baritone.utils.accessor.IAnvilChunkLoader; -import net.minecraft.world.chunk.storage.AnvilChunkLoader; +import net.minecraft.world.chunk.storage.RegionFileCache; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -29,15 +29,15 @@ import java.io.File; * @author Brady * @since 9/4/2018 */ -@Mixin(AnvilChunkLoader.class) -public class MixinAnvilChunkLoader implements IAnvilChunkLoader { +@Mixin(RegionFileCache.class) +public class MixinRegionFileCache implements IAnvilChunkLoader { @Shadow @Final - private File chunkSaveLocation; + private File folder; @Override public File getChunkSaveLocation() { - return this.chunkSaveLocation; + return this.folder; } } diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java deleted file mode 100644 index 48a3fbce0..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.BlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.chunk.RenderChunk; -import net.minecraft.client.renderer.chunk.RenderChunkCache; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -/** - * @author Brady - * @since 1/29/2019 - */ -@Mixin(RenderChunk.class) -public class MixinRenderChunk { - - @Redirect( - method = "rebuildChunk", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/renderer/chunk/RenderChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/BlockState;" - ) - ) - private BlockState getBlockState(RenderChunkCache chunkCache, BlockPos pos) { - if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) { - Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); - IPlayerContext ctx = baritone.getPlayerContext(); - if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { - return baritone.bsi.get0(pos); - } - } - - return chunkCache.getBlockState(pos); - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderChunkCache.java b/src/launch/java/baritone/launch/mixins/MixinRenderChunkCache.java deleted file mode 100644 index 817743973..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinRenderChunkCache.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.chunk.RenderChunkCache; -import net.minecraft.world.chunk.Chunk; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(RenderChunkCache.class) -public class MixinRenderChunkCache { - - @Redirect( - method = "generateCache", - at = @At( - value = "INVOKE", - target = "net/minecraft/world/chunk/Chunk.isEmptyBetween(II)Z" - ) - ) - private static boolean isEmpty(Chunk chunk, int yStart, int yEnd) { - if (!chunk.isEmptyBetween(yStart, yEnd)) { - return false; - } - if (chunk.isEmpty() && Baritone.settings().renderCachedChunks.value && Minecraft.getInstance().getIntegratedServer() == null) { - return false; - } - return true; - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderList.java b/src/launch/java/baritone/launch/mixins/MixinRenderList.java deleted file mode 100644 index ec3053f11..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinRenderList.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderList; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import static org.lwjgl.opengl.GL11.*; - -@Mixin(RenderList.class) -public class MixinRenderList { - - @Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second - method = "renderChunkLayer", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V" - ) - ) - private void popMatrix() { - if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) { - // reset the blend func to normal (not dependent on constant alpha) - GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); - } - GlStateManager.popMatrix(); - } -} diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java b/src/launch/java/baritone/launch/mixins/MixinServerChunkProvider.java similarity index 78% rename from src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java rename to src/launch/java/baritone/launch/mixins/MixinServerChunkProvider.java index 6d5a5421b..2ac467979 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkProviderServer.java +++ b/src/launch/java/baritone/launch/mixins/MixinServerChunkProvider.java @@ -18,8 +18,8 @@ package baritone.launch.mixins; import baritone.utils.accessor.IChunkProviderServer; -import net.minecraft.world.chunk.storage.IChunkLoader; -import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraft.world.chunk.ServerChunkProvider; +import net.minecraft.world.chunk.storage.ChunkLoader; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -28,15 +28,15 @@ import org.spongepowered.asm.mixin.Shadow; * @author Brady * @since 9/4/2018 */ -@Mixin(ChunkProviderServer.class) -public class MixinChunkProviderServer implements IChunkProviderServer { +@Mixin(ServerChunkProvider.class) +public class MixinServerChunkProvider implements IChunkProviderServer { @Shadow @Final - private IChunkLoader chunkLoader; + private ChunkLoader chunkLoader; @Override - public IChunkLoader getChunkLoader() { + public ChunkLoader getChunkLoader() { return this.chunkLoader; } } diff --git a/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java b/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java deleted file mode 100644 index 5cda68034..000000000 --- a/src/launch/java/baritone/launch/mixins/MixinVboRenderList.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.VboRenderList; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import static org.lwjgl.opengl.GL11.*; - -@Mixin(VboRenderList.class) -public class MixinVboRenderList { - - @Redirect( // avoid creating CallbackInfo at all costs; this is called 40k times per second - method = "renderChunkLayer", - at = @At( - value = "INVOKE", - target = "net/minecraft/client/renderer/GlStateManager.popMatrix()V" - ) - ) - private void popMatrix() { - if (Baritone.settings().renderCachedChunks.value && !Minecraft.getInstance().isSingleplayer()) { - // reset the blend func to normal (not dependent on constant alpha) - GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); - } - GlStateManager.popMatrix(); - } -} diff --git a/src/launch/resources/mixins.baritone.json b/src/launch/resources/mixins.baritone.json index 056b17a42..dfe9c58fa 100644 --- a/src/launch/resources/mixins.baritone.json +++ b/src/launch/resources/mixins.baritone.json @@ -8,21 +8,15 @@ "maxShiftBy": 2 }, "client": [ - "MixinAnvilChunkLoader", "MixinBlockPos", - "MixinChunkProviderClient", - "MixinChunkProviderServer", - "MixinChunkRenderContainer", - "MixinChunkRenderWorker", - "MixinEntityLivingBase", - "MixinEntityPlayerSP", + "MixinClientPlayerEntity", + "MixinClientPlayNetHandler", + "MixinEntity", "MixinGameRenderer", + "MixinLivingEntity", "MixinMinecraft", - "MixinNetHandlerPlayClient", "MixinNetworkManager", - "MixinRenderChunk", - "MixinRenderChunkCache", - "MixinRenderList", - "MixinVboRenderList" + "MixinRegionFileCache", + "MixinServerChunkProvider" ] } \ No newline at end of file diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index e03d56332..52f64a91f 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -218,7 +218,7 @@ public class Baritone implements IBaritone { new Thread(() -> { try { Thread.sleep(100); - Helper.mc.addScheduledTask(() -> Helper.mc.displayScreen(new GuiClick())); + Helper.mc.execute(() -> Helper.mc.displayGuiScreen(new GuiClick())); } catch (Exception ignored) {} }).start(); } diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index bcb11bb6c..3c2e15c72 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -21,10 +21,10 @@ import baritone.Baritone; import baritone.api.event.events.TickEvent; import baritone.utils.ToolSet; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; -import net.minecraft.client.entity.ClientPlayerEntity; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.ClickType; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.inventory.container.ClickType; import net.minecraft.item.*; import net.minecraft.util.NonNullList; @@ -46,14 +46,14 @@ public final class InventoryBehavior extends Behavior { if (event.getType() == TickEvent.Type.OUT) { return; } - if (ctx.player().openContainer != ctx.player().inventoryContainer) { + if (ctx.player().openContainer != ctx.player().container) { // we have a crafting table or a chest or something open return; } if (firstValidThrowaway() >= 9) { // aka there are none on the hotbar, but there are some in main inventory swapWithHotBar(firstValidThrowaway(), 8); } - int pick = bestToolAgainst(Blocks.STONE, ItemPickaxe.class); + int pick = bestToolAgainst(Blocks.STONE, PickaxeItem.class); if (pick >= 9) { swapWithHotBar(pick, 0); } @@ -88,7 +88,7 @@ public final class InventoryBehavior extends Behavior { } private void swapWithHotBar(int inInventory, int inHotbar) { - ctx.playerController().windowClick(ctx.player().inventoryContainer.windowId, inInventory < 9 ? inInventory + 36 : inInventory, inHotbar, ClickType.SWAP, ctx.player()); + ctx.playerController().windowClick(ctx.player().container.windowId, inInventory < 9 ? inInventory + 36 : inInventory, inHotbar, ClickType.SWAP, ctx.player()); } private int firstValidThrowaway() { // TODO offhand idk @@ -101,7 +101,7 @@ public final class InventoryBehavior extends Behavior { return -1; } - private int bestToolAgainst(Block against, Class klass) { + private int bestToolAgainst(Block against, Class klass) { NonNullList invy = ctx.player().inventory.mainInventory; int bestInd = -1; double bestSpeed = -1; @@ -132,7 +132,7 @@ public final class InventoryBehavior extends Behavior { public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) { BlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z); - if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock().equals(maybe.getBlock()))) { + if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && ((BlockItem) stack.getItem()).getBlock().equals(maybe.getBlock()))) { return true; // gotem } for (Item item : Baritone.settings().acceptableThrowawayItems.value) { @@ -168,7 +168,7 @@ public final class InventoryBehavior extends Behavior { // so not a shovel, not a hoe, not a block, etc for (byte i = 0; i < 9; i++) { ItemStack item = inv.get(i); - if (item.isEmpty() || item.getItem() instanceof ItemPickaxe) { + if (item.isEmpty() || item.getItem() instanceof PickaxeItem) { if (select) { p.inventory.currentItem = i; } diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 0c1680b33..4c4c48a04 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -20,26 +20,10 @@ package baritone.behavior; import baritone.Baritone; import baritone.api.cache.Waypoint; import baritone.api.event.events.BlockInteractEvent; -import baritone.api.event.events.PacketEvent; -import baritone.api.event.events.PlayerUpdateEvent; -import baritone.api.event.events.TickEvent; -import baritone.api.event.events.type.EventState; import baritone.cache.ContainerMemory; import baritone.utils.BlockStateInterface; -import net.minecraft.block.Block; -import net.minecraft.block.BlockBed; -import net.minecraft.init.Blocks; +import net.minecraft.block.BedBlock; import net.minecraft.item.ItemStack; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.CPacketCloseWindow; -import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock; -import net.minecraft.network.play.server.SPacketCloseWindow; -import net.minecraft.network.play.server.SPacketOpenWindow; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityLockable; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentTranslation; import java.io.IOException; import java.nio.file.Files; @@ -54,111 +38,13 @@ import java.util.*; */ public final class MemoryBehavior extends Behavior { - private final List futureInventories = new ArrayList<>(); // this is per-bot - - private Integer enderChestWindowId; // nae nae - public MemoryBehavior(Baritone baritone) { super(baritone); } - @Override - public synchronized void onTick(TickEvent event) { - if (!Baritone.settings().containerMemory.value) { - return; - } - if (event.getType() == TickEvent.Type.OUT) { - enderChestWindowId = null; - futureInventories.clear(); - } - } - - @Override - public synchronized void onPlayerUpdate(PlayerUpdateEvent event) { - if (event.getState() == EventState.PRE) { - updateInventory(); - } - } - - @Override - public synchronized void onSendPacket(PacketEvent event) { - if (!Baritone.settings().containerMemory.value) { - return; - } - Packet p = event.getPacket(); - - if (event.getState() == EventState.PRE) { - if (p instanceof CPacketPlayerTryUseItemOnBlock) { - CPacketPlayerTryUseItemOnBlock packet = event.cast(); - - TileEntity tileEntity = ctx.world().getTileEntity(packet.getPos()); - // if tileEntity is an ender chest, we don't need to do anything. ender chests are treated the same regardless of what coordinate right clicked - - // Ensure the TileEntity is a container of some sort - if (tileEntity instanceof TileEntityLockable) { - - TileEntityLockable lockable = (TileEntityLockable) tileEntity; - int size = lockable.getSizeInventory(); - BlockPos position = tileEntity.getPos(); - BlockPos adj = neighboringConnectedBlock(position); - System.out.println(position + " " + adj); - if (adj != null) { - size *= 2; // double chest or double trapped chest - if (adj.getX() < position.getX() || adj.getZ() < position.getZ()) { - position = adj; // standardize on the lower coordinate, regardless of which side of the large chest we right clicked - } - } - - this.futureInventories.add(new FutureInventory(System.nanoTime() / 1000000L, size, lockable.getGuiID(), position)); - } - } - - if (p instanceof CPacketCloseWindow) { - getCurrent().save(); - } - } - } - - @Override - public synchronized void onReceivePacket(PacketEvent event) { - if (!Baritone.settings().containerMemory.value) { - return; - } - Packet p = event.getPacket(); - - if (event.getState() == EventState.PRE) { - if (p instanceof SPacketOpenWindow) { - SPacketOpenWindow packet = event.cast(); - // Remove any entries that were created over a second ago, this should make up for INSANE latency - futureInventories.removeIf(i -> System.nanoTime() / 1000000L - i.time > 1000); - - System.out.println("Received packet " + packet.getGuiId() + " " + packet.getEntityId() + " " + packet.getSlotCount() + " " + packet.getWindowId()); - System.out.println(packet.getWindowTitle()); - if (packet.getWindowTitle() instanceof TextComponentTranslation && ((TextComponentTranslation) packet.getWindowTitle()).getKey().equals("container.enderchest")) { - // title is not customized (i.e. this isn't just a renamed shulker) - enderChestWindowId = packet.getWindowId(); - return; - } - futureInventories.stream() - .filter(i -> i.getType().equals(packet.getGuiId()) && i.slots == packet.getSlotCount()) - .findFirst().ifPresent(matched -> { - // Remove the future inventory - futureInventories.remove(matched); - - // Setup the remembered inventory - getCurrentContainer().setup(matched.pos, packet.getWindowId(), packet.getSlotCount()); - }); - } - - if (p instanceof SPacketCloseWindow) { - getCurrent().save(); - } - } - } - @Override public void onBlockInteract(BlockInteractEvent event) { - if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(ctx, event.getPos()) instanceof BlockBed) { + if (event.getType() == BlockInteractEvent.Type.USE && BlockStateInterface.getBlock(ctx, event.getPos()) instanceof BedBlock) { baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("bed", Waypoint.Tag.BED, event.getPos())); } } @@ -168,85 +54,6 @@ public final class MemoryBehavior extends Behavior { baritone.getWorldProvider().getCurrentWorld().getWaypoints().addWaypoint(new Waypoint("death", Waypoint.Tag.DEATH, ctx.playerFeet())); } - - private void updateInventory() { - if (!Baritone.settings().containerMemory.value) { - return; - } - int windowId = ctx.player().openContainer.windowId; - if (enderChestWindowId != null) { - if (windowId == enderChestWindowId) { - getCurrent().contents = ctx.player().openContainer.getInventory().subList(0, 27); - } else { - getCurrent().save(); - enderChestWindowId = null; - } - } - if (getCurrentContainer() != null) { - getCurrentContainer().getInventoryFromWindow(windowId).ifPresent(inventory -> inventory.updateFromOpenWindow(ctx)); - } - } - - private ContainerMemory getCurrentContainer() { - if (baritone.getWorldProvider().getCurrentWorld() == null) { - return null; - } - return (ContainerMemory) baritone.getWorldProvider().getCurrentWorld().getContainerMemory(); - } - - private BlockPos neighboringConnectedBlock(BlockPos in) { - BlockStateInterface bsi = baritone.bsi; - Block block = bsi.get0(in).getBlock(); - if (block != Blocks.TRAPPED_CHEST && block != Blocks.CHEST) { - return null; // other things that have contents, but can be placed adjacent without combining - } - for (int i = 0; i < 4; i++) { - BlockPos adj = in.offset(Direction.byHorizontalIndex(i)); - if (bsi.get0(adj).getBlock() == block) { - return adj; - } - } - return null; - } - - /** - * An inventory that we are not yet fully aware of, but are expecting to exist at some point in the future. - */ - private static final class FutureInventory { - - /** - * The time that we initially expected the inventory to be provided, in milliseconds - */ - private final long time; - - /** - * The amount of slots in the inventory - */ - private final int slots; - - /** - * The type of inventory - */ - private final String type; - - /** - * The position of the inventory container - */ - private final BlockPos pos; - - private FutureInventory(long time, int slots, String type, BlockPos pos) { - this.time = time; - this.slots = slots; - this.type = type; - this.pos = pos; - System.out.println("Future inventory created " + time + " " + slots + " " + type + " " + pos); - } - } - - public Optional> echest() { - return Optional.ofNullable(getCurrent().contents).map(Collections::unmodifiableList); - } - public EnderChestMemory getCurrent() { Path path = baritone.getWorldProvider().getCurrentWorld().directory; return EnderChestMemory.getByServerAndPlayer(path.getParent(), ctx.player().getUniqueID()); diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 829bd39bc..dac132613 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -22,8 +22,8 @@ import baritone.utils.pathing.PathingBlockType; import com.google.common.collect.ImmutableSet; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import java.util.ArrayList; diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index 84612908e..ed5e9df8b 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -20,7 +20,7 @@ package baritone.cache; import baritone.Baritone; import baritone.api.cache.ICachedRegion; import baritone.api.utils.BlockUtils; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import java.io.*; diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index e5d4a6526..e06c08077 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -21,8 +21,6 @@ import baritone.api.utils.BlockUtils; import baritone.pathing.movement.MovementHelper; import baritone.utils.pathing.PathingBlockType; import net.minecraft.block.*; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.chunk.BlockStateContainer; @@ -31,6 +29,8 @@ import net.minecraft.world.chunk.ChunkSection; import java.util.*; +import static baritone.utils.BlockStateInterface.getFromChunk; + /** * @author Brady * @since 8/3/2018 @@ -89,19 +89,20 @@ public final class ChunkPacker { BlockState[] blocks = new BlockState[256]; for (int z = 0; z < 16; z++) { - https://www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html + https: +//www.ibm.com/developerworks/library/j-perry-writing-good-java-code/index.html for (int x = 0; x < 16; x++) { for (int y = 255; y >= 0; y--) { int index = CachedChunk.getPositionIndex(x, y, z); if (bitSet.get(index) || bitSet.get(index + 1)) { - blocks[z << 4 | x] = chunk.getBlockState(x, y, z); + blocks[z << 4 | x] = getFromChunk(chunk, x, y, z); continue https; } } blocks[z << 4 | x] = Blocks.AIR.getDefaultState(); } } - return new CachedChunk(chunk.x, chunk.z, bitSet, blocks, specialBlocks, System.currentTimeMillis()); + return new CachedChunk(chunk.getPos().x, chunk.getPos().z, bitSet, blocks, specialBlocks, System.currentTimeMillis()); } private static PathingBlockType getPathingBlockType(BlockState state, Chunk chunk, int x, int y, int z) { @@ -113,15 +114,15 @@ public final class ChunkPacker { return PathingBlockType.AVOID; } if ( - (x != 15 && MovementHelper.possiblyFlowing(chunk.getBlockState(x + 1, y, z))) - || (x != 0 && MovementHelper.possiblyFlowing(chunk.getBlockState(x - 1, y, z))) - || (z != 15 && MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z + 1))) - || (z != 0 && MovementHelper.possiblyFlowing(chunk.getBlockState(x, y, z - 1))) + (x != 15 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x + 1, y, z))) + || (x != 0 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x - 1, y, z))) + || (z != 15 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x, y, z + 1))) + || (z != 0 && MovementHelper.possiblyFlowing(getFromChunk(chunk, x, y, z - 1))) ) { return PathingBlockType.AVOID; } if (x == 0 || x == 15 || z == 0 || z == 15) { - Vec3d flow = state.getFluidState().getFlow(chunk.getWorld(), new BlockPos(x + chunk.x << 4, y, z + chunk.z << 4)); + Vec3d flow = state.getFluidState().getFlow(chunk.getWorld(), new BlockPos(x + chunk.getPos().x << 4, y, z + chunk.getPos().z << 4)); if (flow.x != 0.0 || flow.z != 0.0) { return PathingBlockType.WATER; } @@ -137,7 +138,7 @@ public final class ChunkPacker { // however, this failed in the nether when you were near a nether fortress // because fences check their adjacent blocks in the world for their fence connection status to determine AABB shape // this caused a nullpointerexception when we saved chunks on unload, because they were unable to check their neighbors - if (block instanceof BlockAir || block instanceof BlockTallGrass || block instanceof BlockDoublePlant || block instanceof BlockFlower) { + if (block instanceof AirBlock || block instanceof TallGrassBlock || block instanceof DoublePlantBlock || block instanceof FlowerBlock) { return PathingBlockType.AIR; } diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 412e16ee5..54cfb41cb 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -23,7 +23,7 @@ import baritone.api.utils.Helper; import baritone.utils.accessor.IAnvilChunkLoader; import baritone.utils.accessor.IChunkProviderServer; import net.minecraft.server.integrated.IntegratedServer; -import net.minecraft.world.WorldServer; +import net.minecraft.world.ServerWorld; import net.minecraft.world.dimension.DimensionType; import org.apache.commons.lang3.SystemUtils; @@ -64,7 +64,7 @@ public class WorldProvider implements IWorldProvider, Helper { // If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file if (mc.isSingleplayer()) { - WorldServer localServerWorld = integratedServer.getWorld(dimension); + ServerWorld localServerWorld = integratedServer.getWorld(dimension); IChunkProviderServer provider = (IChunkProviderServer) localServerWorld.getChunkProvider(); IAnvilChunkLoader loader = (IAnvilChunkLoader) provider.getChunkLoader(); directory = loader.getChunkSaveLocation(); diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 6bfe58772..300af3824 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -20,8 +20,8 @@ package baritone.cache; import baritone.api.cache.IWorldScanner; import baritone.api.utils.IPlayerContext; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; -import net.minecraft.client.multiplayer.ChunkProviderClient; +import net.minecraft.block.BlockState; +import net.minecraft.client.multiplayer.ClientChunkProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.chunk.BlockStateContainer; @@ -46,7 +46,7 @@ public enum WorldScanner implements IWorldScanner { if (blocks.isEmpty()) { return res; } - ChunkProviderClient chunkProvider = (ChunkProviderClient) ctx.world().getChunkProvider(); + ClientChunkProvider chunkProvider = (ClientChunkProvider) ctx.world().getChunkProvider(); int maxSearchRadiusSq = maxSearchRadius * maxSearchRadius; int playerChunkX = ctx.playerFeet().getX() >> 4; @@ -70,7 +70,7 @@ public enum WorldScanner implements IWorldScanner { foundChunks = true; int chunkX = xoff + playerChunkX; int chunkZ = zoff + playerChunkZ; - Chunk chunk = chunkProvider.getChunk(chunkX, chunkZ, false, false); + Chunk chunk = chunkProvider.getChunk(chunkX, chunkZ, null, false); if (chunk == null) { continue; } @@ -96,8 +96,8 @@ public enum WorldScanner implements IWorldScanner { return Collections.emptyList(); } - ChunkProviderClient chunkProvider = (ChunkProviderClient) ctx.world().getChunkProvider(); - Chunk chunk = chunkProvider.getChunk(pos.x, pos.z, false, false); + ClientChunkProvider chunkProvider = (ClientChunkProvider) ctx.world().getChunkProvider(); + Chunk chunk = chunkProvider.getChunk(pos.x, pos.z, null, false); int playerY = ctx.playerFeet().getY(); if (chunk == null || chunk.isEmpty()) { @@ -114,12 +114,12 @@ public enum WorldScanner implements IWorldScanner { boolean foundWithinY = false; for (int yIndex = 0; yIndex < 16; yIndex++) { int y0 = coordinateIterationOrder[yIndex]; - ChunkSection extendedblockstorage = chunkInternalStorageArray[y0]; - if (extendedblockstorage == null) { + ChunkSection section = chunkInternalStorageArray[y0]; + if (section == null || ChunkSection.isEmpty(section)) { continue; } int yReal = y0 << 4; - BlockStateContainer bsc = extendedblockstorage.getData(); + BlockStateContainer bsc = section.getData(); // the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x; // for better cache locality, iterate in that order for (int y = 0; y < 16; y++) { diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index 5519d5023..e20a92be4 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -84,7 +84,7 @@ public final class GameEventHandler implements IEventBus, Helper { // to make sure the chunk being unloaded is already loaded. boolean isPreUnload = state == EventState.PRE && type == ChunkEvent.Type.UNLOAD - && world.getChunkProvider().getChunk(event.getX(), event.getZ(), false, false) != null; + && world.getChunkProvider().getChunk(event.getX(), event.getZ(), null, false) != null; if (isPostPopulate || isPreUnload) { baritone.getWorldProvider().ifWorldLoaded(worldData -> { diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index bdad4e7cb..d485d9c4a 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -25,12 +25,12 @@ import baritone.utils.BlockStateInterface; import baritone.utils.ToolSet; import baritone.utils.pathing.BetterWorldBorder; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; -import net.minecraft.client.entity.ClientPlayerEntity; +import net.minecraft.block.BlockState; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Items; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -83,7 +83,7 @@ public class CalculationContext { this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread); this.toolSet = new ToolSet(player); this.hasThrowaway = Baritone.settings().allowPlace.value && ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway(); - this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && InventoryPlayer.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.getDimension().isNether(); + this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && PlayerInventory.isHotbar(player.inventory.getSlotFor(STACK_BUCKET_WATER)) && !world.getDimension().isNether(); this.canSprint = Baritone.settings().allowSprint.value && player.getFoodStats().getFoodLevel() > 6; this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value; this.allowBreak = Baritone.settings().allowBreak.value; diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index eaa512a61..a021d8cce 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -24,7 +24,7 @@ import baritone.api.pathing.movement.MovementStatus; import baritone.api.utils.*; import baritone.api.utils.input.Input; import baritone.utils.BlockStateInterface; -import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.item.FallingBlockEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -107,7 +107,7 @@ public abstract class Movement implements IMovement, MovementHelper { */ @Override public MovementStatus update() { - ctx.player().abilities.isFlying = false; + ctx.player().playerAbilities.isFlying = false; currentState = updateState(currentState); if (MovementHelper.isLiquid(ctx, ctx.playerFeet())) { currentState.setInput(Input.JUMP, true); @@ -142,7 +142,7 @@ public abstract class Movement implements IMovement, MovementHelper { } boolean somethingInTheWay = false; for (BetterBlockPos blockPos : positionsToBreak) { - if (!ctx.world().getEntitiesWithinAABB(EntityFallingBlock.class, new AxisAlignedBB(0, 0, 0, 1, 1.1, 1).offset(blockPos)).isEmpty() && Baritone.settings().pauseMiningForFallingBlocks.value) { + if (!ctx.world().getEntitiesWithinAABB(FallingBlockEntity.class, new AxisAlignedBB(0, 0, 0, 1, 1.1, 1).offset(blockPos)).isEmpty() && Baritone.settings().pauseMiningForFallingBlocks.value) { return false; } if (!MovementHelper.canWalkThrough(ctx, blockPos)) { // can't break air, so don't try diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index 79e98f8a8..edd26c32a 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -27,18 +27,13 @@ import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.BlockStateInterface; import baritone.utils.ToolSet; import net.minecraft.block.*; -import net.minecraft.block.state.BlockState; -import net.minecraft.fluid.FlowingFluid; -import net.minecraft.fluid.Fluid; -import net.minecraft.fluid.IFluidState; -import net.minecraft.fluid.WaterFluid; -import net.minecraft.init.Blocks; -import net.minecraft.init.Fluids; +import net.minecraft.fluid.*; import net.minecraft.pathfinding.PathType; import net.minecraft.state.BooleanProperty; import net.minecraft.state.properties.SlabType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; @@ -56,7 +51,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean avoidBreaking(BlockStateInterface bsi, int x, int y, int z, BlockState state) { Block b = state.getBlock(); return b == Blocks.ICE // ice becomes water, and water can mess up the path - || b instanceof BlockSilverfish // obvious reasons + || b instanceof SilverfishBlock // obvious reasons // call context.get directly with x,y,z. no need to make 5 new BlockPos for no reason || avoidAdjacentBreaking(bsi, x, y + 1, z, true) || avoidAdjacentBreaking(bsi, x + 1, y, z, false) @@ -73,9 +68,9 @@ public interface MovementHelper extends ActionCosts, Helper { Block block = state.getBlock(); if (!directlyAbove // it is fine to mine a block that has a falling block directly above, this (the cost of breaking the stacked fallings) is included in cost calculations // therefore if directlyAbove is true, we will actually ignore if this is falling - && block instanceof BlockFalling // obviously, this check is only valid for falling blocks + && block instanceof FallingBlock // obviously, this check is only valid for falling blocks && Baritone.settings().avoidUpdatingFallingBlocks.value // and if the setting is enabled - && BlockFalling.canFallThrough(bsi.get0(x, y - 1, z))) { // and if it would fall (i.e. it's unsupported) + && FallingBlock.canFallThrough(bsi.get0(x, y - 1, z))) { // and if it would fall (i.e. it's unsupported) return true; // dont break a block that is adjacent to unsupported gravel because it can cause really weird stuff } return !state.getFluidState().isEmpty(); @@ -91,25 +86,25 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean canWalkThrough(BlockStateInterface bsi, int x, int y, int z, BlockState state) { Block block = state.getBlock(); - if (block instanceof BlockAir) { // early return for most common case + if (block instanceof AirBlock) { // early return for most common case return true; } - if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block == Blocks.BUBBLE_COLUMN || block instanceof BlockShulkerBox || block instanceof BlockSlab || block instanceof BlockTrapDoor) { + if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof SkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock) { return false; } if (Baritone.settings().blocksToAvoid.value.contains(block)) { return false; } - if (block instanceof BlockDoor || block instanceof BlockFenceGate) { + if (block instanceof DoorBlock || block instanceof FenceGateBlock) { // Because there's no nice method in vanilla to check if a door is openable or not, we just have to assume // that anything that isn't an iron door isn't openable, ignoring that some doors introduced in mods can't // be opened by just interacting. return block != Blocks.IRON_DOOR; } - if (block instanceof BlockCarpet) { + if (block instanceof CarpetBlock) { return canWalkOn(bsi, x, y - 1, z); } - if (block instanceof BlockSnowLayer) { + if (block instanceof SnowBlock) { // we've already checked doors and fence gates // so the only remaining dynamic isPassables are snow and trapdoor // if they're cached as a top block, we don't know their metadata @@ -119,7 +114,7 @@ public interface MovementHelper extends ActionCosts, Helper { } // the check in BlockSnow.isPassable is layers < 5 // while actually, we want < 3 because 3 or greater makes it impassable in a 2 high ceiling - if (state.get(BlockSnowLayer.LAYERS) >= 3) { + if (state.get(SnowBlock.LAYERS) >= 3) { return false; } // ok, it's low enough we could walk through it, but is it supported? @@ -134,7 +129,7 @@ public interface MovementHelper extends ActionCosts, Helper { return false; } BlockState up = bsi.get0(x, y + 1, z); - if (!up.getFluidState().isEmpty() || up.getBlock() instanceof BlockLilyPad) { + if (!up.getFluidState().isEmpty() || up.getBlock() instanceof LilyPadBlock) { return false; } return true; @@ -161,7 +156,7 @@ public interface MovementHelper extends ActionCosts, Helper { static boolean fullyPassable(BlockState state) { Block block = state.getBlock(); - if (block instanceof BlockAir) { // early return for most common case + if (block instanceof AirBlock) { // early return for most common case return true; } // exceptions - blocks that are isPassable true, but we can't actually jump through @@ -171,14 +166,14 @@ public interface MovementHelper extends ActionCosts, Helper { || block == Blocks.VINE || block == Blocks.LADDER || block == Blocks.COCOA - || block instanceof BlockDoor - || block instanceof BlockFenceGate - || block instanceof BlockSnow + || block instanceof DoorBlock + || block instanceof FenceGateBlock + || block instanceof SnowBlock || !state.getFluidState().isEmpty() - || block instanceof BlockTrapDoor - || block instanceof BlockEndPortal - || block instanceof BlockSkull - || block instanceof BlockShulkerBox) { + || block instanceof TrapDoorBlock + || block instanceof EndPortalBlock + || block instanceof SkullBlock + || block instanceof ShulkerBoxBlock) { return false; } // door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters @@ -197,16 +192,16 @@ public interface MovementHelper extends ActionCosts, Helper { * } */ Block block = state.getBlock(); - if (block instanceof BlockAir) { + if (block instanceof AirBlock) { // early return for common cases hehe return true; } - if (block instanceof BlockSnowLayer) { + if (block instanceof SnowBlock) { // as before, default to true (mostly because it would otherwise make long distance pathing through snowy biomes impossible) if (!bsi.worldContainsLoadedChunk(x, z)) { return true; } - return state.get(BlockSnowLayer.LAYERS) == 1; + return state.get(SnowBlock.LAYERS) == 1; } if (block == Blocks.LARGE_FERN || block == Blocks.TALL_GRASS) { return true; @@ -220,11 +215,11 @@ public interface MovementHelper extends ActionCosts, Helper { } BlockState state = BlockStateInterface.get(ctx, doorPos); - if (!(state.getBlock() instanceof BlockDoor)) { + if (!(state.getBlock() instanceof DoorBlock)) { return true; } - return isHorizontalBlockPassable(doorPos, state, playerPos, BlockDoor.OPEN); + return isHorizontalBlockPassable(doorPos, state, playerPos, DoorBlock.OPEN); } static boolean isGatePassable(IPlayerContext ctx, BlockPos gatePos, BlockPos playerPos) { @@ -233,11 +228,11 @@ public interface MovementHelper extends ActionCosts, Helper { } BlockState state = BlockStateInterface.get(ctx, gatePos); - if (!(state.getBlock() instanceof BlockFenceGate)) { + if (!(state.getBlock() instanceof FenceGateBlock)) { return true; } - return state.get(BlockFenceGate.OPEN); + return state.get(FenceGateBlock.OPEN); } static boolean isHorizontalBlockPassable(BlockPos blockPos, BlockState blockState, BlockPos playerPos, BooleanProperty propertyOpen) { @@ -245,7 +240,7 @@ public interface MovementHelper extends ActionCosts, Helper { return false; } - Direction.Axis facing = blockState.get(BlockHorizontal.HORIZONTAL_FACING).getAxis(); + Direction.Axis facing = blockState.get(HorizontalBlock.HORIZONTAL_FACING).getAxis(); boolean open = blockState.get(propertyOpen); Direction.Axis playerFacing; @@ -285,12 +280,12 @@ public interface MovementHelper extends ActionCosts, Helper { */ static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) { Block block = state.getBlock(); - if (block instanceof BlockAir || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) { + if (block instanceof AirBlock || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) { // early return for most common case (air) // plus magma, which is a normal cube but it hurts you return false; } - if (state.isBlockNormalCube()) { + if (isBlockNormalCube(state)) { return true; } if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.value)) { // TODO reconsider this @@ -307,7 +302,7 @@ public interface MovementHelper extends ActionCosts, Helper { // BlockPos s that we'd just garbage collect immediately is actually noticeable. I don't even think its a decrease in readability BlockState upState = bsi.get0(x, y + 1, z); Block up = upState.getBlock(); - if (up == Blocks.LILY_PAD || up instanceof BlockCarpet) { + if (up == Blocks.LILY_PAD || up instanceof CarpetBlock) { return true; } if (isFlowing(x, y, z, state, bsi) || upState.getFluidState().getFluid() == Fluids.FLOWING_WATER) { @@ -321,16 +316,16 @@ public interface MovementHelper extends ActionCosts, Helper { if (Baritone.settings().assumeWalkOnLava.value && isLava(state) && !isFlowing(x, y, z, state, bsi)) { return true; } - if (block == Blocks.GLASS || block instanceof BlockStainedGlass) { + if (block == Blocks.GLASS || block instanceof StainedGlassBlock) { return true; } - if (block instanceof BlockSlab) { + if (block instanceof SlabBlock) { if (!Baritone.settings().allowWalkOnBottomSlab.value) { - return state.isTopSolid(); + return state.get(SlabBlock.TYPE) != SlabType.BOTTOM; } return true; } - return block instanceof BlockStairs; + return block instanceof StairsBlock; } static boolean canWalkOn(IPlayerContext ctx, BetterBlockPos pos, BlockState state) { @@ -365,7 +360,7 @@ public interface MovementHelper extends ActionCosts, Helper { // can we look at the center of a side face of this block and likely be able to place? // (thats how this check is used) // therefore dont include weird things that we technically could place against (like carpet) but practically can't - return state.isBlockNormalCube() || state.isFullCube() || state.getBlock() == Blocks.GLASS || state.getBlock() instanceof BlockStainedGlass; + return isBlockNormalCube(state) || isFullCube(state) || state.getBlock() == Blocks.GLASS || state.getBlock() instanceof StainedGlassBlock; } static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, boolean includeFalling) { @@ -394,7 +389,7 @@ public interface MovementHelper extends ActionCosts, Helper { result *= mult; if (includeFalling) { BlockState above = context.get(x, y + 1, z); - if (above.getBlock() instanceof BlockFalling) { + if (above.getBlock() instanceof FallingBlock) { result += getMiningDurationTicks(context, x, y + 1, z, above, true); } } @@ -404,8 +399,8 @@ public interface MovementHelper extends ActionCosts, Helper { } static boolean isBottomSlab(BlockState state) { - return state.getBlock() instanceof BlockSlab - && state.get(BlockSlab.TYPE) == SlabType.BOTTOM; + return state.getBlock() instanceof SlabBlock + && state.get(SlabBlock.TYPE) == SlabType.BOTTOM; } /** @@ -502,6 +497,13 @@ public interface MovementHelper extends ActionCosts, Helper { || possiblyFlowing(bsi.get0(x, y, z - 1)); } + static boolean isBlockNormalCube(BlockState state) { + return state.isBlockNormalCube(); + } + + static boolean isFullCube(BlockState state){ + return state.isFullCube(); + } static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown) { IPlayerContext ctx = baritone.getPlayerContext(); @@ -524,7 +526,7 @@ public interface MovementHelper extends ActionCosts, Helper { double faceZ = (placeAt.getZ() + against1.getZ() + 1.0D) * 0.5D; Rotation place = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations()); RayTraceResult res = RayTraceUtils.rayTraceTowards(ctx.player(), place, ctx.playerController().getBlockReachDistance()); - if (res != null && res.getType() == RayTraceResult.Type.BLOCK && res.getBlockPos().equals(against1) && res.getBlockPos().offset(res.sideHit).equals(placeAt)) { + if (res != null && res.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) res).getPos().equals(against1) && ((BlockRayTraceResult) res).getPos().offset(((BlockRayTraceResult) res).getFace()).equals(placeAt)) { state.setTarget(new MovementState.MovementTarget(place, true)); found = true; @@ -538,7 +540,7 @@ public interface MovementHelper extends ActionCosts, Helper { } if (ctx.getSelectedBlock().isPresent()) { BlockPos selectedBlock = ctx.getSelectedBlock().get(); - Direction side = ctx.objectMouseOver().sideHit; + Direction side = ((BlockRayTraceResult) ctx.objectMouseOver()).getFace(); // only way for selectedBlock.equals(placeAt) to be true is if it's replacable if (selectedBlock.equals(placeAt) || (MovementHelper.canPlaceAgainst(ctx, selectedBlock) && selectedBlock.offset(side).equals(placeAt))) { ((Baritone) baritone).getInventoryBehavior().selectThrowawayForLocation(true, placeAt.getX(), placeAt.getY(), placeAt.getZ()); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index 5c61b3ca8..4ed671760 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -27,9 +27,9 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; -import net.minecraft.block.BlockFalling; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FallingBlock; import net.minecraft.util.Direction; public class MovementAscend extends Movement { @@ -80,18 +80,18 @@ public class MovementAscend extends Movement { } } BlockState srcUp2 = context.get(x, y + 2, z); // used lower down anyway - if (context.get(x, y + 3, z).getBlock() instanceof BlockFalling && (MovementHelper.canWalkThrough(context.bsi, x, y + 1, z) || !(srcUp2.getBlock() instanceof BlockFalling))) {//it would fall on us and possibly suffocate us + if (context.get(x, y + 3, z).getBlock() instanceof FallingBlock && (MovementHelper.canWalkThrough(context.bsi, x, y + 1, z) || !(srcUp2.getBlock() instanceof FallingBlock))) {//it would fall on us and possibly suffocate us // HOWEVER, we assume that we're standing in the start position // that means that src and src.up(1) are both air // maybe they aren't now, but they will be by the time this starts // if the lower one is can't walk through and the upper one is falling, that means that by standing on src // (the presupposition of this Movement) - // we have necessarily already cleared the entire BlockFalling stack + // we have necessarily already cleared the entire FallingBlock stack // on top of our head - // as in, if we have a block, then two BlockFallings on top of it + // as in, if we have a block, then two FallingBlocks on top of it // and that block is x, y+1, z, and we'd have to clear it to even start this movement - // we don't need to worry about those BlockFallings because we've already cleared them + // we don't need to worry about those FallingBlocks because we've already cleared them return COST_INF; // you may think we only need to check srcUp2, not srcUp // however, in the scenario where glitchy world gen where unsupported sand / gravel generates @@ -189,7 +189,7 @@ public class MovementAscend extends Movement { double flatDistToNext = xAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().posX) + zAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().posZ); double sideDist = zAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().posX) + xAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().posZ); - double lateralMotion = xAxis * ctx.player().motionZ + zAxis * ctx.player().motionX; + double lateralMotion = xAxis * ctx.player().getMotion().z + zAxis * ctx.player().getMotion().x; if (Math.abs(lateralMotion) > 0.1) { return state; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index e46f868b9..1e28f5429 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -30,10 +30,10 @@ import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.pathing.MutableMoveResult; import net.minecraft.block.Block; -import net.minecraft.block.BlockFalling; -import net.minecraft.block.state.BlockState; -import net.minecraft.client.entity.ClientPlayerEntity; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FallingBlock; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -116,7 +116,7 @@ public class MovementDescend extends Movement { } public static boolean dynamicFallCost(CalculationContext context, int x, int y, int z, int destX, int destZ, double frontBreak, BlockState below, MutableMoveResult res) { - if (frontBreak != 0 && context.get(destX, y + 2, destZ).getBlock() instanceof BlockFalling) { + if (frontBreak != 0 && context.get(destX, y + 2, destZ).getBlock() instanceof FallingBlock) { // if frontBreak is 0 we can actually get through this without updating the falling block and making it actually fall // but if frontBreak is nonzero, we're breaking blocks in front, so don't let anything fall through this column, // and potentially replace the water we're going to fall into diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 2f0d49cdc..f53748c52 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -29,8 +29,8 @@ import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.pathing.MutableMoveResult; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index bc97a8911..1429ecba2 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -25,8 +25,8 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; public class MovementDownward extends Movement { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index ff84e4f52..1e6cc95d6 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -31,13 +31,13 @@ import baritone.pathing.movement.MovementState; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.pathing.MutableMoveResult; import net.minecraft.block.Block; -import net.minecraft.block.BlockLadder; -import net.minecraft.block.state.BlockState; -import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.LadderBlock; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.fluid.WaterFluid; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -84,7 +84,7 @@ public class MovementFall extends Movement { Block destBlock = destState.getBlock(); boolean isWater = destState.getFluidState().getFluid() instanceof WaterFluid; if (!isWater && willPlaceBucket() && !playerFeet.equals(dest)) { - if (!InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().getDimension().isNether()) { + if (!PlayerInventory.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().getDimension().isNether()) { return state.setStatus(MovementStatus.UNREACHABLE); } @@ -105,15 +105,15 @@ public class MovementFall extends Movement { } if (playerFeet.equals(dest) && (ctx.player().posY - playerFeet.getY() < 0.094 || isWater)) { // 0.094 because lilypads if (isWater) { // only match water, not flowing water (which we cannot pick up with a bucket) - if (InventoryPlayer.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { + if (PlayerInventory.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY); - if (ctx.player().motionY >= 0) { + if (ctx.player().getMotion().y >= 0) { return state.setInput(Input.CLICK_RIGHT, true); } else { return state; } } else { - if (ctx.player().motionY >= 0) { + if (ctx.player().getMotion().y >= 0) { return state.setStatus(MovementStatus.SUCCESS); } // don't else return state; we need to stay centered because this water might be flowing under the surface } @@ -122,8 +122,8 @@ public class MovementFall extends Movement { } } Vec3d destCenter = VecUtils.getBlockPosCenter(dest); // we are moving to the 0.5 center not the edge (like if we were falling on a ladder) - if (Math.abs(ctx.player().posX + ctx.player().motionX - destCenter.x) > 0.1 || Math.abs(ctx.player().posZ + ctx.player().motionZ - destCenter.z) > 0.1) { - if (!ctx.player().onGround && Math.abs(ctx.player().motionY) > 0.4) { + if (Math.abs(ctx.player().posX + ctx.player().getMotion().x - destCenter.x) > 0.1 || Math.abs(ctx.player().posZ + ctx.player().getMotion().z - destCenter.z) > 0.1) { + if (!ctx.player().onGround && Math.abs(ctx.player().getMotion().y) > 0.4) { state.setInput(Input.SNEAK, true); } state.setInput(Input.MOVE_FORWARD, true); @@ -150,7 +150,7 @@ public class MovementFall extends Movement { for (int i = 0; i < 15; i++) { BlockState state = ctx.world().getBlockState(ctx.playerFeet().down(i)); if (state.getBlock() == Blocks.LADDER) { - return state.get(BlockLadder.FACING); + return state.get(LadderBlock.FACING); } } return null; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index c15b57b5d..725bb7c22 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -28,11 +28,11 @@ import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import baritone.utils.pathing.MutableMoveResult; import net.minecraft.block.Block; -import net.minecraft.block.BlockStairs; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.StairsBlock; +import net.minecraft.fluid.Fluids; import net.minecraft.fluid.WaterFluid; -import net.minecraft.init.Blocks; -import net.minecraft.init.Fluids; import net.minecraft.util.Direction; public class MovementParkour extends Movement { @@ -87,7 +87,7 @@ public class MovementParkour extends Movement { return; } BlockState standingOn = context.get(x, y - 1, z); - if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof BlockStairs || MovementHelper.isBottomSlab(standingOn) || standingOn.getFluidState().getFluid() != Fluids.EMPTY) { + if (standingOn.getBlock() == Blocks.VINE || standingOn.getBlock() == Blocks.LADDER || standingOn.getBlock() instanceof StairsBlock || MovementHelper.isBottomSlab(standingOn) || standingOn.getFluidState().getFluid() != Fluids.EMPTY) { return; } int maxJump; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index 6750a782f..d3bfb5218 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -31,13 +31,10 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import net.minecraft.block.*; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.state.properties.SlabType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import java.util.Objects; - public class MovementPillar extends Movement { public MovementPillar(IBaritone baritone, BetterBlockPos start, BetterBlockPos end) { @@ -58,7 +55,7 @@ public class MovementPillar extends Movement { if (fromDown.getBlock() == Blocks.LADDER || fromDown.getBlock() == Blocks.VINE) { return COST_INF; // can't pillar from a ladder or vine onto something that isn't also climbable } - if (fromDown.getBlock() instanceof BlockSlab && !fromDown.isTopSolid()) { + if (fromDown.getBlock() instanceof SlabBlock && fromDown.get(SlabBlock.TYPE) == SlabType.BOTTOM) { return COST_INF; // can't pillar up from a bottom slab onto a non ladder } } @@ -67,7 +64,7 @@ public class MovementPillar extends Movement { } BlockState toBreak = context.get(x, y + 2, z); Block toBreakBlock = toBreak.getBlock(); - if (toBreakBlock instanceof BlockFenceGate) { // see issue #172 + if (toBreakBlock instanceof FenceGateBlock) { // see issue #172 return COST_INF; } BlockState srcUp = null; @@ -84,7 +81,7 @@ public class MovementPillar extends Movement { if (placeCost >= COST_INF) { return COST_INF; } - if (fromDown.getBlock() instanceof BlockAir) { + if (fromDown.getBlock() instanceof AirBlock) { placeCost += 0.1; // slightly (1/200th of a second) penalize pillaring on what's currently air } } @@ -103,19 +100,19 @@ public class MovementPillar extends Movement { hardness = 0; // we won't actually need to break the ladder / vine because we're going to use it } else { BlockState check = context.get(x, y + 3, z); // the block on top of the one we're going to break, could it fall on us? - if (check.getBlock() instanceof BlockFalling) { + if (check.getBlock() instanceof FallingBlock) { // see MovementAscend's identical check for breaking a falling block above our head if (srcUp == null) { srcUp = context.get(x, y + 1, z); } - if (!(toBreakBlock instanceof BlockFalling) || !(srcUp.getBlock() instanceof BlockFalling)) { + if (!(toBreakBlock instanceof FallingBlock) || !(srcUp.getBlock() instanceof FallingBlock)) { return COST_INF; } } // this is commented because it may have had a purpose, but it's very unclear what it was. it's from the minebot era. //if (!MovementHelper.canWalkOn(chkPos, check) || MovementHelper.canWalkThrough(chkPos, check)) {//if the block above where we want to break is not a full block, don't do it // TODO why does canWalkThrough mean this action is COST_INF? - // BlockFalling makes sense, and !canWalkOn deals with weird cases like if it were lava + // FallingBlock makes sense, and !canWalkOn deals with weird cases like if it were lava // but I don't understand why canWalkThrough makes it impossible // return COST_INF; //} @@ -129,23 +126,23 @@ public class MovementPillar extends Movement { } public static boolean hasAgainst(CalculationContext context, int x, int y, int z) { - return context.get(x + 1, y, z).isBlockNormalCube() || - context.get(x - 1, y, z).isBlockNormalCube() || - context.get(x, y, z + 1).isBlockNormalCube() || - context.get(x, y, z - 1).isBlockNormalCube(); + return MovementHelper.isBlockNormalCube(context.get(x + 1, y, z)) || + MovementHelper.isBlockNormalCube(context.get(x - 1, y, z)) || + MovementHelper.isBlockNormalCube(context.get(x, y, z + 1)) || + MovementHelper.isBlockNormalCube(context.get(x, y, z - 1)); } public static BlockPos getAgainst(CalculationContext context, BetterBlockPos vine) { - if (context.get(vine.north()).isBlockNormalCube()) { + if (MovementHelper.isBlockNormalCube(context.get(vine.north()))) { return vine.north(); } - if (context.get(vine.south()).isBlockNormalCube()) { + if (MovementHelper.isBlockNormalCube(context.get(vine.south()))) { return vine.south(); } - if (context.get(vine.east()).isBlockNormalCube()) { + if (MovementHelper.isBlockNormalCube(context.get(vine.east()))) { return vine.east(); } - if (context.get(vine.west()).isBlockNormalCube()) { + if (MovementHelper.isBlockNormalCube(context.get(vine.west()))) { return vine.west(); } return null; @@ -186,7 +183,7 @@ public class MovementPillar extends Movement { boolean blockIsThere = MovementHelper.canWalkOn(ctx, src) || ladder; if (ladder) { - BlockPos against = vine ? getAgainst(new CalculationContext(baritone), src) : src.offset(fromDown.get(BlockLadder.FACING).getOpposite()); + BlockPos against = vine ? getAgainst(new CalculationContext(baritone), src) : src.offset(fromDown.get(LadderBlock.FACING).getOpposite()); if (against == null) { logDebug("Unable to climb vines"); return state.setStatus(MovementStatus.UNREACHABLE); @@ -219,7 +216,7 @@ public class MovementPillar extends Movement { double diffX = ctx.player().posX - (dest.getX() + 0.5); double diffZ = ctx.player().posZ - (dest.getZ() + 0.5); double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); - double flatMotion = Math.sqrt(ctx.player().motionX * ctx.player().motionX + ctx.player().motionZ * ctx.player().motionZ); + double flatMotion = Math.sqrt(ctx.player().getMotion().x * ctx.player().getMotion().x + ctx.player().getMotion().z * ctx.player().getMotion().z); if (dist > 0.17) {//why 0.17? because it seemed like a good number, that's why //[explanation added after baritone port lol] also because it needs to be less than 0.2 because of the 0.3 sneak limit //and 0.17 is reasonably less than 0.2 @@ -239,14 +236,14 @@ public class MovementPillar extends Movement { BlockState frState = BlockStateInterface.get(ctx, src); Block fr = frState.getBlock(); // TODO: Evaluate usage of getMaterial().isReplaceable() - if (!(fr instanceof BlockAir || frState.getMaterial().isReplaceable())) { + if (!(fr instanceof AirBlock || frState.getMaterial().isReplaceable())) { RotationUtils.reachable(ctx.player(), src, ctx.playerController().getBlockReachDistance()) .map(rot -> new MovementState.MovementTarget(rot, true)) .ifPresent(state::setTarget); state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping state.setInput(Input.CLICK_LEFT, true); blockIsThere = false; - } else if (ctx.player().isSneaking() && (Objects.equals(src.down(), ctx.objectMouseOver().getBlockPos()) || Objects.equals(src, ctx.objectMouseOver().getBlockPos())) && ctx.player().posY > dest.getY() + 0.1) { + } else if (ctx.player().isSneaking() && (ctx.isLookingAt(src.down()) || ctx.isLookingAt(src)) && ctx.player().posY > dest.getY() + 0.1) { state.setInput(Input.CLICK_RIGHT, true); } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 68c4b4cc3..b275c163b 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -31,9 +31,7 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import net.minecraft.block.*; -import net.minecraft.block.state.BlockState; import net.minecraft.fluid.WaterFluid; -import net.minecraft.init.Blocks; import net.minecraft.state.properties.SlabType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -133,7 +131,7 @@ public class MovementTraverse extends Movement { } } // now that we've checked all possible directions to side place, we actually need to backplace - if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && down.get(BlockSlab.TYPE) != SlabType.DOUBLE)) { + if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof SlabBlock && down.get(SlabBlock.TYPE) != SlabType.DOUBLE)) { return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/ } if (down.getFluidState() instanceof WaterFluid) { @@ -181,7 +179,7 @@ public class MovementTraverse extends Movement { // it's safe to do this since the two blocks we break (in a traverse) are right on top of each other and so will have the same yaw float yawToDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), dest), ctx.playerRotations()).getYaw(); float pitchToBreak = state.getTarget().getRotation().get().getPitch(); - if ((pb0.isFullCube() || pb0.getBlock() instanceof BlockAir && (pb1.isFullCube() || pb1.getBlock() instanceof BlockAir))) { + if ((MovementHelper.isFullCube(pb0) || pb0.getBlock() instanceof AirBlock && (MovementHelper.isFullCube(pb1) || pb1.getBlock() instanceof AirBlock))) { // in the meantime, before we're right up against the block, we can break efficiently at this angle pitchToBreak = 26; } @@ -197,16 +195,16 @@ public class MovementTraverse extends Movement { Block fd = BlockStateInterface.get(ctx, src.down()).getBlock(); boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE; - if (pb0.getBlock() instanceof BlockDoor || pb1.getBlock() instanceof BlockDoor) { - if ((pb0.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, src, dest) - || pb1.getBlock() instanceof BlockDoor && !MovementHelper.isDoorPassable(ctx, dest, src)) + if (pb0.getBlock() instanceof DoorBlock || pb1.getBlock() instanceof DoorBlock) { + if ((pb0.getBlock() instanceof DoorBlock && !MovementHelper.isDoorPassable(ctx, src, dest) + || pb1.getBlock() instanceof DoorBlock && !MovementHelper.isDoorPassable(ctx, dest, src)) && !(Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) { return state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), positionsToBreak[0]), ctx.playerRotations()), true)) .setInput(Input.CLICK_RIGHT, true); } } - if (pb0.getBlock() instanceof BlockFenceGate || pb1.getBlock() instanceof BlockFenceGate) { + if (pb0.getBlock() instanceof FenceGateBlock || pb1.getBlock() instanceof FenceGateBlock) { BlockPos blocked = !MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up()) ? positionsToBreak[0] : !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1] : null; @@ -250,14 +248,14 @@ public class MovementTraverse extends Movement { BlockState destDown = BlockStateInterface.get(ctx, dest.down()); BlockPos against = positionsToBreak[0]; if (feet.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) { - against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.get(BlockLadder.FACING).getOpposite()); + against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.get(LadderBlock.FACING).getOpposite()); } MovementHelper.moveTowards(ctx, state, against); return state; } else { wasTheBridgeBlockAlwaysThere = false; Block standingOn = BlockStateInterface.get(ctx, feet.down()).getBlock(); - if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof BlockSlab) { // see issue #118 + if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof SlabBlock) { // see issue #118 double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().posX), Math.abs(dest.getZ() + 0.5 - ctx.player().posZ)); if (dist < 0.85) { // 0.5 + 0.3 + epsilon MovementHelper.moveTowards(ctx, state, dest); diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 937c09db6..7710dcea3 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -32,7 +32,7 @@ import baritone.pathing.movement.Movement; import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.movements.*; import baritone.utils.BlockStateInterface; -import net.minecraft.init.Blocks; +import net.minecraft.block.Blocks; import net.minecraft.util.Tuple; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -353,7 +353,7 @@ public class PathExecutor implements IPathExecutor, Helper { return false; } else { // we are either onGround or in liquid - if (ctx.player().motionY < -0.1) { + if (ctx.player().getMotion().y < -0.1) { // if we are strictly moving downwards (not stationary) // we could be falling through water, which could be unsafe to splice return false; // so don't diff --git a/src/main/java/baritone/process/BackfillProcess.java b/src/main/java/baritone/process/BackfillProcess.java index 49e17a8c6..4bb8b9317 100644 --- a/src/main/java/baritone/process/BackfillProcess.java +++ b/src/main/java/baritone/process/BackfillProcess.java @@ -26,8 +26,8 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.pathing.path.PathExecutor; import baritone.utils.BaritoneProcessHelper; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.chunk.EmptyChunk; @@ -103,7 +103,7 @@ public final class BackfillProcess extends BaritoneProcessHelper { .filter(pos -> ctx.world().getBlockState(pos).getBlock() == Blocks.AIR) .filter(pos -> baritone.getBuilderProcess().placementPlausible(pos, Blocks.DIRT.getDefaultState())) .filter(pos -> !partOfCurrentMovement(pos)) - .sorted(Comparator.comparingDouble(ctx.player()::getDistanceSq).reversed()) + .sorted(Comparator.comparingDouble(ctx.playerFeet()::distanceSq).reversed()) .collect(Collectors.toList()); } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index a0f957663..368c9a509 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -36,17 +36,18 @@ import baritone.utils.PathingCommandContext; import baritone.utils.schematic.AirSchematic; import baritone.utils.schematic.Schematic; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; -import net.minecraft.block.BlockAir; -import net.minecraft.block.BlockFlowingFluid; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.AirBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.FlowingFluidBlock; +import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Direction; +import net.minecraft.util.Hand; import net.minecraft.util.Tuple; import net.minecraft.util.math.*; import net.minecraft.util.math.shapes.VoxelShape; @@ -95,7 +96,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil @Override public boolean build(String name, File schematic, Vec3i origin) { - NBTTagCompound tag; + CompoundNBT tag; try (FileInputStream fileIn = new FileInputStream(schematic)) { tag = CompressedStreamTools.readCompressed(fileIn); } catch (IOException e) { @@ -117,7 +118,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil build("clear area", new AirSchematic(widthX, heightY, lengthZ), origin); } - private static ISchematic parse(NBTTagCompound schematic) { + private static ISchematic parse(CompoundNBT schematic) { return new Schematic(schematic); } @@ -134,7 +135,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil return null; } BlockState state = schematic.desiredState(x - origin.getX(), y - origin.getY(), z - origin.getZ()); - if (state.getBlock() instanceof BlockAir) { + if (state.getBlock() instanceof AirBlock) { return null; } return state; @@ -157,7 +158,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil continue; // irrelevant } BlockState curr = bcc.bsi.get0(x, y, z); - if (!(curr.getBlock() instanceof BlockAir) && !valid(curr, desired)) { + if (!(curr.getBlock() instanceof AirBlock) && !valid(curr, desired)) { BetterBlockPos pos = new BetterBlockPos(x, y, z); Optional rot = RotationUtils.reachable(ctx.player(), pos, ctx.playerController().getBlockReachDistance()); if (rot.isPresent()) { @@ -198,7 +199,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } BlockState curr = bcc.bsi.get0(x, y, z); if (MovementHelper.isReplacable(x, y, z, curr, bcc.bsi) && !valid(curr, desired)) { - if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() instanceof BlockAir) { + if (dy == 1 && bcc.bsi.get0(x, y + 1, z).getBlock() instanceof AirBlock) { continue; } desirableOnHotbar.add(desired); @@ -238,7 +239,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil double placeZ = placeAgainstPos.z + aabb.minZ * placementMultiplier.z + aabb.maxZ * (1 - placementMultiplier.z); Rotation rot = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(placeX, placeY, placeZ), ctx.playerRotations()); RayTraceResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot, ctx.playerController().getBlockReachDistance()); - if (result != null && result.getType() == RayTraceResult.Type.BLOCK && result.getBlockPos().equals(placeAgainstPos) && result.sideHit == against.getOpposite()) { + if (result != null && result.getType() == RayTraceResult.Type.BLOCK && ((BlockRayTraceResult) result).getPos().equals(placeAgainstPos) && ((BlockRayTraceResult) result).getFace() == against.getOpposite()) { OptionalInt hotbar = hasAnyItemThatWouldPlace(toPlace, result, rot); if (hotbar.isPresent()) { return Optional.of(new Placement(hotbar.getAsInt(), placeAgainstPos, against.getOpposite(), rot)); @@ -252,7 +253,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil private OptionalInt hasAnyItemThatWouldPlace(BlockState desired, RayTraceResult result, Rotation rot) { for (int i = 0; i < 9; i++) { ItemStack stack = ctx.player().inventory.mainInventory.get(i); - if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) { + if (stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) { continue; } float originalYaw = ctx.player().rotationYaw; @@ -261,15 +262,13 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil ctx.player().rotationYaw = rot.getYaw(); ctx.player().rotationPitch = rot.getPitch(); BlockItemUseContext meme = new BlockItemUseContext(new ItemUseContext( + ctx.world(), ctx.player(), + Hand.MAIN_HAND, stack, - result.getBlockPos().offset(result.sideHit), - result.sideHit, - (float) result.hitVec.x - result.getBlockPos().getX(), - (float) result.hitVec.y - result.getBlockPos().getY(), - (float) result.hitVec.z - result.getBlockPos().getZ() - )); - BlockState wouldBePlaced = ((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(meme); + (BlockRayTraceResult) result + ) {}); // that {} gives us access to a protected constructor lmfao + BlockState wouldBePlaced = ((BlockItem) stack.getItem()).getBlock().getStateForPlacement(meme); ctx.player().rotationYaw = originalYaw; ctx.player().rotationPitch = originalPitch; if (wouldBePlaced == null) { @@ -404,7 +403,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil baritone.getLookBehavior().updateTarget(rot, true); ctx.player().inventory.currentItem = toPlace.get().hotbarSelection; baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true); - if ((ctx.isLookingAt(toPlace.get().placeAgainst) && ctx.objectMouseOver().sideHit.equals(toPlace.get().side)) || ctx.playerRotations().isReallyCloseTo(rot)) { + if ((ctx.isLookingAt(toPlace.get().placeAgainst) && ((BlockRayTraceResult) ctx.objectMouseOver()).getFace().equals(toPlace.get().side)) || ctx.playerRotations().isReallyCloseTo(rot)) { baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true); } return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL); @@ -466,7 +465,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil private void trim() { HashSet copy = new HashSet<>(incorrectPositions); - copy.removeIf(pos -> pos.distanceSq(ctx.player().posX, ctx.player().posY, ctx.player().posZ) > 200); + copy.removeIf(pos -> pos.distanceSq(new BlockPos(ctx.player())) > 200); if (!copy.isEmpty()) { incorrectPositions = copy; } @@ -535,12 +534,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil List sourceLiquids = new ArrayList<>(); incorrectPositions.forEach(pos -> { BlockState state = bcc.bsi.get0(pos); - if (state.getBlock() instanceof BlockAir) { + if (state.getBlock() instanceof AirBlock) { if (approxPlacable.contains(bcc.getSchematic(pos.x, pos.y, pos.z))) { placable.add(pos); } } else { - if (state.getBlock() instanceof BlockFlowingFluid) { + if (state.getBlock() instanceof FlowingFluidBlock) { // if the block itself is JUST a liquid (i.e. not just a waterlogged block), we CANNOT break it // TODO for 1.13 make sure that this only matches pure water, not waterlogged blocks if (!MovementHelper.possiblyFlowing(state)) { @@ -615,10 +614,10 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } private Goal placementGoal(BlockPos pos, BuilderCalculationContext bcc) { - if (!(ctx.world().getBlockState(pos).getBlock() instanceof BlockAir)) { // TODO can this even happen? + if (!(ctx.world().getBlockState(pos).getBlock() instanceof AirBlock)) { // TODO can this even happen? return new GoalPlace(pos); } - boolean allowSameLevel = !(ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir); + boolean allowSameLevel = !(ctx.world().getBlockState(pos.up()).getBlock() instanceof AirBlock); for (Direction facing : Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP) { if (MovementHelper.canPlaceAgainst(ctx, pos.offset(facing)) && placementPlausible(pos, bcc.getSchematic(pos.getX(), pos.getY(), pos.getZ()))) { return new GoalAdjacent(pos, allowSameLevel); @@ -628,7 +627,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } private Goal breakGoal(BlockPos pos, BuilderCalculationContext bcc) { - if (Baritone.settings().goalBreakFromAbove.value && bcc.bsi.get0(pos.up()).getBlock() instanceof BlockAir && bcc.bsi.get0(pos.up(2)).getBlock() instanceof BlockAir) { // TODO maybe possible without the up(2) check? + if (Baritone.settings().goalBreakFromAbove.value && bcc.bsi.get0(pos.up()).getBlock() instanceof AirBlock && bcc.bsi.get0(pos.up(2)).getBlock() instanceof AirBlock) { // TODO maybe possible without the up(2) check? return new JankyGoalComposite(new GoalBreak(pos), new GoalGetToBlock(pos.up()) { @Override public boolean isInGoal(int x, int y, int z) { @@ -700,12 +699,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil List result = new ArrayList<>(); for (int i = 0; i < size; i++) { ItemStack stack = ctx.player().inventory.mainInventory.get(i); - if (stack.isEmpty() || !(stack.getItem() instanceof ItemBlock)) { + if (stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) { result.add(Blocks.AIR.getDefaultState()); continue; } // - result.add(((ItemBlock) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.player(), stack, ctx.playerFeet(), Direction.UP, (float) ctx.player().posX, (float) ctx.player().posY, (float) ctx.player().posZ)))); + result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vec3d(ctx.player().posX, ctx.player().posY, ctx.player().posZ), Direction.UP, ctx.playerFeet(), false)) {}))); // } return result; @@ -715,7 +714,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (desired == null) { return true; } - if (current.getBlock() instanceof BlockAir && desired.getBlock() instanceof BlockAir) { + if (current.getBlock() instanceof AirBlock && desired.getBlock() instanceof AirBlock) { return true; } // TODO more complicated comparison logic I guess @@ -757,7 +756,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil BlockState sch = getSchematic(x, y, z); if (sch != null) { // TODO this can return true even when allowPlace is off.... is that an issue? - if (sch.getBlock() instanceof BlockAir) { + if (sch.getBlock() instanceof AirBlock) { // we want this to be air, but they're asking if they can place here // this won't be a schematic block, this will be a throwaway return placeBlockCost * 2; // we're going to have to break it eventually @@ -790,7 +789,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil } BlockState sch = getSchematic(x, y, z); if (sch != null) { - if (sch.getBlock() instanceof BlockAir) { + if (sch.getBlock() instanceof AirBlock) { // it should be air // regardless of current contents, we can break it return 1; diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 3e9b47493..d7bce3ae9 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -31,13 +31,11 @@ import baritone.cache.WorldScanner; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import net.minecraft.block.*; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -94,29 +92,29 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro } private enum Harvest { - WHEAT((BlockCrops) Blocks.WHEAT), - CARROTS((BlockCrops) Blocks.CARROTS), - POTATOES((BlockCrops) Blocks.POTATOES), - BEETROOT((BlockCrops) Blocks.BEETROOTS), + WHEAT((CropsBlock) Blocks.WHEAT), + CARROTS((CropsBlock) Blocks.CARROTS), + POTATOES((CropsBlock) Blocks.POTATOES), + BEETROOT((CropsBlock) Blocks.BEETROOTS), PUMPKIN(Blocks.PUMPKIN, state -> true), MELON(Blocks.MELON, state -> true), - NETHERWART(Blocks.NETHER_WART, state -> state.get(BlockNetherWart.AGE) >= 3), + NETHERWART(Blocks.NETHER_WART, state -> state.get(NetherWartBlock.AGE) >= 3), SUGARCANE(Blocks.SUGAR_CANE, null) { @Override public boolean readyToHarvest(World world, BlockPos pos, BlockState state) { - return world.getBlockState(pos.down()).getBlock() instanceof BlockReed; + return world.getBlockState(pos.down()).getBlock() instanceof SugarCaneBlock; } }, CACTUS(Blocks.CACTUS, null) { @Override public boolean readyToHarvest(World world, BlockPos pos, BlockState state) { - return world.getBlockState(pos.down()).getBlock() instanceof BlockCactus; + return world.getBlockState(pos.down()).getBlock() instanceof CactusBlock; } }; public final Block block; public final Predicate readyToHarvest; - Harvest(BlockCrops blockCrops) { + Harvest(CropsBlock blockCrops) { this(blockCrops, blockCrops::isMaxAge); // max age is 7 for wheat, carrots, and potatoes, but 3 for beetroot } @@ -171,7 +169,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro List openSoulsand = new ArrayList<>(); for (BlockPos pos : locations) { BlockState state = ctx.world().getBlockState(pos); - boolean airAbove = ctx.world().getBlockState(pos.up()).getBlock() instanceof BlockAir; + boolean airAbove = ctx.world().getBlockState(pos.up()).getBlock() instanceof AirBlock; if (state.getBlock() == Blocks.FARMLAND) { if (airAbove) { openFarmland.add(pos); @@ -258,8 +256,8 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro } } for (Entity entity : ctx.world().loadedEntityList) { - if (entity instanceof EntityItem && entity.onGround) { - EntityItem ei = (EntityItem) entity; + if (entity instanceof ItemEntity && entity.onGround) { + ItemEntity ei = (ItemEntity) entity; if (PICKUP_DROPPED.contains(ei.getItem().getItem())) { // +0.1 because of farmland's 0.9375 dummy height lol goalz.add(new GoalBlock(new BlockPos(entity.posX, entity.posY + 0.1, entity.posZ))); diff --git a/src/main/java/baritone/process/FollowProcess.java b/src/main/java/baritone/process/FollowProcess.java index 4fcb13624..072943bd8 100644 --- a/src/main/java/baritone/process/FollowProcess.java +++ b/src/main/java/baritone/process/FollowProcess.java @@ -82,7 +82,7 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo } private void scanWorld() { - cache = Stream.of(ctx.world().loadedEntityList, ctx.world().playerEntities).flatMap(List::stream).filter(this::followable).filter(this.filter).distinct().collect(Collectors.toCollection(ArrayList::new)); + cache = Stream.of(ctx.world().loadedEntityList, ctx.world().getPlayers()).flatMap(List::stream).filter(this::followable).filter(this.filter).distinct().collect(Collectors.toCollection(ArrayList::new)); } @Override diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 4c43cd6f2..ae4190e12 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -26,10 +26,11 @@ import baritone.api.utils.Rotation; import baritone.api.utils.RotationUtils; import baritone.api.utils.input.Input; import baritone.pathing.movement.CalculationContext; +import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.ContainerPlayer; +import net.minecraft.block.Blocks; +import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.util.math.BlockPos; import java.util.*; @@ -121,7 +122,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG // blacklist the closest block and its adjacent blocks public synchronized boolean blacklistClosest() { List newBlacklist = new ArrayList<>(); - knownLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(newBlacklist::add); + knownLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq)).ifPresent(newBlacklist::add); outer: while (true) { for (BlockPos known : knownLocations) { @@ -180,7 +181,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG if (walkIntoInsteadOfAdjacent(gettingTo)) { return new GoalTwoBlocks(pos); } - if (blockOnTopMustBeRemoved(gettingTo) && baritone.bsi.get0(pos.up()).isBlockNormalCube()) { + if (blockOnTopMustBeRemoved(gettingTo) && MovementHelper.isBlockNormalCube(baritone.bsi.get0(pos.up()))) { // TODO this should be the check for chest openability return new GoalBlock(pos.up()); } return new GoalGetToBlock(pos); @@ -194,7 +195,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG if (knownLocations.contains(ctx.getSelectedBlock().orElse(null))) { baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true); // TODO find some way to right click even if we're in an ESC menu System.out.println(ctx.player().openContainer); - if (!(ctx.player().openContainer instanceof ContainerPlayer)) { + if (!(ctx.player().openContainer instanceof PlayerContainer)) { return true; } } diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index c3992e5e6..f1da9117e 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -33,13 +33,9 @@ import baritone.pathing.movement.CalculationContext; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import baritone.utils.BlockStateInterface; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.block.BlockFalling; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.*; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.init.Blocks; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -91,7 +87,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro if (calcFailed) { if (!knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) { logDirect("Unable to find any path to " + mining + ", blacklisting presumably unreachable closest instance..."); - knownOreLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(blacklist::add); + knownOreLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq)).ifPresent(blacklist::add); knownOreLocations.removeIf(blacklist::contains); } else { logDirect("Unable to find any path to " + mining + ", canceling Mine"); @@ -111,8 +107,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro Optional shaft = curr.stream() .filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ()) .filter(pos -> pos.getY() >= ctx.playerFeet().getY()) - .filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof BlockAir)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =( - .min(Comparator.comparingDouble(ctx.player()::getDistanceSq)); + .filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof AirBlock)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =( + .min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq)); baritone.getInputOverrideHandler().clearAllKeys(); if (shaft.isPresent()) { BlockPos pos = shaft.get(); @@ -211,14 +207,14 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro return true; } Block block = BlockStateInterface.getBlock(ctx, pos); - if (Baritone.settings().internalMiningAirException.value && block instanceof BlockAir) { + if (Baritone.settings().internalMiningAirException.value && block instanceof AirBlock) { return true; } return mining.contains(block); } private Goal coalesce(BlockPos loc, List locs) { - boolean assumeVerticalShaftMine = !(baritone.bsi.get0(loc.up()).getBlock() instanceof BlockFalling); + boolean assumeVerticalShaftMine = !(baritone.bsi.get0(loc.up()).getBlock() instanceof FallingBlock); if (!Baritone.settings().forceInternalMining.value) { if (assumeVerticalShaftMine) { // we can get directly below the block @@ -292,8 +288,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro } List ret = new ArrayList<>(); for (Entity entity : world.loadedEntityList) { - if (entity instanceof EntityItem) { - EntityItem ei = (EntityItem) entity; + if (entity instanceof ItemEntity) { + ItemEntity ei = (ItemEntity) entity; if (searchingFor.contains(ei.getItem().getItem())) { ret.add(new BlockPos(entity)); } @@ -369,7 +365,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro .filter(pos -> !blacklist.contains(pos)) - .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player()::getDistanceSq)) + .sorted(Comparator.comparingDouble(new BlockPos(ctx.getBaritone().getPlayerContext().player())::distanceSq)) .collect(Collectors.toList()); if (locs.size() > max) { diff --git a/src/main/java/baritone/utils/BaritoneAutoTest.java b/src/main/java/baritone/utils/BaritoneAutoTest.java index 6827f29eb..bb4e7ede2 100644 --- a/src/main/java/baritone/utils/BaritoneAutoTest.java +++ b/src/main/java/baritone/utils/BaritoneAutoTest.java @@ -26,10 +26,13 @@ import baritone.api.utils.Helper; import baritone.api.utils.IPlayerContext; import net.minecraft.client.GameSettings; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.screen.MainMenuScreen; +import net.minecraft.client.settings.AmbientOcclusionStatus; +import net.minecraft.client.settings.CloudOption; +import net.minecraft.client.settings.ParticleStatus; import net.minecraft.client.tutorial.TutorialSteps; import net.minecraft.server.integrated.IntegratedServer; -import net.minecraft.util.HttpUtil; +import net.minecraft.util.HTTPUtil; import net.minecraft.util.math.BlockPos; import net.minecraft.world.GameType; import net.minecraft.world.WorldSettings; @@ -71,14 +74,14 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper { GameSettings s = mc.gameSettings; s.limitFramerate = 20; s.mipmapLevels = 0; - s.particleSetting = 2; + s.field_74362_aa = ParticleStatus.MINIMAL; s.overrideWidth = 128; s.overrideHeight = 128; s.heldItemTooltips = false; s.entityShadows = false; s.chatScale = 0.0F; - s.ambientOcclusion = 0; - s.clouds = 0; + s.ambientOcclusionStatus = AmbientOcclusionStatus.OFF; + s.field_74345_l = CloudOption.OFF; s.fancyGraphics = false; s.tutorialStep = TutorialSteps.NONE; s.hideGUI = true; @@ -89,9 +92,9 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper { public void onTick(TickEvent event) { IPlayerContext ctx = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext(); // If we're on the main menu then create the test world and launch the integrated server - if (mc.currentScreen instanceof GuiMainMenu) { + if (mc.field_71462_r instanceof MainMenuScreen) { System.out.println("Beginning Baritone automatic test routine"); - mc.displayScreen(null); + mc.displayGuiScreen(null); WorldSettings worldsettings = new WorldSettings(TEST_SEED, GameType.getByName("survival"), true, false, WorldType.DEFAULT); mc.launchIntegratedServer("BaritoneAutoTest", "BaritoneAutoTest", worldsettings); } @@ -110,7 +113,7 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper { // Force the integrated server to share the world to LAN so that // the ingame pause menu gui doesn't actually pause our game if (mc.isSingleplayer() && !mc.getIntegratedServer().getPublic()) { - mc.getIntegratedServer().shareToLAN(GameType.getByName("survival"), false, HttpUtil.getSuitableLanPort()); + mc.getIntegratedServer().shareToLAN(GameType.getByName("survival"), false, HTTPUtil.getSuitableLanPort()); } // For the first 200 ticks, wait for the world to generate diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index 449693976..2b734f73f 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -20,8 +20,9 @@ package baritone.utils; import baritone.api.utils.Helper; import baritone.api.utils.IPlayerContext; import net.minecraft.util.Direction; -import net.minecraft.util.EnumHand; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; /** @@ -40,7 +41,7 @@ public final class BlockBreakHelper implements Helper { public void tryBreakBlock(BlockPos pos, Direction side) { if (playerContext.playerController().onPlayerDamageBlock(pos, side)) { - playerContext.player().swingArm(EnumHand.MAIN_HAND); + playerContext.player().swingArm(Hand.MAIN_HAND); } } @@ -57,7 +58,7 @@ public final class BlockBreakHelper implements Helper { boolean isBlockTrace = trace != null && trace.getType() == RayTraceResult.Type.BLOCK; if (isLeftClick && isBlockTrace) { - tryBreakBlock(trace.getBlockPos(), trace.sideHit); + tryBreakBlock(((BlockRayTraceResult) trace).getPos(), ((BlockRayTraceResult) trace).getFace()); didBreakLastTick = true; } else if (didBreakLastTick) { stopBreakingBlock(); diff --git a/src/main/java/baritone/utils/BlockPlaceHelper.java b/src/main/java/baritone/utils/BlockPlaceHelper.java index a2f7e7572..875cd14c8 100644 --- a/src/main/java/baritone/utils/BlockPlaceHelper.java +++ b/src/main/java/baritone/utils/BlockPlaceHelper.java @@ -20,8 +20,9 @@ package baritone.utils; import baritone.Baritone; import baritone.api.utils.Helper; import baritone.api.utils.IPlayerContext; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; public class BlockPlaceHelper implements Helper { @@ -38,16 +39,16 @@ public class BlockPlaceHelper implements Helper { return; } RayTraceResult mouseOver = ctx.objectMouseOver(); - if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getBlockPos() == null || mouseOver.getType() != RayTraceResult.Type.BLOCK) { + if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getType() != RayTraceResult.Type.BLOCK) { return; } rightClickTimer = Baritone.settings().rightClickSpeed.value; - for (EnumHand hand : EnumHand.values()) { - if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), mouseOver.getBlockPos(), mouseOver.sideHit, mouseOver.hitVec, hand) == EnumActionResult.SUCCESS) { + for (Hand hand : Hand.values()) { + if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), hand, (BlockRayTraceResult) mouseOver) == ActionResultType.SUCCESS) { ctx.player().swingArm(hand); return; } - if (!ctx.player().getHeldItem(hand).isEmpty() && ctx.playerController().processRightClick(ctx.player(), ctx.world(), hand) == EnumActionResult.SUCCESS) { + if (!ctx.player().getHeldItem(hand).isEmpty() && ctx.playerController().processRightClick(ctx.player(), ctx.world(), hand) == ActionResultType.SUCCESS) { return; } } diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 1efca7e05..fce7e5149 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -25,13 +25,14 @@ import baritone.utils.accessor.IChunkProviderClient; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkSection; /** * Wraps get for chuck caching capability @@ -67,7 +68,7 @@ public class BlockStateInterface { this.loadedChunks = worldLoaded; // this will only be used on the main thread } this.useTheRealWorld = !Baritone.settings().pathThroughCachedOnly.value; - if (!Minecraft.getInstance().isCallingFromMinecraftThread()) { + if (!Minecraft.getInstance().isOnExecutionThread()) { throw new IllegalStateException(); } } @@ -105,14 +106,14 @@ public class BlockStateInterface { // we can just skip the mc.world.getChunk lookup // which is a Long2ObjectOpenHashMap.get // see issue #113 - if (cached != null && cached.x == x >> 4 && cached.z == z >> 4) { - return cached.getBlockState(x, y, z); + if (cached != null && cached.getPos().x == x >> 4 && cached.getPos().z == z >> 4) { + return getFromChunk(cached, x, y, z); } Chunk chunk = loadedChunks.get(ChunkPos.asLong(x >> 4, z >> 4)); - if (chunk != null && chunk.isLoaded()) { + if (chunk != null && !chunk.isEmpty()) { prev = chunk; - return chunk.getBlockState(x, y, z); + return getFromChunk(chunk, x, y, z); } } // same idea here, skip the Long2ObjectOpenHashMap.get if at all possible @@ -138,11 +139,11 @@ public class BlockStateInterface { public boolean isLoaded(int x, int z) { Chunk prevChunk = prev; - if (prevChunk != null && prevChunk.x == x >> 4 && prevChunk.z == z >> 4) { + if (prevChunk != null && prevChunk.getPos().x == x >> 4 && prevChunk.getPos().z == z >> 4) { return true; } prevChunk = loadedChunks.get(ChunkPos.asLong(x >> 4, z >> 4)); - if (prevChunk != null && prevChunk.isLoaded()) { + if (prevChunk != null && !prevChunk.isEmpty()) { prev = prevChunk; return true; } @@ -160,4 +161,13 @@ public class BlockStateInterface { prevCached = prevRegion; return prevRegion.isCached(x & 511, z & 511); } + + // get the block at x,y,z from this chunk WITHOUT creating a single blockpos object + public static BlockState getFromChunk(Chunk chunk, int x, int y, int z) { + ChunkSection section = chunk.getSections()[y >> 4]; + if (ChunkSection.isEmpty(section)) { + return AIR; + } + return section.get(x & 15, y & 15, z & 15); + } } diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 7881e604e..4429a8e7b 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -22,10 +22,13 @@ import baritone.api.BaritoneAPI; import baritone.api.pathing.goals.GoalBlock; import baritone.api.pathing.goals.GoalTwoBlocks; import baritone.api.utils.BetterBlockPos; -import net.minecraft.client.gui.Screen; -import net.minecraft.client.renderer.GlStateManager; +import baritone.api.utils.Helper; +import com.mojang.blaze3d.platform.GlStateManager; +import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.entity.Entity; import net.minecraft.util.math.*; +import net.minecraft.util.text.StringTextComponent; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; @@ -36,7 +39,7 @@ import java.util.Collections; import static org.lwjgl.opengl.GL11.*; -public class GuiClick extends Screen { +public class GuiClick extends Screen implements Helper { // My name is Brady and I grant leijurv permission to use this pasted code private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16); @@ -47,8 +50,12 @@ public class GuiClick extends Screen { private BlockPos clickStart; private BlockPos currentMouseOver; + public GuiClick() { + super(new StringTextComponent("CLICK")); + } + @Override - public boolean doesGuiPauseGame() { + public boolean isPauseScreen() { return false; } @@ -62,10 +69,12 @@ public class GuiClick extends Screen { Vec3d near = toWorld(mx, my, 0); Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv if (near != null && far != null) { - Vec3d viewerPos = new Vec3d(mc.getRenderManager().viewerPosX, mc.getRenderManager().viewerPosY, mc.getRenderManager().viewerPosZ); - RayTraceResult result = mc.world.rayTraceBlocks(near.add(viewerPos), far.add(viewerPos), RayTraceFluidMode.NEVER, false, true); + /// + Vec3d viewerPos = new Vec3d(PathRenderer.posX(), PathRenderer.posY(), PathRenderer.posZ()); + ClientPlayerEntity player = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().player(); + RayTraceResult result = player.world.func_217299_a(new RayTraceContext(near.add(viewerPos), far.add(viewerPos), RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player)); if (result != null && result.getType() == RayTraceResult.Type.BLOCK) { - currentMouseOver = result.getBlockPos(); + currentMouseOver = ((BlockRayTraceResult) result).getPos(); } } @@ -94,8 +103,8 @@ public class GuiClick extends Screen { } public void onRender() { - GlStateManager.getFloatv(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear()); - GlStateManager.getFloatv(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear()); + GlStateManager.getMatrix(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear()); + GlStateManager.getMatrix(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear()); GL11.glGetIntegerv(GL_VIEWPORT, (IntBuffer) VIEWPORT.clear()); if (currentMouseOver != null) { @@ -107,7 +116,7 @@ public class GuiClick extends Screen { GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); GlStateManager.color4f(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F); GlStateManager.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value); - GlStateManager.disableTexture2D(); + GlStateManager.disableTexture(); GlStateManager.depthMask(false); GlStateManager.disableDepthTest(); BetterBlockPos a = new BetterBlockPos(currentMouseOver); @@ -116,7 +125,7 @@ public class GuiClick extends Screen { GlStateManager.enableDepthTest(); GlStateManager.depthMask(true); - GlStateManager.enableTexture2D(); + GlStateManager.enableTexture(); GlStateManager.disableBlend(); } } diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index 86797548c..40b09ea97 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -27,11 +27,11 @@ import baritone.api.utils.Helper; import baritone.api.utils.interfaces.IGoalRenderPos; import baritone.behavior.PathingBehavior; import baritone.pathing.path.PathExecutor; -import net.minecraft.block.state.BlockState; +import com.mojang.blaze3d.platform.GlStateManager; +import net.minecraft.block.BlockState; import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer; +import net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; @@ -60,11 +60,23 @@ public final class PathRenderer implements Helper { private PathRenderer() {} + public static double posX() { + return mc.getRenderManager().viewerPosX; + } + + public static double posY() { + return mc.getRenderManager().viewerPosY; + } + + public static double posZ() { + return mc.getRenderManager().viewerPosZ; + } + public static void render(RenderEvent event, PathingBehavior behavior) { float partialTicks = event.getPartialTicks(); Goal goal = behavior.getGoal(); - if (mc.currentScreen instanceof GuiClick) { - ((GuiClick) mc.currentScreen).onRender(); + if (mc.field_71462_r instanceof GuiClick) { + ((GuiClick) mc.field_71462_r).onRender(); } int thisPlayerDimension = behavior.baritone.getPlayerContext().world().getDimension().getType().getId(); @@ -137,7 +149,7 @@ public final class PathRenderer implements Helper { GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); GlStateManager.color4f(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F); GlStateManager.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value); - GlStateManager.disableTexture2D(); + GlStateManager.disableTexture(); GlStateManager.depthMask(false); if (Baritone.settings().renderPathIgnoreDepth.value) { GlStateManager.disableDepthTest(); @@ -187,14 +199,14 @@ public final class PathRenderer implements Helper { } //GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f); GlStateManager.depthMask(true); - GlStateManager.enableTexture2D(); + GlStateManager.enableTexture(); GlStateManager.disableBlend(); } public static void drawLine(double bp1x, double bp1y, double bp1z, double bp2x, double bp2y, double bp2z) { - double d0 = mc.getRenderManager().viewerPosX; - double d1 = mc.getRenderManager().viewerPosY; - double d2 = mc.getRenderManager().viewerPosZ; + double d0 = posX(); + double d1 = posY(); + double d2 = posZ(); BUFFER.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION); BUFFER.pos(bp1x + 0.5D - d0, bp1y + 0.5D - d1, bp1z + 0.5D - d2).endVertex(); BUFFER.pos(bp2x + 0.5D - d0, bp2y + 0.5D - d1, bp2z + 0.5D - d2).endVertex(); @@ -208,7 +220,7 @@ public final class PathRenderer implements Helper { GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); GlStateManager.color4f(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F); GlStateManager.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value); - GlStateManager.disableTexture2D(); + GlStateManager.disableTexture(); GlStateManager.depthMask(false); if (Baritone.settings().renderSelectionBoxesIgnoreDepth.value) { @@ -231,13 +243,13 @@ public final class PathRenderer implements Helper { } GlStateManager.depthMask(true); - GlStateManager.enableTexture2D(); + GlStateManager.enableTexture(); GlStateManager.disableBlend(); } public static void drawAABB(AxisAlignedBB aabb) { float expand = 0.002F; - AxisAlignedBB toDraw = aabb.expand(expand, expand, expand).offset(-mc.getRenderManager().viewerPosX, -mc.getRenderManager().viewerPosY, -mc.getRenderManager().viewerPosZ); + AxisAlignedBB toDraw = aabb.expand(expand, expand, expand).offset(-posX(), -posY(), -posZ()); BUFFER.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION); BUFFER.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex(); BUFFER.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex(); @@ -265,9 +277,9 @@ public final class PathRenderer implements Helper { } public static void drawDankLitGoalBox(Entity player, Goal goal, float partialTicks, Color color) { - double renderPosX = mc.getRenderManager().viewerPosX; - double renderPosY = mc.getRenderManager().viewerPosY; - double renderPosZ = mc.getRenderManager().viewerPosZ; + double renderPosX = posX(); + double renderPosY = posY(); + double renderPosZ = posZ(); double minX; double maxX; double minZ; @@ -307,7 +319,7 @@ public final class PathRenderer implements Helper { GlStateManager.disableDepthTest(); } - TileEntityBeaconRenderer.renderBeamSegment( + BeaconTileEntityRenderer.renderBeamSegment( goalPos.getX() - renderPosX, -renderPosY, goalPos.getZ() - renderPosZ, @@ -363,7 +375,7 @@ public final class PathRenderer implements Helper { GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); GlStateManager.color4f(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.6F); GlStateManager.lineWidth(Baritone.settings().goalRenderLineWidthPixels.value); - GlStateManager.disableTexture2D(); + GlStateManager.disableTexture(); GlStateManager.depthMask(false); if (Baritone.settings().renderGoalIgnoreDepth.value) { GlStateManager.disableDepthTest(); @@ -387,7 +399,7 @@ public final class PathRenderer implements Helper { GlStateManager.enableDepthTest(); } GlStateManager.depthMask(true); - GlStateManager.enableTexture2D(); + GlStateManager.enableTexture(); GlStateManager.disableBlend(); } diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 9e7cde488..a3b8f5478 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -19,13 +19,13 @@ package baritone.utils; import baritone.Baritone; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; -import net.minecraft.client.entity.ClientPlayerEntity; +import net.minecraft.block.BlockState; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.init.Enchantments; -import net.minecraft.init.MobEffects; +import net.minecraft.enchantment.Enchantments; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; +import net.minecraft.item.ToolItem; +import net.minecraft.potion.Effects; import java.util.HashMap; import java.util.Map; @@ -80,7 +80,7 @@ public class ToolSet { * @return Either 1 or -1 */ private int getMaterialCost(ItemStack itemStack) { - return itemStack.getItem() instanceof ItemTool ? 1 : -1; + return itemStack.getItem() instanceof ToolItem ? 1 : -1; } /** @@ -165,11 +165,11 @@ public class ToolSet { */ private double potionAmplifier() { double speed = 1; - if (player.isPotionActive(MobEffects.HASTE)) { - speed *= 1 + (player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2; + if (player.isPotionActive(Effects.field_76422_e)) { + speed *= 1 + (player.getActivePotionEffect(Effects.field_76422_e).getAmplifier() + 1) * 0.2; } - if (player.isPotionActive(MobEffects.MINING_FATIGUE)) { - switch (player.getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier()) { + if (player.isPotionActive(Effects.field_76419_f)) { + switch (player.getActivePotionEffect(Effects.field_76419_f).getAmplifier()) { case 0: speed *= 0.3; break; diff --git a/src/main/java/baritone/utils/accessor/IChunkProviderServer.java b/src/main/java/baritone/utils/accessor/IChunkProviderServer.java index e527cb508..bf24fbfe5 100644 --- a/src/main/java/baritone/utils/accessor/IChunkProviderServer.java +++ b/src/main/java/baritone/utils/accessor/IChunkProviderServer.java @@ -17,7 +17,7 @@ package baritone.utils.accessor; -import net.minecraft.world.chunk.storage.IChunkLoader; +import net.minecraft.world.chunk.storage.ChunkLoader; /** * @author Brady @@ -25,5 +25,5 @@ import net.minecraft.world.chunk.storage.IChunkLoader; */ public interface IChunkProviderServer { - IChunkLoader getChunkLoader(); + ChunkLoader getChunkLoader(); } diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index c4b12336e..2cee04c56 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -21,7 +21,7 @@ import baritone.Baritone; import baritone.api.utils.BetterBlockPos; import baritone.api.utils.IPlayerContext; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; -import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.MobEntity; import net.minecraft.util.math.BlockPos; import java.util.ArrayList; @@ -69,7 +69,7 @@ public class Avoidance { } if (mobCoeff != 1.0D) { ctx.world().loadedEntityList.stream() - .filter(entity -> entity instanceof EntityMob) + .filter(entity -> entity instanceof MobEntity) .forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value))); } return res; diff --git a/src/main/java/baritone/utils/player/PrimaryPlayerContext.java b/src/main/java/baritone/utils/player/PrimaryPlayerContext.java index 07a66c5c2..c1bfb3948 100644 --- a/src/main/java/baritone/utils/player/PrimaryPlayerContext.java +++ b/src/main/java/baritone/utils/player/PrimaryPlayerContext.java @@ -23,7 +23,7 @@ import baritone.api.utils.Helper; import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerController; import baritone.api.utils.RayTraceUtils; -import net.minecraft.client.entity.ClientPlayerEntity; +import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; diff --git a/src/main/java/baritone/utils/player/PrimaryPlayerController.java b/src/main/java/baritone/utils/player/PrimaryPlayerController.java index f44d0c745..42904fef4 100644 --- a/src/main/java/baritone/utils/player/PrimaryPlayerController.java +++ b/src/main/java/baritone/utils/player/PrimaryPlayerController.java @@ -19,16 +19,16 @@ package baritone.utils.player; import baritone.api.utils.Helper; import baritone.api.utils.IPlayerController; -import net.minecraft.client.entity.ClientPlayerEntity; -import net.minecraft.client.multiplayer.ClientWorld; +import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.ClickType; +import net.minecraft.inventory.container.ClickType; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; -import net.minecraft.util.EnumHand; +import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.GameType; import net.minecraft.world.World; @@ -44,37 +44,38 @@ public enum PrimaryPlayerController implements IPlayerController, Helper { @Override public boolean onPlayerDamageBlock(BlockPos pos, Direction side) { - return mc.playerController.onPlayerDamageBlock(pos, side); + + return mc.field_71442_b.onPlayerDamageBlock(pos, side); } @Override public void resetBlockRemoving() { - mc.playerController.resetBlockRemoving(); + mc.field_71442_b.resetBlockRemoving(); } @Override public ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, PlayerEntity player) { - return mc.playerController.windowClick(windowId, slotId, mouseButton, type, player); + return mc.field_71442_b.windowClick(windowId, slotId, mouseButton, type, player); } @Override public void setGameType(GameType type) { - mc.playerController.setGameType(type); + mc.field_71442_b.setGameType(type); } @Override public GameType getGameType() { - return mc.playerController.getCurrentGameType(); + return mc.field_71442_b.getCurrentGameType(); } @Override - public EnumActionResult processRightClickBlock(ClientPlayerEntity player, World world, BlockPos pos, Direction direction, Vec3d vec, EnumHand hand) { + public ActionResultType processRightClickBlock(ClientPlayerEntity player, World world, Hand hand, BlockRayTraceResult result) { // primaryplayercontroller is always in a ClientWorld so this is ok - return mc.playerController.processRightClickBlock(player, (ClientWorld) world, pos, direction, vec, hand); + return mc.field_71442_b.func_217292_a(player, (ClientWorld) world, hand, result); } @Override - public EnumActionResult processRightClick(ClientPlayerEntity player, World world, EnumHand hand) { - return mc.playerController.processRightClick(player, world, hand); + public ActionResultType processRightClick(ClientPlayerEntity player, World world, Hand hand) { + return mc.field_71442_b.processRightClick(player, world, hand); } } diff --git a/src/main/java/baritone/utils/schematic/AirSchematic.java b/src/main/java/baritone/utils/schematic/AirSchematic.java index 5d58da564..c314abaf1 100644 --- a/src/main/java/baritone/utils/schematic/AirSchematic.java +++ b/src/main/java/baritone/utils/schematic/AirSchematic.java @@ -18,8 +18,8 @@ package baritone.utils.schematic; import baritone.api.utils.ISchematic; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; public class AirSchematic implements ISchematic { diff --git a/src/main/java/baritone/utils/schematic/MapArtSchematic.java b/src/main/java/baritone/utils/schematic/MapArtSchematic.java index c9260b2b4..347215722 100644 --- a/src/main/java/baritone/utils/schematic/MapArtSchematic.java +++ b/src/main/java/baritone/utils/schematic/MapArtSchematic.java @@ -17,9 +17,9 @@ package baritone.utils.schematic; -import net.minecraft.block.BlockAir; -import net.minecraft.block.state.BlockState; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.block.AirBlock; +import net.minecraft.block.BlockState; +import net.minecraft.nbt.CompoundNBT; import java.util.OptionalInt; import java.util.function.Predicate; @@ -28,7 +28,7 @@ public class MapArtSchematic extends Schematic { private final int[][] heightMap; - public MapArtSchematic(NBTTagCompound schematic) { + public MapArtSchematic(CompoundNBT schematic) { super(schematic); heightMap = new int[widthX][lengthZ]; @@ -36,7 +36,7 @@ public class MapArtSchematic extends Schematic { for (int z = 0; z < lengthZ; z++) { BlockState[] column = states[x][z]; - OptionalInt lowestBlockY = lastIndexMatching(column, block -> !(block instanceof BlockAir)); + OptionalInt lowestBlockY = lastIndexMatching(column, state -> !(state.getBlock() instanceof AirBlock)); if (lowestBlockY.isPresent()) { heightMap[x][z] = lowestBlockY.getAsInt(); } else { diff --git a/src/main/java/baritone/utils/schematic/Schematic.java b/src/main/java/baritone/utils/schematic/Schematic.java index 16ce286a6..736e09415 100644 --- a/src/main/java/baritone/utils/schematic/Schematic.java +++ b/src/main/java/baritone/utils/schematic/Schematic.java @@ -18,8 +18,8 @@ package baritone.utils.schematic; import baritone.api.utils.ISchematic; -import net.minecraft.block.state.BlockState; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.block.BlockState; +import net.minecraft.nbt.CompoundNBT; public class Schematic implements ISchematic { public final int widthX; @@ -27,7 +27,7 @@ public class Schematic implements ISchematic { public final int lengthZ; protected final BlockState[][][] states; - public Schematic(NBTTagCompound schematic) { + public Schematic(CompoundNBT schematic) { /*String type = schematic.getString("Materials"); if (!type.equals("Alpha")) { throw new IllegalStateException("bad schematic " + type);