mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 20:03:21 +00: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 =
|
||||
new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@Getter private static final Int2ObjectMap<SubfieldMapping> subfieldMappingMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Int2ObjectMap<DropSubfieldMapping> dropSubfieldMappingMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Int2ObjectMap<DropTableExcelConfigData> dropTableExcelConfigDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter
|
||||
private static final Int2ObjectMap<SubfieldMapping> subfieldMappingMap =
|
||||
new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@Getter
|
||||
private static final Int2ObjectMap<DropSubfieldMapping> dropSubfieldMappingMap =
|
||||
new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@Getter
|
||||
private static final Int2ObjectMap<DropTableExcelConfigData> dropTableExcelConfigDataMap =
|
||||
new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@Getter
|
||||
private static final Int2ObjectMap<MonsterMapping> monsterMappingMap =
|
||||
|
@ -810,8 +810,11 @@ public final class ResourceLoader {
|
||||
try {
|
||||
val subfieldMap = GameData.getSubfieldMappingMap();
|
||||
try {
|
||||
JsonUtils.loadToList(getResourcePath("Server/SubfieldMapping.json"), SubfieldMapping.class).forEach(entry -> subfieldMap.put(entry.getEntityId(), entry));;
|
||||
} catch (IOException | NullPointerException ignored) {}
|
||||
JsonUtils.loadToList(getResourcePath("Server/SubfieldMapping.json"), SubfieldMapping.class)
|
||||
.forEach(entry -> subfieldMap.put(entry.getEntityId(), entry));
|
||||
;
|
||||
} catch (IOException | NullPointerException ignored) {
|
||||
}
|
||||
Grasscutter.getLogger().debug("Loaded {} subfield mappings.", subfieldMap.size());
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load subfield mappings.", e);
|
||||
@ -820,8 +823,12 @@ public final class ResourceLoader {
|
||||
try {
|
||||
val dropSubfieldMap = GameData.getDropSubfieldMappingMap();
|
||||
try {
|
||||
JsonUtils.loadToList(getResourcePath("Server/DropSubfieldMapping.json"), DropSubfieldMapping.class).forEach(entry -> dropSubfieldMap.put(entry.getDropId(), entry));;
|
||||
} catch (IOException | NullPointerException ignored) {}
|
||||
JsonUtils.loadToList(
|
||||
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());
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load drop subfield mappings.", e);
|
||||
@ -830,9 +837,15 @@ public final class ResourceLoader {
|
||||
try {
|
||||
val dropTableExcelConfigDataMap = GameData.getDropTableExcelConfigDataMap();
|
||||
try {
|
||||
JsonUtils.loadToList(getResourcePath("Server/DropTableExcelConfigData.json"), DropTableExcelConfigData.class).forEach(entry -> dropTableExcelConfigDataMap.put(entry.getId(), entry));;
|
||||
} catch (IOException | NullPointerException ignored) {}
|
||||
Grasscutter.getLogger().debug("Loaded {} drop table configs.", dropTableExcelConfigDataMap.size());
|
||||
JsonUtils.loadToList(
|
||||
getResourcePath("Server/DropTableExcelConfigData.json"),
|
||||
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) {
|
||||
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 emu.grasscutter.data.common.DynamicFloat;
|
||||
import emu.grasscutter.game.props.ElementType;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.ToString;
|
||||
|
||||
public class AbilityModifier implements Serializable {
|
||||
private static final long serialVersionUID = -2001232313615923575L;
|
||||
|
@ -3,9 +3,8 @@ package emu.grasscutter.game.ability;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.binout.AbilityMixinData;
|
||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class AbilityLocalIdGenerator {
|
||||
@ -38,12 +37,14 @@ public class AbilityLocalIdGenerator {
|
||||
this.actionIndex++;
|
||||
|
||||
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 {
|
||||
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)
|
||||
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.packet.send.PacketEntityFightPropUpdateNotify;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
|
||||
public abstract class GameEntity {
|
||||
@Getter private final Scene scene;
|
||||
@ -230,40 +229,45 @@ public abstract class GameEntity {
|
||||
|
||||
private int[] parseCountRange(String range) {
|
||||
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])};
|
||||
}
|
||||
|
||||
public boolean dropSubfieldItem(int dropId) {
|
||||
var drop = GameData.getDropSubfieldMappingMap().get(dropId);
|
||||
if(drop == null) return false;
|
||||
if (drop == null) return false;
|
||||
var dropTableEntry = GameData.getDropTableExcelConfigDataMap().get(drop.getItemId());
|
||||
if(dropTableEntry == null) return false;
|
||||
if (dropTableEntry == null) return false;
|
||||
|
||||
Int2ObjectMap<Integer> itemsToDrop = new Int2ObjectOpenHashMap<>();
|
||||
switch (dropTableEntry.getRandomType()) {
|
||||
case 0: //select one
|
||||
case 0: // select one
|
||||
{
|
||||
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);
|
||||
|
||||
weightCount = 0;
|
||||
for(var entry : dropTableEntry.getDropVec()) {
|
||||
if(randomValue >= weightCount && randomValue < (weightCount + entry.getWeight())) {
|
||||
for (var entry : dropTableEntry.getDropVec()) {
|
||||
if (randomValue >= weightCount && randomValue < (weightCount + entry.getWeight())) {
|
||||
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;
|
||||
case 1: //Select various
|
||||
case 1: // Select various
|
||||
{
|
||||
for(var entry : dropTableEntry.getDropVec()) {
|
||||
if(entry.getWeight() < new Random().nextInt(10000)) {
|
||||
for (var entry : dropTableEntry.getDropVec()) {
|
||||
if (entry.getWeight() < new Random().nextInt(10000)) {
|
||||
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()) {
|
||||
var item = new EntityItem(
|
||||
scene,
|
||||
null,
|
||||
GameData.getItemDataMap().get(entry.getIntKey()),
|
||||
getPosition().nearby2d(1f).addY(0.5f),
|
||||
entry.getValue(),
|
||||
true);
|
||||
var item =
|
||||
new EntityItem(
|
||||
scene,
|
||||
null,
|
||||
GameData.getItemDataMap().get(entry.getIntKey()),
|
||||
getPosition().nearby2d(1f).addY(0.5f),
|
||||
entry.getValue(),
|
||||
true);
|
||||
|
||||
scene.addEntity(item);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package emu.grasscutter.game.world;
|
||||
|
||||
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.dungeon.DungeonData;
|
||||
import emu.grasscutter.game.entity.*;
|
||||
@ -18,13 +20,10 @@ import emu.grasscutter.server.game.GameServer;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.ConversionUtils;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
||||
|
||||
public class World implements Iterable<Player> {
|
||||
@Getter private final GameServer server;
|
||||
@Getter private final Player host;
|
||||
|
Loading…
Reference in New Issue
Block a user