Fix quest chests not having drop data

This commit is contained in:
KingRainbow44 2023-06-01 21:28:12 -04:00
parent 43f3494073
commit cef8b53dd6
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
2 changed files with 21 additions and 5 deletions

View File

@ -75,6 +75,7 @@ public class GadgetChest extends GadgetContent {
} else if (chest.chest_drop_id != 0) {
status = dropSystem.handleChestDrop(chest.chest_drop_id, chest.drop_count, getGadget());
}
if (status) {
getGadget().updateState(ScriptGadgetState.ChestOpened);
player.sendPacket(

View File

@ -1,15 +1,13 @@
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.GadgetData;
import emu.grasscutter.data.excels.ItemData;
import emu.grasscutter.data.excels.monster.MonsterData;
import emu.grasscutter.game.entity.*;
import emu.grasscutter.game.world.Position;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.*;
import emu.grasscutter.net.proto.QuestCreateEntityReqOuterClass.QuestCreateEntityReq;
import emu.grasscutter.scripts.data.SceneGadget;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketQuestCreateEntityRsp;
import lombok.val;
@ -30,12 +28,29 @@ public class HandlerQuestCreateEntityReq extends PacketHandler {
case GADGET_ID -> {
val gadgetId = entity.getGadgetId();
val gadgetInfo = entity.getGadget();
GadgetData gadgetData = GameData.getGadgetDataMap().get(gadgetId);
var gadgetData = GameData.getGadgetDataMap().get(gadgetId);
gameEntity =
switch (gadgetData.getType()) {
case Vehicle -> new EntityVehicle(scene, session.getPlayer(), gadgetId, 0, pos, rot);
case Chest -> {
var chest = gadgetInfo.getChest();
var gadget = new EntityGadget(scene, gadgetId, pos, rot);
// Create the gadget data for the chest.
var metaGadget = new SceneGadget();
metaGadget.drop_count = 1; // TODO: Check if more items should be dropped.
metaGadget.chest_drop_id = chest.getChestDropId();
metaGadget.setShowcutscene(chest.getIsShowCutscene());
// Apply the gadget data to the chest.
gadget.setMetaGadget(metaGadget);
yield gadget;
}
default -> new EntityGadget(scene, gadgetId, pos, rot);
};
if (gameEntity instanceof EntityGadget gadget) {
gadget.buildContent();
}
}
case ITEM_ID -> {
val itemId = entity.getItemId();