mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
item dropping
This commit is contained in:
parent
caf75b323b
commit
efa4a0cf1b
@ -17,6 +17,7 @@ import de.bixilon.minosoft.config.key.KeyAction
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||
|
||||
|
||||
object KeyBindingsNames {
|
||||
@ -33,6 +34,9 @@ object KeyBindingsNames {
|
||||
|
||||
val DESTROY_BLOCK = ResourceLocation("minosoft:destroy_block")
|
||||
|
||||
val DROP_ITEM = "minosoft:drop_item".asResourceLocation()
|
||||
val DROP_ITEM_STACK = "minosoft:drop_item_stack".asResourceLocation()
|
||||
|
||||
val ZOOM = ResourceLocation("minosoft:zoom")
|
||||
|
||||
val QUIT_RENDERING = ResourceLocation("minosoft:quit_rendering")
|
||||
@ -243,5 +247,16 @@ object KeyBindingsNames {
|
||||
),
|
||||
ignoreConsumer = true,
|
||||
),
|
||||
DROP_ITEM to KeyBinding(
|
||||
mutableMapOf(
|
||||
KeyAction.PRESS to mutableSetOf(KeyCodes.KEY_Q),
|
||||
),
|
||||
),
|
||||
DROP_ITEM_STACK to KeyBinding(
|
||||
mutableMapOf(
|
||||
KeyAction.PRESS to mutableSetOf(KeyCodes.KEY_Q),
|
||||
KeyAction.MODIFIER to mutableSetOf(KeyCodes.KEY_LEFT_CONTROL)
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import java.util.Base64;
|
||||
public class GUITools {
|
||||
public static final Image MINOSOFT_LOGO = new Image(GUITools.class.getResourceAsStream("/assets/minosoft/textures/icons/window_icon.png"));
|
||||
public static final ObservableList<Version> VERSIONS = FXCollections.observableArrayList();
|
||||
public static final JFXComboBox<Version> VERSION_COMBO_BOX;
|
||||
|
||||
static {
|
||||
VERSIONS.add(Versions.AUTOMATIC_VERSION);
|
||||
@ -46,9 +47,10 @@ public class GUITools {
|
||||
}
|
||||
return -(a.getVersionId() - b.getVersionId());
|
||||
});
|
||||
|
||||
VERSION_COMBO_BOX = new JFXComboBox<>(VERSIONS);
|
||||
}
|
||||
|
||||
public static final JFXComboBox<Version> VERSION_COMBO_BOX = new JFXComboBox<>(VERSIONS);
|
||||
|
||||
public static Image getImageFromBase64(String base64) {
|
||||
if (base64 == null) {
|
||||
|
@ -34,6 +34,8 @@ import de.bixilon.minosoft.gui.rendering.util.VecUtil.floor
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.getWorldOffset
|
||||
import de.bixilon.minosoft.modding.event.CallbackEventInvoker
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.play.BlockBreakC2SP
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import glm_.func.cos
|
||||
import glm_.func.rad
|
||||
import glm_.func.sin
|
||||
@ -84,6 +86,7 @@ class Camera(
|
||||
var viewProjectionMatrix = projectionMatrix * viewMatrix
|
||||
private set
|
||||
|
||||
private var lastDropPacketSent = -1L
|
||||
|
||||
val frustum: Frustum = Frustum(this)
|
||||
|
||||
@ -123,6 +126,18 @@ class Camera(
|
||||
)
|
||||
|
||||
connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> { recalculateViewProjectionMatrix() })
|
||||
|
||||
fun dropItem(type: BlockBreakC2SP.BreakType) {
|
||||
val time = System.currentTimeMillis()
|
||||
if (time - lastDropPacketSent < ProtocolDefinition.TICK_TIME) {
|
||||
return
|
||||
}
|
||||
connection.sendPacket(BlockBreakC2SP(type, entity.positionInfo.blockPosition))
|
||||
lastDropPacketSent = time
|
||||
}
|
||||
|
||||
renderWindow.inputHandler.registerKeyCallback(KeyBindingsNames.DROP_ITEM) { dropItem(BlockBreakC2SP.BreakType.DROP_ITEM) }
|
||||
renderWindow.inputHandler.registerKeyCallback(KeyBindingsNames.DROP_ITEM_STACK) { dropItem(BlockBreakC2SP.BreakType.DROP_ITEM_STACK) }
|
||||
frustum.recalculate()
|
||||
connection.fireEvent(FrustumChangeEvent(renderWindow, frustum))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user