rendering: add clear chunk combination, send debug chat message

This commit is contained in:
Bixilon 2021-02-26 20:46:30 +01:00
parent f3da647ebf
commit c4c762951b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 32 additions and 1 deletions

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.config.config.game.controls
import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames.DEBUG_CLEAR_CHUNK_CACHE
import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames.DEBUG_MOUSE_CATCH
import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames.DEBUG_POLYGEN
import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames.DEBUG_SCREEN
@ -108,6 +109,13 @@ data class KeyBindingsGameConfig(
),
mutableSetOf(mutableSetOf(WHEN_IN_GAME))
),
DEBUG_CLEAR_CHUNK_CACHE to KeyBinding(
mutableMapOf(
KeyAction.MODIFIER to mutableSetOf(KeyCodes.KEY_F3),
KeyAction.RELEASE to mutableSetOf(KeyCodes.KEY_A)
),
mutableSetOf(mutableSetOf(WHEN_IN_GAME))
),
),
)
@ -125,6 +133,7 @@ object KeyBindingsNames {
val QUIT_RENDERING = ResourceLocation("minosoft:quit_rendering")
val DEBUG_SCREEN = ResourceLocation("minosoft:debug_screen")
val DEBUG_CLEAR_CHUNK_CACHE = ResourceLocation("minosoft:debug_clear_chunk_cache")
val DEBUG_POLYGEN = ResourceLocation("minosoft:debug_polygen")
val DEBUG_MOUSE_CATCH = ResourceLocation("minosoft:debug_mouse_catch")

View File

@ -27,6 +27,8 @@ public enum StatisticCategories {
KILLED(new ChangeableResourceLocation("minecraft.killed"), 6),
KILLED_BY(new ChangeableResourceLocation("minecraft.killed_by"), 7),
CUSTOM(new ChangeableResourceLocation("minecraft.custom"), 8);
private final ChangeableResourceLocation changeableResourceLocation;
private final int id;

View File

@ -266,6 +266,7 @@ class RenderWindow(private val connection: Connection, val rendering: Rendering)
} else {
GL_FILL
})
connection.sender.sendFakeChatMessage("§f[§e§lDEBUG§f] §9Toggled polygen mode!")
}
registerKeyCallback(KeyBindingsNames.DEBUG_MOUSE_CATCH) { _: KeyCodes, _: KeyAction ->
mouseCatch = !mouseCatch
@ -274,6 +275,7 @@ class RenderWindow(private val connection: Connection, val rendering: Rendering)
} else {
glfwSetInputMode(windowId, GLFW_CURSOR, GLFW_CURSOR_NORMAL)
}
connection.sender.sendFakeChatMessage("§f[§e§lDEBUG§f] §9Toggled mouse catch!")
}
registerKeyCallback(KeyBindingsNames.QUIT_RENDERING) { _: KeyCodes, _: KeyAction ->
glfwSetWindowShouldClose(windowId, true)

View File

@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.chunk
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.config.StaticConfiguration
import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames
import de.bixilon.minosoft.data.Directions
import de.bixilon.minosoft.data.mappings.blocks.BlockState
import de.bixilon.minosoft.data.text.RGBColor
@ -123,6 +124,12 @@ class WorldRenderer(private val connection: Connection, private val world: World
chunkShader = Shader("chunk_vertex.glsl", "chunk_fragment.glsl")
chunkShader.load()
// register keybindings
renderWindow.registerKeyCallback(KeyBindingsNames.DEBUG_CLEAR_CHUNK_CACHE) { _, _ ->
clearChunkCache()
connection.sender.sendFakeChatMessage("§f[§e§lDEBUG§f] §9Cleared chunk cache!")
prepareWorld(world)
}
}
override fun postInit() {

View File

@ -32,7 +32,7 @@ class TextureArray(val textures: List<Texture>, val maxWidth: Int, val maxHeight
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
// glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR) // ToDo: This breaks transparency again
// glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST) // ToDo: This breaks transparency again
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, maxWidth, maxHeight, textures.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, null as ByteBuffer?)

View File

@ -13,10 +13,13 @@
package de.bixilon.minosoft.protocol.protocol;
import de.bixilon.minosoft.data.ChatTextPositions;
import de.bixilon.minosoft.data.entities.EntityRotation;
import de.bixilon.minosoft.data.entities.Position;
import de.bixilon.minosoft.data.mappings.ResourceLocation;
import de.bixilon.minosoft.data.player.Hands;
import de.bixilon.minosoft.data.text.ChatComponent;
import de.bixilon.minosoft.modding.event.events.ChatMessageReceivingEvent;
import de.bixilon.minosoft.modding.event.events.ChatMessageSendingEvent;
import de.bixilon.minosoft.modding.event.events.CloseWindowEvent;
import de.bixilon.minosoft.protocol.network.Connection;
@ -126,4 +129,12 @@ public class PacketSender {
this.connection.getPlayer().getEntity().setLocation(position);
this.connection.getPlayer().getEntity().setRotation(rotation);
}
public void sendFakeChatMessage(ChatComponent message, ChatTextPositions position) {
this.connection.fireEvent(new ChatMessageReceivingEvent(this.connection, message, position, null));
}
public void sendFakeChatMessage(String message) {
sendFakeChatMessage(ChatComponent.valueOf(message), ChatTextPositions.CHAT_BOX);
}
}