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.IGameEventListener;
|
||||||
import baritone.bot.event.events.ChatEvent;
|
import baritone.bot.event.events.ChatEvent;
|
||||||
import baritone.bot.event.events.ChunkEvent;
|
import baritone.bot.event.events.ChunkEvent;
|
||||||
|
import baritone.bot.event.events.RenderEvent;
|
||||||
import baritone.bot.event.events.WorldEvent;
|
import baritone.bot.event.events.WorldEvent;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
@ -16,8 +17,7 @@ import java.util.function.Consumer;
|
|||||||
*/
|
*/
|
||||||
public final class GameEventHandler implements IGameEventListener {
|
public final class GameEventHandler implements IGameEventListener {
|
||||||
|
|
||||||
GameEventHandler() {
|
GameEventHandler() {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onTick() {
|
public final void onTick() {
|
||||||
@ -81,8 +81,8 @@ public final class GameEventHandler implements IGameEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRenderPass() {
|
public void onRenderPass(RenderEvent event) {
|
||||||
dispatch(Behavior::onRenderPass);
|
dispatch(behavior -> onRenderPass(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,7 @@ public final class CachedChunk implements IBlockTypeAccess {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the chunk data in bits. Equal to 16 KiB.
|
* The size of the chunk data in bits. Equal to 16 KiB.
|
||||||
* <br>
|
* <p>
|
||||||
* Chunks are 16x16x256, each block requires 2 bits.
|
* Chunks are 16x16x256, each block requires 2 bits.
|
||||||
*/
|
*/
|
||||||
public static final int SIZE = 2 * 16 * 16 * 256;
|
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.
|
* The actual raw data of this packed chunk.
|
||||||
* <br>
|
* <p>
|
||||||
* Each block is expressed as 2 bits giving a total of 16 KiB
|
* Each block is expressed as 2 bits giving a total of 16 KiB
|
||||||
*/
|
*/
|
||||||
private final BitSet data;
|
private final BitSet data;
|
||||||
|
@ -2,6 +2,7 @@ package baritone.bot.event;
|
|||||||
|
|
||||||
import baritone.bot.event.events.ChatEvent;
|
import baritone.bot.event.events.ChatEvent;
|
||||||
import baritone.bot.event.events.ChunkEvent;
|
import baritone.bot.event.events.ChunkEvent;
|
||||||
|
import baritone.bot.event.events.RenderEvent;
|
||||||
import baritone.bot.event.events.WorldEvent;
|
import baritone.bot.event.events.WorldEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +36,7 @@ public interface AbstractGameEventListener extends IGameEventListener {
|
|||||||
default void onChunkEvent(ChunkEvent event) {}
|
default void onChunkEvent(ChunkEvent event) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void onRenderPass() {}
|
default void onRenderPass(RenderEvent event) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void onWorldEvent(WorldEvent event) {}
|
default void onWorldEvent(WorldEvent event) {}
|
||||||
|
@ -2,11 +2,13 @@ package baritone.bot.event;
|
|||||||
|
|
||||||
import baritone.bot.event.events.ChatEvent;
|
import baritone.bot.event.events.ChatEvent;
|
||||||
import baritone.bot.event.events.ChunkEvent;
|
import baritone.bot.event.events.ChunkEvent;
|
||||||
|
import baritone.bot.event.events.RenderEvent;
|
||||||
import baritone.bot.event.events.WorldEvent;
|
import baritone.bot.event.events.WorldEvent;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
import net.minecraft.client.renderer.EntityRenderer;
|
import net.minecraft.client.renderer.EntityRenderer;
|
||||||
|
import net.minecraft.client.settings.GameSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
@ -50,11 +52,13 @@ public interface IGameEventListener {
|
|||||||
void onChunkEvent(ChunkEvent event);
|
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)
|
* @see EntityRenderer#renderWorldPass(int, float, long)
|
||||||
*/
|
*/
|
||||||
void onRenderPass();
|
void onRenderPass(RenderEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs before and after whenever a new world is loaded
|
* 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;
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
import baritone.bot.Baritone;
|
import baritone.bot.Baritone;
|
||||||
|
import baritone.bot.event.events.RenderEvent;
|
||||||
import net.minecraft.client.renderer.EntityRenderer;
|
import net.minecraft.client.renderer.EntityRenderer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@ -18,7 +19,7 @@ public class MixinEntityRenderer {
|
|||||||
args = { "ldc=hand" }
|
args = { "ldc=hand" }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private void renderWorldPass(CallbackInfo ci) {
|
private void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
|
||||||
Baritone.INSTANCE.getGameEventHandler().onRenderPass();
|
Baritone.INSTANCE.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user