mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 07:37:43 +00:00
Gadgets can be picked up too (#2272)
* Gadgets can be picked up too * put in a warning
This commit is contained in:
parent
ddc082fc97
commit
fe169398ec
@ -59,12 +59,11 @@ public final class GadgetGatherObject extends GadgetContent {
|
||||
GameItem item = new GameItem(itemData, 1);
|
||||
player.getInventory().addItem(item, ActionReason.Gather);
|
||||
|
||||
getGadget()
|
||||
.getScene()
|
||||
.getScriptManager()
|
||||
.callEvent(
|
||||
new ScriptArgs(
|
||||
getGadget().getGroupId(), EventType.EVENT_GATHER, getGadget().getConfigId()));
|
||||
var ScriptArgs = new ScriptArgs(getGadget().getGroupId(), EventType.EVENT_GATHER, getGadget().getConfigId());
|
||||
if(getGadget().getMetaGadget() != null){
|
||||
ScriptArgs.setEventSource(getGadget().getMetaGadget().config_id);
|
||||
}
|
||||
getGadget().getScene().getScriptManager().callEvent(ScriptArgs);
|
||||
|
||||
getGadget()
|
||||
.getScene()
|
||||
|
@ -1,18 +1,52 @@
|
||||
package emu.grasscutter.game.entity.gadget;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.GatherData;
|
||||
import emu.grasscutter.data.excels.ItemData;
|
||||
import emu.grasscutter.game.entity.EntityGadget;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.net.proto.GadgetInteractReqOuterClass;
|
||||
import emu.grasscutter.net.proto.InteractTypeOuterClass;
|
||||
import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass;
|
||||
import emu.grasscutter.scripts.constants.EventType;
|
||||
import emu.grasscutter.scripts.data.ScriptArgs;
|
||||
import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp;
|
||||
|
||||
public class GadgetObject extends GadgetContent {
|
||||
private int itemId;
|
||||
|
||||
public GadgetObject(EntityGadget gadget) {
|
||||
super(gadget);
|
||||
GatherData gatherData = GameData.getGatherDataMap().get(gadget.getPointType());
|
||||
if (gatherData != null) {
|
||||
this.itemId = gatherData.getItemId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInteract(Player player, GadgetInteractReqOuterClass.GadgetInteractReq req) {
|
||||
return false;
|
||||
// This is a workaround until a proper gadget interaction system can be put in place.
|
||||
ItemData itemData = GameData.getItemDataMap().get(this.itemId);
|
||||
if (itemData == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GameItem item = new GameItem(itemData, 1);
|
||||
player.getInventory().addItem(item, ActionReason.Gather);
|
||||
|
||||
var ScriptArgs = new ScriptArgs(getGadget().getGroupId(), EventType.EVENT_GATHER, getGadget().getConfigId());
|
||||
if(getGadget().getMetaGadget() != null){
|
||||
ScriptArgs.setEventSource(getGadget().getMetaGadget().config_id);
|
||||
}
|
||||
getGadget().getScene().getScriptManager().callEvent(ScriptArgs);
|
||||
|
||||
getGadget()
|
||||
.getScene()
|
||||
.broadcastPacket(
|
||||
new PacketGadgetInteractRsp(getGadget(), InteractTypeOuterClass.InteractType.INTERACT_TYPE_GATHER));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user