mirror of
https://github.com/YouHaveTrouble/QuickerStacker.git
synced 2026-05-11 21:56:55 +00:00
an attempt was made at understanding how interactions work without any documentation
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
.kotlin
|
||||||
|
libraries/
|
||||||
|
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>me.youhavetrouble.quickerstacker</groupId>
|
||||||
|
<artifactId>QuickerStacker</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<defaultGoal>clean package</defaultGoal>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hypixel.hytale</groupId>
|
||||||
|
<artifactId>HytaleServer-parent</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/libraries/HytaleServer.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package me.youhavetrouble.quickerstacker;
|
||||||
|
|
||||||
|
|
||||||
|
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
|
||||||
|
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||||
|
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
||||||
|
import me.youhavetrouble.quickerstacker.interaction.ChestInteraction;
|
||||||
|
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
|
||||||
|
|
||||||
|
public class QuickerStacker extends JavaPlugin {
|
||||||
|
|
||||||
|
public QuickerStacker(@NonNullDecl JavaPluginInit init) {
|
||||||
|
super(init);
|
||||||
|
|
||||||
|
this.getCodecRegistry(Interaction.CODEC).register("YouHaveTrouble_QuickerStacker_QuickStackToChest", ChestInteraction.class, ChestInteraction.CODEC);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package me.youhavetrouble.quickerstacker.interaction;
|
||||||
|
|
||||||
|
|
||||||
|
import com.hypixel.hytale.codec.builder.BuilderCodec;
|
||||||
|
import com.hypixel.hytale.component.CommandBuffer;
|
||||||
|
import com.hypixel.hytale.component.Ref;
|
||||||
|
import com.hypixel.hytale.component.Store;
|
||||||
|
import com.hypixel.hytale.math.util.ChunkUtil;
|
||||||
|
import com.hypixel.hytale.math.vector.Vector3i;
|
||||||
|
import com.hypixel.hytale.protocol.BlockPosition;
|
||||||
|
import com.hypixel.hytale.protocol.InteractionSyncData;
|
||||||
|
import com.hypixel.hytale.protocol.InteractionType;
|
||||||
|
import com.hypixel.hytale.server.core.Message;
|
||||||
|
import com.hypixel.hytale.server.core.entity.InteractionContext;
|
||||||
|
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||||
|
import com.hypixel.hytale.server.core.inventory.Inventory;
|
||||||
|
import com.hypixel.hytale.server.core.inventory.ItemStack;
|
||||||
|
import com.hypixel.hytale.server.core.modules.interaction.interaction.CooldownHandler;
|
||||||
|
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.SimpleInstantInteraction;
|
||||||
|
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.client.SimpleBlockInteraction;
|
||||||
|
import com.hypixel.hytale.server.core.universe.world.World;
|
||||||
|
import com.hypixel.hytale.server.core.universe.world.chunk.WorldChunk;
|
||||||
|
import com.hypixel.hytale.server.core.universe.world.meta.state.ItemContainerState;
|
||||||
|
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||||
|
import com.hypixel.hytale.server.core.util.NotificationUtil;
|
||||||
|
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
|
||||||
|
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
|
||||||
|
|
||||||
|
public class ChestInteraction extends SimpleBlockInteraction {
|
||||||
|
|
||||||
|
public static final BuilderCodec<ChestInteraction> CODEC = BuilderCodec
|
||||||
|
.builder(ChestInteraction.class, ChestInteraction::new)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void interactWithBlock(
|
||||||
|
@NonNullDecl World world,
|
||||||
|
@NonNullDecl CommandBuffer<EntityStore> commandBuffer,
|
||||||
|
@NonNullDecl InteractionType interactionType,
|
||||||
|
@NonNullDecl InteractionContext interactionContext,
|
||||||
|
@NullableDecl ItemStack itemStack,
|
||||||
|
@NonNullDecl Vector3i vector3i,
|
||||||
|
@NonNullDecl CooldownHandler cooldownHandler
|
||||||
|
) {
|
||||||
|
Ref<EntityStore> ref = interactionContext.getEntity();
|
||||||
|
Player player = ref.getStore().getComponent(ref, Player.getComponentType());
|
||||||
|
if (player == null) return;
|
||||||
|
NotificationUtil.sendNotification(player.getPlayerRef().getPacketHandler(), "Interaction happened! "+ interactionType.name());
|
||||||
|
player.sendMessage(Message.raw("Interaction: " + interactionType.name()));
|
||||||
|
InteractionSyncData clientState = interactionContext.getClientState();
|
||||||
|
if (clientState == null) return;
|
||||||
|
BlockPosition targetBlockPosition = clientState.blockPosition;
|
||||||
|
if (targetBlockPosition == null) return;
|
||||||
|
WorldChunk chunk = world.getChunk(ChunkUtil.indexChunkFromBlock(targetBlockPosition.x, targetBlockPosition.z));
|
||||||
|
if (chunk == null) return;
|
||||||
|
var blockState = chunk.getState(targetBlockPosition.x, targetBlockPosition.y, targetBlockPosition.z);
|
||||||
|
if (!(blockState instanceof ItemContainerState containerState)) return;
|
||||||
|
|
||||||
|
Inventory playerInventory = player.getInventory();
|
||||||
|
if (playerInventory == null) return;
|
||||||
|
playerInventory.getCombinedHotbarFirst().quickStackTo(containerState.getItemContainer());
|
||||||
|
player.sendMessage(Message.raw("Quick stacked items to chest."));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void simulateInteractWithBlock(@NonNullDecl InteractionType interactionType, @NonNullDecl InteractionContext interactionContext, @NullableDecl ItemStack itemStack, @NonNullDecl World world, @NonNullDecl Vector3i vector3i) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"Type": "YouHaveTrouble_QuickerStacker_QuickStackToChest"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"Type": "UseBlock",
|
||||||
|
"Next": {
|
||||||
|
"Type": "YouHaveTrouble_QuickerStacker_QuickStackToChest",
|
||||||
|
"RunTime": 0.5
|
||||||
|
},
|
||||||
|
"Failed": {
|
||||||
|
"Type": "Simple",
|
||||||
|
"RunTime": 0.5
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"Interactions": [
|
||||||
|
"YouHaveTrouble_QuickerStacker_QuickStackToChest"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"Group": "me.youhavetrouble.quickerstacker",
|
||||||
|
"Name": "QuickerStacker",
|
||||||
|
"Version": "1.0.0",
|
||||||
|
"Description": "Quick stack everything!",
|
||||||
|
"Authors": [
|
||||||
|
{
|
||||||
|
"Name": "YouHaveTrouble",
|
||||||
|
"Email": "youhavetrouble@youhavetrouble.me",
|
||||||
|
"Url": "https://yht.one"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ServerVersion": "*",
|
||||||
|
"Dependencies": {},
|
||||||
|
"OptionalDependencies": {},
|
||||||
|
"DisabledByDefault": false,
|
||||||
|
"IncludesAssetPack": false,
|
||||||
|
"Main": "me.youhavetrouble.quickerstacker.QuickerStacker"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user