Merge branch 'master' of github.com:cabaletta/baritone
This commit is contained in:
commit
10212601c8
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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) {}
|
||||
|
@ -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
|
||||
|
24
src/main/java/baritone/bot/event/events/RenderEvent.java
Normal file
24
src/main/java/baritone/bot/event/events/RenderEvent.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user