mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 01:22:54 +00:00
Fix ActionGenerateElemBall
This commit is contained in:
parent
b050337216
commit
b09c0d48bf
@ -2,6 +2,7 @@ package emu.grasscutter.game.ability.actions;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||
@ -12,13 +13,12 @@ import emu.grasscutter.game.entity.EntityItem;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.game.props.SceneType;
|
||||
import emu.grasscutter.net.proto.AbilityActionGenerateElemBallOuterClass.AbilityActionGenerateElemBall;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import emu.grasscutter.game.world.Position;
|
||||
|
||||
@AbilityAction(AbilityModifierAction.Type.GenerateElemBall)
|
||||
public class ActionGenerateElemBall extends AbilityActionHandler {
|
||||
public final class ActionGenerateElemBall extends AbilityActionHandler {
|
||||
@Override
|
||||
public boolean execute(
|
||||
Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||
public boolean execute(Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||
GameEntity owner = ability.getOwner();
|
||||
|
||||
AbilityActionGenerateElemBall generateElemBall;
|
||||
@ -32,9 +32,7 @@ public class ActionGenerateElemBall extends AbilityActionHandler {
|
||||
if(action.dropType == 0x0) {
|
||||
String levelEntityConfig = owner.getScene().getSceneData().getLevelEntityConfig();
|
||||
ConfigLevelEntity config = GameData.getConfigLevelEntityDataMap().get(levelEntityConfig);
|
||||
if (config != null
|
||||
&& config.getDropElemControlType() != null
|
||||
&& config.getDropElemControlType().compareTo("None") == 0) {
|
||||
if(config != null && config.getDropElemControlType() != null && config.getDropElemControlType().compareTo("None") == 0) {
|
||||
Grasscutter.getLogger().warn("This level config don't allow element balls");
|
||||
return true;
|
||||
}
|
||||
@ -62,12 +60,8 @@ public class ActionGenerateElemBall extends AbilityActionHandler {
|
||||
var itemUse = itemData.getItemUse().get(0);
|
||||
double requiredEnergy;
|
||||
switch(itemUse.getUseOp()) {
|
||||
case ITEM_USE_ADD_ELEM_ENERGY:
|
||||
requiredEnergy = Integer.parseInt(itemUse.getUseParam()[1]);
|
||||
break;
|
||||
case ITEM_USE_ADD_ALL_ENERGY:
|
||||
requiredEnergy = Integer.parseInt(itemUse.getUseParam()[0]);
|
||||
break;
|
||||
case ITEM_USE_ADD_ELEM_ENERGY: requiredEnergy = Integer.parseInt(itemUse.getUseParam()[1]); break;
|
||||
case ITEM_USE_ADD_ALL_ENERGY: requiredEnergy = Integer.parseInt(itemUse.getUseParam()[0]); break;
|
||||
default:
|
||||
Grasscutter.getLogger().warn("UseOp not implemented", itemUse.getUseOp());
|
||||
return false;
|
||||
@ -75,22 +69,13 @@ public class ActionGenerateElemBall extends AbilityActionHandler {
|
||||
|
||||
var amountGenerated = (int)Math.ceil(energy / requiredEnergy);
|
||||
if(amountGenerated >= 21) {
|
||||
Grasscutter.getLogger()
|
||||
.warn("Attempt to generate more than 20 element balls {}", amountGenerated);
|
||||
Grasscutter.getLogger().warn("Attempt to generate more than 20 element balls {}", amountGenerated);
|
||||
return false;
|
||||
}
|
||||
|
||||
Grasscutter.getLogger()
|
||||
.debug("Generating {} of {} element balls", amountGenerated, action.configID);
|
||||
Grasscutter.getLogger().debug("Generating {} of {} element balls", amountGenerated, action.configID);
|
||||
for(int i = 0; i < amountGenerated; i++) {
|
||||
EntityItem energyBall =
|
||||
new EntityItem(
|
||||
owner.getScene(),
|
||||
(owner instanceof EntityAvatar avatar) ? avatar.getPlayer() : null,
|
||||
itemData,
|
||||
new Position(generateElemBall.getPos()),
|
||||
new Position(generateElemBall.getRot()),
|
||||
1);
|
||||
EntityItem energyBall = new EntityItem(owner.getScene(), (owner instanceof EntityAvatar avatar) ? avatar.getPlayer() : null, itemData, new Position(generateElemBall.getPos()), new Position(generateElemBall.getRot()), 1);
|
||||
owner.getScene().addEntity(energyBall);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user