From f2506b0f0679852e85e150042235e0aec0c8c7be Mon Sep 17 00:00:00 2001 From: zyxkad Date: Fri, 26 Apr 2024 14:56:47 -0600 Subject: [PATCH] fix java generic --- .../peripheral/plugins/AutomataEntityHandPlugin.java | 5 +++-- .../peripheral/plugins/AutomataEntityTransferPlugin.java | 3 ++- .../computercraft/peripheral/plugins/AutomataLookPlugin.java | 3 ++- .../common/util/fakeplayer/APFakePlayer.java | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityHandPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityHandPlugin.java index c0647b008..fc0d5f159 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityHandPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityHandPlugin.java @@ -3,6 +3,7 @@ import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; import dan200.computercraft.api.lua.MethodResult; +import dan200.computercraft.core.apis.TableHelper; import de.srendi.advancedperipherals.common.addons.computercraft.owner.TurtlePeripheralOwner; import de.srendi.advancedperipherals.common.util.LuaConverter; import de.srendi.advancedperipherals.lib.peripherals.AutomataCorePeripheral; @@ -47,7 +48,7 @@ public final MethodResult useOnAnimal(@NotNull IArguments arguments) throws LuaE TurtlePeripheralOwner owner = automataCore.getPeripheralOwner(); ItemStack selectedTool = owner.getToolInMainHand(); int previousDamageValue = selectedTool.getDamageValue(); - InteractionResult result = owner.withPlayer(player -> player.doActionWithRot(yaw, pitch, player -> player.useOnFilteredEntity(suitableEntity))); + InteractionResult result = owner.withPlayer(player -> player.doActionWithRot(yaw, pitch, p -> p.useOnFilteredEntity(suitableEntity))); if (automataCore.hasAttribute(AutomataCorePeripheral.ATTR_STORING_TOOL_DURABILITY)) selectedTool.setDamageValue(previousDamageValue); @@ -63,7 +64,7 @@ public final MethodResult inspectAnimal(@NotNull IArguments arguments) throws Lu automataCore.addRotationCycle(); TurtlePeripheralOwner owner = automataCore.getPeripheralOwner(); - HitResult entityHit = owner.withPlayer(player -> player.doActionWithRot(yaw, pitch, player -> player.findHit(false, true, suitableEntity))); + HitResult entityHit = owner.withPlayer(player -> player.doActionWithRot(yaw, pitch, p -> p.findHit(false, true, suitableEntity))); if (entityHit.getType() == HitResult.Type.MISS) return MethodResult.of(null, "Nothing found"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java index 0a955c868..c031ca1f2 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataEntityTransferPlugin.java @@ -3,6 +3,7 @@ import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; import dan200.computercraft.api.lua.MethodResult; +import dan200.computercraft.core.apis.TableHelper; import de.srendi.advancedperipherals.common.addons.computercraft.owner.TurtlePeripheralOwner; import de.srendi.advancedperipherals.common.util.LuaConverter; import de.srendi.advancedperipherals.lib.peripherals.AutomataCorePeripheral; @@ -74,7 +75,7 @@ public final MethodResult captureAnimal(@NotNull IArguments arguments) throws Lu float yaw = opts != null ? (float) TableHelper.optNumberField(opts, "yaw", 0) : 0; float pitch = opts != null ? (float) TableHelper.optNumberField(opts, "pitch", 0) : 0; - HitResult entityHit = automataCore.getPeripheralOwner().withPlayer(player -> player.doActionWithRot(yaw, pitch, player -> player.findHit(false, true, suitableEntity))); + HitResult entityHit = automataCore.getPeripheralOwner().withPlayer(player -> player.doActionWithRot(yaw, pitch, p -> p.findHit(false, true, suitableEntity))); if (entityHit.getType() == HitResult.Type.MISS) return MethodResult.of(null, "Nothing found"); return automataCore.withOperation(CAPTURE_ANIMAL, context -> { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataLookPlugin.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataLookPlugin.java index 329108bf6..eb6ce8965 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataLookPlugin.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/plugins/AutomataLookPlugin.java @@ -2,6 +2,7 @@ import dan200.computercraft.api.lua.LuaFunction; import dan200.computercraft.api.lua.MethodResult; +import dan200.computercraft.core.apis.TableHelper; import de.srendi.advancedperipherals.common.addons.computercraft.owner.TurtlePeripheralOwner; import de.srendi.advancedperipherals.common.util.LuaConverter; import de.srendi.advancedperipherals.lib.peripherals.AutomataCorePeripheral; @@ -50,7 +51,7 @@ public final MethodResult lookAtEntity(@NotNull IArguments arguments) throws Lua float pitch = opts != null ? (float) TableHelper.optNumberField(opts, "pitch", 0) : 0; automataCore.addRotationCycle(); - HitResult result = automataCore.getPeripheralOwner().withPlayer(apFakePlayer -> apFakePlayer.doActionWithRot(yaw, pitch, apFakePlayer -> apFakePlayer.findHit(false, true))); + HitResult result = automataCore.getPeripheralOwner().withPlayer(apFakePlayer -> apFakePlayer.doActionWithRot(yaw, pitch, p -> p.findHit(false, true))); if (result.getType() == HitResult.Type.MISS) return MethodResult.of(null, "No entity find"); diff --git a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java index d6af4968f..4c8b673c8 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java +++ b/src/main/java/de/srendi/advancedperipherals/common/util/fakeplayer/APFakePlayer.java @@ -119,7 +119,7 @@ public float getEyeHeight(@NotNull Pose pose) { return 0; } - public T doActionWithRot(float yaw, float pitch, Function action) { + public T doActionWithRot(float yaw, float pitch, Function action) { final float oldRot = this.getYRot(); this.setRot(oldRot + yaw, pitch); try {