mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-24 06:33:51 +08:00
Format code [skip actions]
This commit is contained in:
parent
f9dffba27a
commit
494cd3b28c
@ -454,9 +454,17 @@ public final class GameData {
|
|||||||
private static final Int2ObjectMap<GadgetMapping> gadgetMappingMap =
|
private static final Int2ObjectMap<GadgetMapping> gadgetMappingMap =
|
||||||
new Int2ObjectOpenHashMap<>();
|
new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
@Getter private static final Int2ObjectMap<SubfieldMapping> subfieldMappingMap = new Int2ObjectOpenHashMap<>();
|
@Getter
|
||||||
@Getter private static final Int2ObjectMap<DropSubfieldMapping> dropSubfieldMappingMap = new Int2ObjectOpenHashMap<>();
|
private static final Int2ObjectMap<SubfieldMapping> subfieldMappingMap =
|
||||||
@Getter private static final Int2ObjectMap<DropTableExcelConfigData> dropTableExcelConfigDataMap = new Int2ObjectOpenHashMap<>();
|
new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static final Int2ObjectMap<DropSubfieldMapping> dropSubfieldMappingMap =
|
||||||
|
new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static final Int2ObjectMap<DropTableExcelConfigData> dropTableExcelConfigDataMap =
|
||||||
|
new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static final Int2ObjectMap<MonsterMapping> monsterMappingMap =
|
private static final Int2ObjectMap<MonsterMapping> monsterMappingMap =
|
||||||
|
@ -810,8 +810,11 @@ public final class ResourceLoader {
|
|||||||
try {
|
try {
|
||||||
val subfieldMap = GameData.getSubfieldMappingMap();
|
val subfieldMap = GameData.getSubfieldMappingMap();
|
||||||
try {
|
try {
|
||||||
JsonUtils.loadToList(getResourcePath("Server/SubfieldMapping.json"), SubfieldMapping.class).forEach(entry -> subfieldMap.put(entry.getEntityId(), entry));;
|
JsonUtils.loadToList(getResourcePath("Server/SubfieldMapping.json"), SubfieldMapping.class)
|
||||||
} catch (IOException | NullPointerException ignored) {}
|
.forEach(entry -> subfieldMap.put(entry.getEntityId(), entry));
|
||||||
|
;
|
||||||
|
} catch (IOException | NullPointerException ignored) {
|
||||||
|
}
|
||||||
Grasscutter.getLogger().debug("Loaded {} subfield mappings.", subfieldMap.size());
|
Grasscutter.getLogger().debug("Loaded {} subfield mappings.", subfieldMap.size());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Grasscutter.getLogger().error("Unable to load subfield mappings.", e);
|
Grasscutter.getLogger().error("Unable to load subfield mappings.", e);
|
||||||
@ -820,8 +823,12 @@ public final class ResourceLoader {
|
|||||||
try {
|
try {
|
||||||
val dropSubfieldMap = GameData.getDropSubfieldMappingMap();
|
val dropSubfieldMap = GameData.getDropSubfieldMappingMap();
|
||||||
try {
|
try {
|
||||||
JsonUtils.loadToList(getResourcePath("Server/DropSubfieldMapping.json"), DropSubfieldMapping.class).forEach(entry -> dropSubfieldMap.put(entry.getDropId(), entry));;
|
JsonUtils.loadToList(
|
||||||
} catch (IOException | NullPointerException ignored) {}
|
getResourcePath("Server/DropSubfieldMapping.json"), DropSubfieldMapping.class)
|
||||||
|
.forEach(entry -> dropSubfieldMap.put(entry.getDropId(), entry));
|
||||||
|
;
|
||||||
|
} catch (IOException | NullPointerException ignored) {
|
||||||
|
}
|
||||||
Grasscutter.getLogger().debug("Loaded {} drop subfield mappings.", dropSubfieldMap.size());
|
Grasscutter.getLogger().debug("Loaded {} drop subfield mappings.", dropSubfieldMap.size());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Grasscutter.getLogger().error("Unable to load drop subfield mappings.", e);
|
Grasscutter.getLogger().error("Unable to load drop subfield mappings.", e);
|
||||||
@ -830,9 +837,15 @@ public final class ResourceLoader {
|
|||||||
try {
|
try {
|
||||||
val dropTableExcelConfigDataMap = GameData.getDropTableExcelConfigDataMap();
|
val dropTableExcelConfigDataMap = GameData.getDropTableExcelConfigDataMap();
|
||||||
try {
|
try {
|
||||||
JsonUtils.loadToList(getResourcePath("Server/DropTableExcelConfigData.json"), DropTableExcelConfigData.class).forEach(entry -> dropTableExcelConfigDataMap.put(entry.getId(), entry));;
|
JsonUtils.loadToList(
|
||||||
} catch (IOException | NullPointerException ignored) {}
|
getResourcePath("Server/DropTableExcelConfigData.json"),
|
||||||
Grasscutter.getLogger().debug("Loaded {} drop table configs.", dropTableExcelConfigDataMap.size());
|
DropTableExcelConfigData.class)
|
||||||
|
.forEach(entry -> dropTableExcelConfigDataMap.put(entry.getId(), entry));
|
||||||
|
;
|
||||||
|
} catch (IOException | NullPointerException ignored) {
|
||||||
|
}
|
||||||
|
Grasscutter.getLogger()
|
||||||
|
.debug("Loaded {} drop table configs.", dropTableExcelConfigDataMap.size());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Grasscutter.getLogger().error("Unable to load drop table config data.", e);
|
Grasscutter.getLogger().error("Unable to load drop table config data.", e);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,8 @@ package emu.grasscutter.data.binout;
|
|||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import emu.grasscutter.data.common.DynamicFloat;
|
import emu.grasscutter.data.common.DynamicFloat;
|
||||||
import emu.grasscutter.game.props.ElementType;
|
import emu.grasscutter.game.props.ElementType;
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
public class AbilityModifier implements Serializable {
|
public class AbilityModifier implements Serializable {
|
||||||
private static final long serialVersionUID = -2001232313615923575L;
|
private static final long serialVersionUID = -2001232313615923575L;
|
||||||
|
@ -3,9 +3,8 @@ package emu.grasscutter.game.ability;
|
|||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.data.binout.AbilityMixinData;
|
import emu.grasscutter.data.binout.AbilityMixinData;
|
||||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
public class AbilityLocalIdGenerator {
|
public class AbilityLocalIdGenerator {
|
||||||
@ -38,12 +37,14 @@ public class AbilityLocalIdGenerator {
|
|||||||
this.actionIndex++;
|
this.actionIndex++;
|
||||||
|
|
||||||
var id = GetLocalId();
|
var id = GetLocalId();
|
||||||
localIdToAction.put((int)id, actions[i]);
|
localIdToAction.put((int) id, actions[i]);
|
||||||
|
|
||||||
if(actions[i].actions != null) this.initializeActionLocalIds(actions[i].actions, localIdToAction);
|
if (actions[i].actions != null)
|
||||||
|
this.initializeActionLocalIds(actions[i].actions, localIdToAction);
|
||||||
else {
|
else {
|
||||||
if (actions[i].successActions != null)
|
if (actions[i].successActions != null)
|
||||||
this.initializeActionLocalIds(actions[i].successActions, localIdToAction); //Need to check this specific order
|
this.initializeActionLocalIds(
|
||||||
|
actions[i].successActions, localIdToAction); // Need to check this specific order
|
||||||
if (actions[i].failActions != null)
|
if (actions[i].failActions != null)
|
||||||
this.initializeActionLocalIds(actions[i].failActions, localIdToAction);
|
this.initializeActionLocalIds(actions[i].failActions, localIdToAction);
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,8 @@ import emu.grasscutter.scripts.data.controller.EntityController;
|
|||||||
import emu.grasscutter.server.event.entity.*;
|
import emu.grasscutter.server.event.entity.*;
|
||||||
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
|
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
|
||||||
import it.unimi.dsi.fastutil.ints.*;
|
import it.unimi.dsi.fastutil.ints.*;
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
public abstract class GameEntity {
|
public abstract class GameEntity {
|
||||||
@Getter private final Scene scene;
|
@Getter private final Scene scene;
|
||||||
@ -230,40 +229,45 @@ public abstract class GameEntity {
|
|||||||
|
|
||||||
private int[] parseCountRange(String range) {
|
private int[] parseCountRange(String range) {
|
||||||
var split = range.split(";");
|
var split = range.split(";");
|
||||||
if(split.length == 1) return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[0])};
|
if (split.length == 1)
|
||||||
|
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[0])};
|
||||||
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1])};
|
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1])};
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dropSubfieldItem(int dropId) {
|
public boolean dropSubfieldItem(int dropId) {
|
||||||
var drop = GameData.getDropSubfieldMappingMap().get(dropId);
|
var drop = GameData.getDropSubfieldMappingMap().get(dropId);
|
||||||
if(drop == null) return false;
|
if (drop == null) return false;
|
||||||
var dropTableEntry = GameData.getDropTableExcelConfigDataMap().get(drop.getItemId());
|
var dropTableEntry = GameData.getDropTableExcelConfigDataMap().get(drop.getItemId());
|
||||||
if(dropTableEntry == null) return false;
|
if (dropTableEntry == null) return false;
|
||||||
|
|
||||||
Int2ObjectMap<Integer> itemsToDrop = new Int2ObjectOpenHashMap<>();
|
Int2ObjectMap<Integer> itemsToDrop = new Int2ObjectOpenHashMap<>();
|
||||||
switch (dropTableEntry.getRandomType()) {
|
switch (dropTableEntry.getRandomType()) {
|
||||||
case 0: //select one
|
case 0: // select one
|
||||||
{
|
{
|
||||||
int weightCount = 0;
|
int weightCount = 0;
|
||||||
for(var entry : dropTableEntry.getDropVec()) weightCount += entry.getWeight();
|
for (var entry : dropTableEntry.getDropVec()) weightCount += entry.getWeight();
|
||||||
|
|
||||||
int randomValue = new Random().nextInt(weightCount);
|
int randomValue = new Random().nextInt(weightCount);
|
||||||
|
|
||||||
weightCount = 0;
|
weightCount = 0;
|
||||||
for(var entry : dropTableEntry.getDropVec()) {
|
for (var entry : dropTableEntry.getDropVec()) {
|
||||||
if(randomValue >= weightCount && randomValue < (weightCount + entry.getWeight())) {
|
if (randomValue >= weightCount && randomValue < (weightCount + entry.getWeight())) {
|
||||||
var countRange = parseCountRange(entry.getCountRange());
|
var countRange = parseCountRange(entry.getCountRange());
|
||||||
itemsToDrop.put(entry.getItemId(), Integer.valueOf((new Random().nextBoolean() ? countRange[0] : countRange[1])));
|
itemsToDrop.put(
|
||||||
|
entry.getItemId(),
|
||||||
|
Integer.valueOf((new Random().nextBoolean() ? countRange[0] : countRange[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1: //Select various
|
case 1: // Select various
|
||||||
{
|
{
|
||||||
for(var entry : dropTableEntry.getDropVec()) {
|
for (var entry : dropTableEntry.getDropVec()) {
|
||||||
if(entry.getWeight() < new Random().nextInt(10000)) {
|
if (entry.getWeight() < new Random().nextInt(10000)) {
|
||||||
var countRange = parseCountRange(entry.getCountRange());
|
var countRange = parseCountRange(entry.getCountRange());
|
||||||
itemsToDrop.put(entry.getItemId(), Integer.valueOf((new Random().nextBoolean() ? countRange[0] : countRange[1])));
|
itemsToDrop.put(
|
||||||
|
entry.getItemId(),
|
||||||
|
Integer.valueOf((new Random().nextBoolean() ? countRange[0] : countRange[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,13 +275,14 @@ public abstract class GameEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var entry : itemsToDrop.int2ObjectEntrySet()) {
|
for (var entry : itemsToDrop.int2ObjectEntrySet()) {
|
||||||
var item = new EntityItem(
|
var item =
|
||||||
scene,
|
new EntityItem(
|
||||||
null,
|
scene,
|
||||||
GameData.getItemDataMap().get(entry.getIntKey()),
|
null,
|
||||||
getPosition().nearby2d(1f).addY(0.5f),
|
GameData.getItemDataMap().get(entry.getIntKey()),
|
||||||
entry.getValue(),
|
getPosition().nearby2d(1f).addY(0.5f),
|
||||||
true);
|
entry.getValue(),
|
||||||
|
true);
|
||||||
|
|
||||||
scene.addEntity(item);
|
scene.addEntity(item);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package emu.grasscutter.game.world;
|
package emu.grasscutter.game.world;
|
||||||
|
|
||||||
|
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
||||||
|
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.excels.dungeon.DungeonData;
|
import emu.grasscutter.data.excels.dungeon.DungeonData;
|
||||||
import emu.grasscutter.game.entity.*;
|
import emu.grasscutter.game.entity.*;
|
||||||
@ -18,13 +20,10 @@ import emu.grasscutter.server.game.GameServer;
|
|||||||
import emu.grasscutter.server.packet.send.*;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
import emu.grasscutter.utils.ConversionUtils;
|
import emu.grasscutter.utils.ConversionUtils;
|
||||||
import it.unimi.dsi.fastutil.ints.*;
|
import it.unimi.dsi.fastutil.ints.*;
|
||||||
|
import java.util.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
|
||||||
|
|
||||||
public class World implements Iterable<Player> {
|
public class World implements Iterable<Player> {
|
||||||
@Getter private final GameServer server;
|
@Getter private final GameServer server;
|
||||||
@Getter private final Player host;
|
@Getter private final Player host;
|
||||||
|
Loading…
Reference in New Issue
Block a user