Merge branch 'master' of github.com:cabaletta/baritone

This commit is contained in:
Leijurv 2018-08-05 17:16:49 -04:00
commit 10212601c8
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
6 changed files with 41 additions and 11 deletions

View File

@ -4,6 +4,7 @@ import baritone.bot.behavior.Behavior;
import baritone.bot.event.IGameEventListener;
import baritone.bot.event.events.ChatEvent;
import baritone.bot.event.events.ChunkEvent;
import baritone.bot.event.events.RenderEvent;
import baritone.bot.event.events.WorldEvent;
import net.minecraft.client.settings.KeyBinding;
import org.lwjgl.input.Keyboard;
@ -16,8 +17,7 @@ import java.util.function.Consumer;
*/
public final class GameEventHandler implements IGameEventListener {
GameEventHandler() {
}
GameEventHandler() {}
@Override
public final void onTick() {
@ -81,8 +81,8 @@ public final class GameEventHandler implements IGameEventListener {
}
@Override
public void onRenderPass() {
dispatch(Behavior::onRenderPass);
public void onRenderPass(RenderEvent event) {
dispatch(behavior -> onRenderPass(event));
}
@Override

View File

@ -13,7 +13,7 @@ public final class CachedChunk implements IBlockTypeAccess {
/**
* The size of the chunk data in bits. Equal to 16 KiB.
* <br>
* <p>
* Chunks are 16x16x256, each block requires 2 bits.
*/
public static final int SIZE = 2 * 16 * 16 * 256;
@ -40,7 +40,7 @@ public final class CachedChunk implements IBlockTypeAccess {
/**
* The actual raw data of this packed chunk.
* <br>
* <p>
* Each block is expressed as 2 bits giving a total of 16 KiB
*/
private final BitSet data;

View File

@ -2,6 +2,7 @@ package baritone.bot.event;
import baritone.bot.event.events.ChatEvent;
import baritone.bot.event.events.ChunkEvent;
import baritone.bot.event.events.RenderEvent;
import baritone.bot.event.events.WorldEvent;
/**
@ -35,7 +36,7 @@ public interface AbstractGameEventListener extends IGameEventListener {
default void onChunkEvent(ChunkEvent event) {}
@Override
default void onRenderPass() {}
default void onRenderPass(RenderEvent event) {}
@Override
default void onWorldEvent(WorldEvent event) {}

View File

@ -2,11 +2,13 @@ package baritone.bot.event;
import baritone.bot.event.events.ChatEvent;
import baritone.bot.event.events.ChunkEvent;
import baritone.bot.event.events.RenderEvent;
import baritone.bot.event.events.WorldEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.settings.GameSettings;
/**
* @author Brady
@ -50,11 +52,13 @@ public interface IGameEventListener {
void onChunkEvent(ChunkEvent event);
/**
* Runs once each frame
* Runs once per world render pass. Two passes are made when {@link GameSettings#anaglyph} is on.
* <p>
* <b>Note:</b> {@link GameSettings#anaglyph} has been removed in Minecraft 1.13
*
* @see EntityRenderer#renderWorldPass(int, float, long)
*/
void onRenderPass();
void onRenderPass(RenderEvent event);
/**
* Runs before and after whenever a new world is loaded

View File

@ -0,0 +1,24 @@
package baritone.bot.event.events;
/**
* @author Brady
* @since 8/5/2018 12:28 AM
*/
public final class RenderEvent {
/**
* The current render partial ticks
*/
private final float partialTicks;
public RenderEvent(float partialTicks) {
this.partialTicks = partialTicks;
}
/**
* @return The current render partial ticks
*/
public final float getPartialTicks() {
return this.partialTicks;
}
}

View File

@ -1,6 +1,7 @@
package baritone.launch.mixins;
import baritone.bot.Baritone;
import baritone.bot.event.events.RenderEvent;
import net.minecraft.client.renderer.EntityRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -18,7 +19,7 @@ public class MixinEntityRenderer {
args = { "ldc=hand" }
)
)
private void renderWorldPass(CallbackInfo ci) {
Baritone.INSTANCE.getGameEventHandler().onRenderPass();
private void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
Baritone.INSTANCE.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
}
}