Implement clone in drive menu
This commit is contained in:
parent
b0e9a96e50
commit
f1f1ce897c
@ -303,6 +303,25 @@ public class DriveViewerMenu extends PoweredMatteryMenu {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (click == ClickType.CLONE) {
|
||||||
|
if (stack_id < 0 || !ply.getAbilities().instabuild)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var get_state = view.state.get(stack_id);
|
||||||
|
|
||||||
|
if (get_state == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var copy = get_state.stack.copy();
|
||||||
|
copy.setCount(Math.min(copy.getCount(), copy.getMaxStackSize()));
|
||||||
|
|
||||||
|
menu.setCarried(copy);
|
||||||
|
MatteryNetworking.send(ply, new SetCarriedPacket(menu.getCarried()));
|
||||||
|
menu.setRemoteCarried(menu.getCarried().copy());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!menu.getCarried().isEmpty() && click != ClickType.QUICK_MOVE) {
|
if (!menu.getCarried().isEmpty() && click != ClickType.QUICK_MOVE) {
|
||||||
// try to put
|
// try to put
|
||||||
if (action == ClickAction.PRIMARY) {
|
if (action == ClickAction.PRIMARY) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ru.dbotthepony.mc.otm.screen;
|
package ru.dbotthepony.mc.otm.screen;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.inventory.ClickAction;
|
import net.minecraft.world.inventory.ClickAction;
|
||||||
@ -79,9 +80,9 @@ public class DriveViewerScreen extends MatteryScreen<DriveViewerMenu> implements
|
|||||||
protected boolean mouseClickedInner(double mouse_x, double mouse_y, int mouse_click_type) {
|
protected boolean mouseClickedInner(double mouse_x, double mouse_y, int mouse_click_type) {
|
||||||
int findex = index + scroll_bar.getScroll(GRID_WIDTH);
|
int findex = index + scroll_bar.getScroll(GRID_WIDTH);
|
||||||
var list = menu.view.getItems();
|
var list = menu.view.getItems();
|
||||||
var action = mouse_click_type == 0 ? ClickAction.PRIMARY : ClickAction.SECONDARY;
|
var action = mouse_click_type == InputConstants.MOUSE_BUTTON_LEFT ? ClickAction.PRIMARY : ClickAction.SECONDARY;
|
||||||
|
|
||||||
var type = hasShiftDown() ? ClickType.QUICK_MOVE : ClickType.PICKUP;
|
var type = mouse_click_type == InputConstants.MOUSE_BUTTON_MIDDLE ? ClickType.CLONE : hasShiftDown() ? ClickType.QUICK_MOVE : ClickType.PICKUP;
|
||||||
|
|
||||||
MatteryNetworking.send(new DriveViewerMenu.InteractPacket(menu.containerId, findex >= list.size() ? -1 : list.get(findex).id(), type, action));
|
MatteryNetworking.send(new DriveViewerMenu.InteractPacket(menu.containerId, findex >= list.size() ? -1 : list.get(findex).id(), type, action));
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user