1.21.3 + Actions!
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.6-SNAPSHOT'
|
id 'fabric-loom' version '1.8-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
minecraft_version=1.21.1
|
minecraft_version=1.21.3
|
||||||
loader_version=0.16.3
|
loader_version=0.16.7
|
||||||
yarn_mappings=1.21.1+build.3
|
yarn_mappings=1.21.3+build.2
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.0.1-SNAPSHOT
|
mod_version = 0.0.1-SNAPSHOT
|
||||||
@@ -14,8 +14,8 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# check this on https://modmuss50.me/fabric.html
|
# check this on https://modmuss50.me/fabric.html
|
||||||
fabric_version=0.103.0+1.21.1
|
fabric_version=0.107.0+1.21.3
|
||||||
|
|
||||||
polymer_version=0.9.12+1.21.1
|
polymer_version=0.10.0+1.21.2
|
||||||
sgui_version=1.6.0+1.21
|
sgui_version=1.7.1+1.21.2
|
||||||
server_translations_version=2.3.1+1.21-pre2
|
server_translations_version=2.4.0+1.21.2-rc1
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ public class EntityPlayerActionPack
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EntityPlayerActionPack stop(ActionType type) {
|
||||||
|
Action previous = actions.remove(type);
|
||||||
|
if (previous != null) type.stop(player, previous);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public EntityPlayerActionPack setSneaking(boolean doSneak)
|
public EntityPlayerActionPack setSneaking(boolean doSneak)
|
||||||
{
|
{
|
||||||
sneaking = doSneak;
|
sneaking = doSneak;
|
||||||
@@ -314,12 +320,12 @@ public class EntityPlayerActionPack
|
|||||||
BlockHitResult blockHit = (BlockHitResult) hit;
|
BlockHitResult blockHit = (BlockHitResult) hit;
|
||||||
BlockPos pos = blockHit.getBlockPos();
|
BlockPos pos = blockHit.getBlockPos();
|
||||||
Direction side = blockHit.getSide();
|
Direction side = blockHit.getSide();
|
||||||
if (pos.getY() < player.getWorld().getTopY() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos))
|
if (pos.getY() < player.getServerWorld().getTopYInclusive() - (side == Direction.UP ? 1 : 0) && world.canPlayerModifyAt(player, pos))
|
||||||
{
|
{
|
||||||
ActionResult result = player.interactionManager.interactBlock(player, world, player.getStackInHand(hand), hand, blockHit);
|
ActionResult result = player.interactionManager.interactBlock(player, world, player.getStackInHand(hand), hand, blockHit);
|
||||||
if (result.isAccepted())
|
if (result instanceof ActionResult.Success success)
|
||||||
{
|
{
|
||||||
if (result.shouldSwingHand()) player.swingHand(hand);
|
if (success.swingSource() == ActionResult.SwingSource.SERVER) player.swingHand(hand);
|
||||||
ap.itemUseCooldown = 3;
|
ap.itemUseCooldown = 3;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -402,7 +408,7 @@ public class EntityPlayerActionPack
|
|||||||
boolean blockBroken = false;
|
boolean blockBroken = false;
|
||||||
if (player.interactionManager.getGameMode().isCreative())
|
if (player.interactionManager.getGameMode().isCreative())
|
||||||
{
|
{
|
||||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getWorld().getTopY(), -1);
|
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getWorld().getTopYInclusive(), -1);
|
||||||
ap.blockHitDelay = 5;
|
ap.blockHitDelay = 5;
|
||||||
blockBroken = true;
|
blockBroken = true;
|
||||||
}
|
}
|
||||||
@@ -410,9 +416,9 @@ public class EntityPlayerActionPack
|
|||||||
{
|
{
|
||||||
if (ap.currentBlock != null)
|
if (ap.currentBlock != null)
|
||||||
{
|
{
|
||||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getWorld().getTopY(), -1);
|
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, side, player.getWorld().getTopYInclusive(), -1);
|
||||||
}
|
}
|
||||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getWorld().getTopY(), -1);
|
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, side, player.getWorld().getTopYInclusive(), -1);
|
||||||
boolean notAir = !state.isAir();
|
boolean notAir = !state.isAir();
|
||||||
if (notAir && ap.curBlockDamageMP == 0)
|
if (notAir && ap.curBlockDamageMP == 0)
|
||||||
{
|
{
|
||||||
@@ -435,7 +441,7 @@ public class EntityPlayerActionPack
|
|||||||
ap.curBlockDamageMP += state.calcBlockBreakingDelta(player, player.getWorld(), pos);
|
ap.curBlockDamageMP += state.calcBlockBreakingDelta(player, player.getWorld(), pos);
|
||||||
if (ap.curBlockDamageMP >= 1)
|
if (ap.curBlockDamageMP >= 1)
|
||||||
{
|
{
|
||||||
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getWorld().getTopY(), -1);
|
player.interactionManager.processBlockBreakingAction(pos, PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, side, player.getWorld().getTopYInclusive(), -1);
|
||||||
ap.currentBlock = null;
|
ap.currentBlock = null;
|
||||||
ap.blockHitDelay = 5;
|
ap.blockHitDelay = 5;
|
||||||
blockBroken = true;
|
blockBroken = true;
|
||||||
@@ -457,7 +463,7 @@ public class EntityPlayerActionPack
|
|||||||
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
|
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
|
||||||
if (ap.currentBlock == null) return;
|
if (ap.currentBlock == null) return;
|
||||||
player.getWorld().setBlockBreakingInfo(-1, ap.currentBlock, -1);
|
player.getWorld().setBlockBreakingInfo(-1, ap.currentBlock, -1);
|
||||||
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getWorld().getTopY(), -1);
|
player.interactionManager.processBlockBreakingAction(ap.currentBlock, PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getWorld().getTopYInclusive(), -1);
|
||||||
ap.currentBlock = null;
|
ap.currentBlock = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import net.minecraft.network.DisconnectionInfo;
|
|||||||
import net.minecraft.network.NetworkSide;
|
import net.minecraft.network.NetworkSide;
|
||||||
import net.minecraft.network.packet.c2s.common.SyncedClientOptions;
|
import net.minecraft.network.packet.c2s.common.SyncedClientOptions;
|
||||||
import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket;
|
import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket;
|
import net.minecraft.network.packet.s2c.play.EntityPositionSyncS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.EntitySetHeadYawS2CPacket;
|
import net.minecraft.network.packet.s2c.play.EntitySetHeadYawS2CPacket;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.ServerTask;
|
import net.minecraft.server.ServerTask;
|
||||||
@@ -42,6 +42,7 @@ import net.minecraft.world.GameMode;
|
|||||||
import net.minecraft.world.TeleportTarget;
|
import net.minecraft.world.TeleportTarget;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@@ -78,13 +79,13 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
|||||||
instance.programmable = canProgram;
|
instance.programmable = canProgram;
|
||||||
instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
instance.fixStartingPosition = () -> instance.refreshPositionAndAngles(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||||
server.getPlayerManager().onPlayerConnect(new FakeClientConnection(NetworkSide.SERVERBOUND), instance, new ConnectedClientData(profile, 0, instance.getClientOptions(), false));
|
server.getPlayerManager().onPlayerConnect(new FakeClientConnection(NetworkSide.SERVERBOUND), instance, new ConnectedClientData(profile, 0, instance.getClientOptions(), false));
|
||||||
instance.teleport(level, pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
instance.teleport(level, pos.x, pos.y, pos.z, Set.of(), (float) yaw, (float) pitch, true);
|
||||||
instance.setHealth(20.0F);
|
instance.setHealth(20.0F);
|
||||||
instance.unsetRemoved();
|
instance.unsetRemoved();
|
||||||
instance.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT).setBaseValue(0.6F);
|
instance.getAttributeInstance(EntityAttributes.STEP_HEIGHT).setBaseValue(0.6F);
|
||||||
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
||||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());//instance.dimension);
|
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());//instance.dimension);
|
||||||
server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), level.getRegistryKey());//instance.dimension);
|
server.getPlayerManager().sendToDimension(EntityPositionSyncS2CPacket.create(instance), level.getRegistryKey());//instance.dimension);
|
||||||
//instance.world.getChunkManager(). updatePosition(instance);
|
//instance.world.getChunkManager(). updatePosition(instance);
|
||||||
instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
|
instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
|
||||||
instance.getAbilities().flying = false;
|
instance.getAbilities().flying = false;
|
||||||
@@ -116,14 +117,14 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
|||||||
server.getPlayerManager().onPlayerConnect(new FakeClientConnection(NetworkSide.SERVERBOUND), instance, new ConnectedClientData(profile, 0, instance.getClientOptions(), false));
|
server.getPlayerManager().onPlayerConnect(new FakeClientConnection(NetworkSide.SERVERBOUND), instance, new ConnectedClientData(profile, 0, instance.getClientOptions(), false));
|
||||||
System.out.println(instance.getPos());
|
System.out.println(instance.getPos());
|
||||||
if(pos != null && rot != null) {
|
if(pos != null && rot != null) {
|
||||||
instance.teleport(level, pos.x, pos.y, pos.z, rot.x, rot.y);
|
instance.teleport(level, pos.x, pos.y, pos.z, Set.of(), rot.x, rot.y, true);
|
||||||
}
|
}
|
||||||
instance.setVelocity(0,0,0);
|
instance.setVelocity(0,0,0);
|
||||||
instance.setHealth(20.0F);
|
instance.setHealth(20.0F);
|
||||||
instance.unsetRemoved();
|
instance.unsetRemoved();
|
||||||
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
instance.interactionManager.changeGameMode(GameMode.SURVIVAL);
|
||||||
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());//instance.dimension);
|
server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(instance, (byte) (instance.headYaw * 256 / 360)), level.getRegistryKey());//instance.dimension);
|
||||||
server.getPlayerManager().sendToDimension(new EntityPositionS2CPacket(instance), level.getRegistryKey());//instance.dimension);
|
server.getPlayerManager().sendToDimension(EntityPositionSyncS2CPacket.create(instance), level.getRegistryKey());//instance.dimension);
|
||||||
//instance.world.getChunkManager(). updatePosition(instance);
|
//instance.world.getChunkManager(). updatePosition(instance);
|
||||||
instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
|
instance.dataTracker.set(PLAYER_MODEL_PARTS, (byte) 0x7f); // show all model layers (incl. capes)
|
||||||
instance.getAbilities().flying = false;
|
instance.getAbilities().flying = false;
|
||||||
@@ -259,7 +260,7 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity teleportTo(TeleportTarget target)
|
public ServerPlayerEntity teleportTo(TeleportTarget target)
|
||||||
{
|
{
|
||||||
super.teleportTo(target);
|
super.teleportTo(target);
|
||||||
if (notInAnyWorld) {
|
if (notInAnyWorld) {
|
||||||
@@ -316,7 +317,7 @@ public class MinionFakePlayer extends ServerPlayerEntity {
|
|||||||
@Override
|
@Override
|
||||||
protected void drop(ServerWorld world, DamageSource damageSource) {
|
protected void drop(ServerWorld world, DamageSource damageSource) {
|
||||||
super.drop(world, damageSource);
|
super.drop(world, damageSource);
|
||||||
dropStack(toItemStack());
|
dropStack(world, toItemStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack toItemStack() {
|
private ItemStack toItemStack() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.github.skippyall.minions.fakeplayer;
|
package io.github.skippyall.minions.fakeplayer;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerPosition;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.network.packet.s2c.play.PositionFlag;
|
import net.minecraft.network.packet.s2c.play.PositionFlag;
|
||||||
@@ -33,9 +34,9 @@ public class NetHandlerPlayServerFake extends ServerPlayNetworkHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void requestTeleport(double d, double e, double f, float g, float h, Set<PositionFlag> set)
|
public void requestTeleport(PlayerPosition pos, Set<PositionFlag> set)
|
||||||
{
|
{
|
||||||
super.requestTeleport(d, e, f, g, h, set);
|
super.requestTeleport(pos, set);
|
||||||
if (player.getServerWorld().getPlayerByUuid(player.getUuid()) != null) {
|
if (player.getServerWorld().getPlayerByUuid(player.getUuid()) != null) {
|
||||||
syncWithPlayerPosition();
|
syncWithPlayerPosition();
|
||||||
player.getServerWorld().getChunkManager().updatePosition(player);
|
player.getServerWorld().getChunkManager().updatePosition(player);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
|||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class TextInput {
|
public class TextInput {
|
||||||
public static CompletableFuture<String> inputText(ServerPlayerEntity player, Text title, String defaultText) {
|
public static CompletableFuture<String> inputText(ServerPlayerEntity player, Text title, String defaultText) {
|
||||||
@@ -24,4 +25,23 @@ public class TextInput {
|
|||||||
gui.open();
|
gui.open();
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> CompletableFuture<T> inputParse(ServerPlayerEntity player, Text title, String defaultValue, Function<String, T> parser, Text failureMessage) {
|
||||||
|
return inputText(player, title, String.valueOf(defaultValue)).thenCompose(string -> {
|
||||||
|
try {
|
||||||
|
return CompletableFuture.completedFuture(parser.apply(string));
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.sendMessage(failureMessage);
|
||||||
|
return CompletableFuture.failedFuture(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompletableFuture<Integer> inputInt(ServerPlayerEntity player, Text title, String defaultValue) {
|
||||||
|
return inputParse(player, title, defaultValue, Integer::parseInt, Text.translatable("minions.command.input.int.fail"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompletableFuture<Float> inputFloat(ServerPlayerEntity player, Text title, String defaultValue) {
|
||||||
|
return inputParse(player, title, defaultValue, Float::parseFloat, Text.translatable("minions.command.input.float.fail"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import net.minecraft.server.world.ServerWorld;
|
|||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.math.Vec2f;
|
import net.minecraft.util.math.Vec2f;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import xyz.nucleoid.packettweaker.PacketContext;
|
||||||
|
|
||||||
public class MinionItem extends Item implements PolymerItem {
|
public class MinionItem extends Item implements PolymerItem {
|
||||||
private final boolean canProgram;
|
private final boolean canProgram;
|
||||||
@@ -28,13 +29,13 @@ public class MinionItem extends Item implements PolymerItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
public Item getPolymerItem(ItemStack itemStack, PacketContext player) {
|
||||||
return Items.ARMOR_STAND;
|
return Items.ARMOR_STAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPolymerItemStack(ItemStack stack, TooltipType tooltipType, RegistryWrapper.WrapperLookup lookup, ServerPlayerEntity player) {
|
public ItemStack getPolymerItemStack(ItemStack stack, TooltipType tooltipType, PacketContext player) {
|
||||||
ItemStack out = PolymerItemUtils.createItemStack(stack, lookup, player);
|
ItemStack out = PolymerItemUtils.createItemStack(stack, tooltipType, player);
|
||||||
out.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true);
|
out.set(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import eu.pb4.sgui.api.gui.SimpleGui;
|
|||||||
import io.github.skippyall.minions.command.CommandExecutor;
|
import io.github.skippyall.minions.command.CommandExecutor;
|
||||||
import io.github.skippyall.minions.fakeplayer.EntityPlayerActionPack;
|
import io.github.skippyall.minions.fakeplayer.EntityPlayerActionPack;
|
||||||
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
|
||||||
|
import io.github.skippyall.minions.input.TextInput;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
@@ -15,8 +16,19 @@ public class ActionModules {
|
|||||||
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.once());
|
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.once());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void intervalExecutor(EntityPlayerActionPack.ActionType actionType, ServerPlayerEntity player, MinionFakePlayer minion) {
|
public static void executeContinuous(EntityPlayerActionPack.ActionType actionType, ServerPlayerEntity player, MinionFakePlayer minion) {
|
||||||
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.interval());
|
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.continuous());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void executeInterval(EntityPlayerActionPack.ActionType actionType, ServerPlayerEntity player, MinionFakePlayer minion) {
|
||||||
|
TextInput.inputFloat(player, Text.translatable("minions.command.action.interval.enter"), "3.5").thenAccept(interval -> {
|
||||||
|
int ticks = Math.round(interval * 20);
|
||||||
|
minion.getMinionActionPack().start(actionType, EntityPlayerActionPack.Action.interval(ticks));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void executeStop(EntityPlayerActionPack.ActionType actionType, ServerPlayerEntity player, MinionFakePlayer minion) {
|
||||||
|
minion.getMinionActionPack().stop(actionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandExecutor detailSelectionExecutor(EntityPlayerActionPack.ActionType actionType, Text actionName) {
|
public static CommandExecutor detailSelectionExecutor(EntityPlayerActionPack.ActionType actionType, Text actionName) {
|
||||||
@@ -29,6 +41,21 @@ public class ActionModules {
|
|||||||
.setName(Text.translatable("minions.command.action.once", actionName))
|
.setName(Text.translatable("minions.command.action.once", actionName))
|
||||||
.setCallback(() -> executeOnce(actionType, player, minion))
|
.setCallback(() -> executeOnce(actionType, player, minion))
|
||||||
);
|
);
|
||||||
|
gui.setSlot(3, new GuiElementBuilder()
|
||||||
|
.setItem(Items.REPEATING_COMMAND_BLOCK)
|
||||||
|
.setName(Text.translatable("minions.command.action.continuous", actionName))
|
||||||
|
.setCallback(() -> executeContinuous(actionType, player, minion))
|
||||||
|
);
|
||||||
|
gui.setSlot(5, new GuiElementBuilder()
|
||||||
|
.setItem(Items.CHAIN_COMMAND_BLOCK)
|
||||||
|
.setName(Text.translatable("minions.command.action.interval", actionName))
|
||||||
|
.setCallback(() -> executeInterval(actionType, player, minion))
|
||||||
|
);
|
||||||
|
gui.setSlot(3, new GuiElementBuilder()
|
||||||
|
.setItem(Items.BARRIER)
|
||||||
|
.setName(Text.translatable("minions.command.action.stop", actionName))
|
||||||
|
.setCallback(() -> executeStop(actionType, player, minion))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ import java.util.List;
|
|||||||
import static io.github.skippyall.minions.module.Modules.register;
|
import static io.github.skippyall.minions.module.Modules.register;
|
||||||
|
|
||||||
public class MobSpawningModule {
|
public class MobSpawningModule {
|
||||||
public static final SimpleModuleItem MOB_SPAWNING_MODULE = register(Identifier.of(Minions.MOD_ID, "mob_spawning_module"), new SimpleModuleItem(List.of(), List.of(), Items.SPAWNER));
|
public static final SimpleModuleItem MOB_SPAWNING_MODULE =
|
||||||
|
register(
|
||||||
|
Identifier.of(Minions.MOD_ID, "mob_spawning_module"),
|
||||||
|
new SimpleModuleItem(List.of(), List.of(), Items.SPAWNER)
|
||||||
|
);
|
||||||
|
|
||||||
public static boolean canMinionSpawnMobs(MinionFakePlayer minion) {
|
public static boolean canMinionSpawnMobs(MinionFakePlayer minion) {
|
||||||
return minion.getModuleInventory().hasModule(MOB_SPAWNING_MODULE);
|
return minion.getModuleInventory().hasModule(MOB_SPAWNING_MODULE);
|
||||||
|
|||||||
@@ -6,19 +6,38 @@ import net.minecraft.item.Items;
|
|||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import static io.github.skippyall.minions.module.Modules.register;
|
import static io.github.skippyall.minions.module.Modules.register;
|
||||||
|
|
||||||
public class MountModule {
|
public class MountModule {
|
||||||
public static final SimpleModuleItem MOUNT_MODULE = register(Identifier.of(Minions.MOD_ID, "mount_module"),
|
public static final SimpleCommand MOUNT_COMMAND = new SimpleCommand(
|
||||||
new SimpleModuleItem(new ArrayList<>(), Arrays.asList(
|
Text.of("Mount"),
|
||||||
new SimpleCommand(Text.of("Mount"), Text.of("Mount the minion to the nearest mountable Entity"), Items.MINECART, (player, minion) -> minion.getMinionActionPack().mount(true)),
|
Text.of("Mount the minion to the nearest mountable Entity"),
|
||||||
new SimpleCommand(Text.of("Dismount"), Text.of("Dismount the minion"), Items.BARRIER, (player, minion) -> minion.getMinionActionPack().dismount())
|
Items.MINECART,
|
||||||
), Items.MINECART)
|
(player, minion) -> minion.getMinionActionPack().mount(true)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static void registerMe() {}
|
public static final SimpleCommand DISMOUNT_COMMAND = new SimpleCommand(
|
||||||
|
Text.of("Dismount"),
|
||||||
|
Text.of("Dismount the minion"),
|
||||||
|
Items.BARRIER,
|
||||||
|
(player, minion) -> minion.getMinionActionPack().dismount()
|
||||||
|
);
|
||||||
|
|
||||||
|
public static final SimpleModuleItem MOUNT_MODULE =
|
||||||
|
register(Identifier.of(Minions.MOD_ID, "mount_module"),
|
||||||
|
new SimpleModuleItem(
|
||||||
|
List.of(),
|
||||||
|
List.of(
|
||||||
|
MOUNT_COMMAND,
|
||||||
|
DISMOUNT_COMMAND
|
||||||
|
),
|
||||||
|
Items.MINECART
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public static void registerMe() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,43 +12,45 @@ import java.util.List;
|
|||||||
import static io.github.skippyall.minions.module.Modules.register;
|
import static io.github.skippyall.minions.module.Modules.register;
|
||||||
|
|
||||||
public class MoveModule {
|
public class MoveModule {
|
||||||
public static final SimpleCommand WALK_COMMAND = new SimpleCommand(Text.literal("Walk"), Text.literal("Walk a specific amount of blocks forward"), Items.IRON_BOOTS, (player, minion) -> {
|
public static final SimpleCommand WALK_COMMAND =
|
||||||
TextInput.inputText(player, Text.literal("Amount of Blocks"), "1")
|
new SimpleCommand(
|
||||||
.thenAccept(string -> {
|
Text.literal("Walk"),
|
||||||
try {
|
Text.literal("Walk a specific amount of blocks forward"),
|
||||||
float blocks = Float.parseFloat(string);
|
Items.IRON_BOOTS,
|
||||||
minion.moveForward(blocks);
|
(player, minion) -> TextInput.inputFloat(player, Text.literal("Amount of Blocks"), "1")
|
||||||
} catch (NumberFormatException e) {
|
.thenAccept(minion::moveForward)
|
||||||
player.sendMessage(Text.literal("No valid number"));
|
);
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
public static final SimpleCommand TURN_RIGHT_COMMAND = new SimpleCommand(Text.literal("Turn Right"), Text.literal("Turn a specific amount of degrees right"), Items.COMPASS, ((player, minion) -> {
|
public static final SimpleCommand TURN_RIGHT_COMMAND =
|
||||||
TextInput.inputText(player, Text.literal("Degrees"), "90")
|
new SimpleCommand(
|
||||||
.thenAccept(string -> {
|
Text.literal("Turn Right"),
|
||||||
try {
|
Text.literal("Turn a specific amount of degrees right"),
|
||||||
float degrees = Float.parseFloat(string);
|
Items.COMPASS,
|
||||||
minion.getMinionActionPack().turn(degrees, 0);
|
(player, minion) -> TextInput.inputFloat(player, Text.literal("Degrees"), "90")
|
||||||
} catch (NumberFormatException e) {
|
.thenAccept(degrees -> minion.getMinionActionPack().turn(degrees, 0))
|
||||||
player.sendMessage(Text.literal("No valid number"));
|
);
|
||||||
}
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
public static final SimpleCommand TURN_LEFT_COMMAND = new SimpleCommand(Text.literal("Turn Left"), Text.literal("Turn a specific amount of degrees left"), Items.COMPASS, ((player, minion) -> {
|
public static final SimpleCommand TURN_LEFT_COMMAND =
|
||||||
TextInput.inputText(player, Text.literal("Degrees"), "90")
|
new SimpleCommand(
|
||||||
.thenAccept(string -> {
|
Text.literal("Turn Left"),
|
||||||
try {
|
Text.literal("Turn a specific amount of degrees left"),
|
||||||
float degrees = Float.parseFloat(string);
|
Items.COMPASS,
|
||||||
minion.getMinionActionPack().turn(-degrees, 0);
|
(player, minion) -> TextInput.inputFloat(player, Text.literal("Degrees"), "90")
|
||||||
} catch (NumberFormatException e) {
|
.thenAccept(degrees -> minion.getMinionActionPack().turn(-degrees, 0))
|
||||||
player.sendMessage(Text.literal("No valid number"));
|
);
|
||||||
}
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
public static final SimpleModuleItem MOVE_MODULE = register(Identifier.of(Minions.MOD_ID, "move_module"), new SimpleModuleItem(List.of(), List.of(WALK_COMMAND, TURN_RIGHT_COMMAND, TURN_LEFT_COMMAND), Items.IRON_BOOTS));
|
public static final SimpleModuleItem MOVE_MODULE =
|
||||||
|
register(Identifier.of(Minions.MOD_ID, "move_module"),
|
||||||
|
new SimpleModuleItem(
|
||||||
|
List.of(),
|
||||||
|
List.of(
|
||||||
|
WALK_COMMAND,
|
||||||
|
TURN_RIGHT_COMMAND,
|
||||||
|
TURN_LEFT_COMMAND
|
||||||
|
),
|
||||||
|
Items.IRON_BOOTS
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
public static void registerMe() {}
|
public static void registerMe() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import io.github.skippyall.minions.command.Command;
|
|||||||
import io.github.skippyall.minions.program.block.CodeBlock;
|
import io.github.skippyall.minions.program.block.CodeBlock;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import xyz.nucleoid.packettweaker.PacketContext;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -33,7 +32,7 @@ public class SimpleModuleItem extends Item implements PolymerItem, ModuleItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
public Item getPolymerItem(ItemStack itemStack, PacketContext context) {
|
||||||
return vanillaItem;
|
return vanillaItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,14 @@
|
|||||||
"minions.gui.module_commands.title": "Commands",
|
"minions.gui.module_commands.title": "Commands",
|
||||||
"minions.gui.commands.title": "%s's Commands",
|
"minions.gui.commands.title": "%s's Commands",
|
||||||
"minions.gui.modules.title": "%s's Modules",
|
"minions.gui.modules.title": "%s's Modules",
|
||||||
|
"minions.command.input.int.fail": "Not an integer",
|
||||||
|
"minions.command.input.float.fail": "Not a number",
|
||||||
"minions.command.action.details": "Set how to %s",
|
"minions.command.action.details": "Set how to %s",
|
||||||
"minions.command.action.once": "%s once",
|
"minions.command.action.once": "%s once",
|
||||||
"minions.command.action.continuous": "%s continuously",
|
"minions.command.action.continuous": "%s continuously",
|
||||||
"minions.command.action.interval": "%s every x seconds"
|
"minions.command.action.interval": "%s every x seconds",
|
||||||
|
"minions.command.action.stop": "Stop %s",
|
||||||
|
"minions.command.action.interval.enter": "Enter an interval in seconds",
|
||||||
|
"minions.command.interact.name": "",
|
||||||
|
"minions.command.interact.description": ""
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user