generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e6d6f3
commit 23da09e
Showing
9 changed files
with
125 additions
and
12 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/generated/resources/.cache/8202586f691eec5ad0bb88d13a278951d0c130fb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// 1.21.1 2024-09-12T13:18:00.5916321 Languages: en_us for mod: justdirethings | ||
370a2cb7525636b760559d6e7176176093558760 assets/justdirethings/lang/en_us.json | ||
// 1.21.1 2024-09-13T09:48:33.046202 Languages: en_us for mod: justdirethings | ||
66210d1d8e8869a1f61aa605a2cb56cf6e1f7674 assets/justdirethings/lang/en_us.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...va/com/direwolf20/justdirethings/common/network/data/ExperienceHolderSettingsPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.direwolf20.justdirethings.common.network.data; | ||
|
||
import com.direwolf20.justdirethings.JustDireThings; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public record ExperienceHolderSettingsPayload( | ||
int targetExp | ||
) implements CustomPacketPayload { | ||
public static final Type<ExperienceHolderSettingsPayload> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "experience_holder_settings")); | ||
|
||
@Override | ||
public Type<ExperienceHolderSettingsPayload> type() { | ||
return TYPE; | ||
} | ||
|
||
public static final StreamCodec<FriendlyByteBuf, ExperienceHolderSettingsPayload> STREAM_CODEC = StreamCodec.composite( | ||
ByteBufCodecs.INT, ExperienceHolderSettingsPayload::targetExp, | ||
ExperienceHolderSettingsPayload::new | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
.../com/direwolf20/justdirethings/common/network/handler/ExperienceHolderSettingsPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.direwolf20.justdirethings.common.network.handler; | ||
|
||
import com.direwolf20.justdirethings.common.blockentities.ExperienceHolderBE; | ||
import com.direwolf20.justdirethings.common.containers.ExperienceHolderContainer; | ||
import com.direwolf20.justdirethings.common.network.data.ExperienceHolderSettingsPayload; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.inventory.AbstractContainerMenu; | ||
import net.neoforged.neoforge.network.handling.IPayloadContext; | ||
|
||
public class ExperienceHolderSettingsPacket { | ||
public static final ExperienceHolderSettingsPacket INSTANCE = new ExperienceHolderSettingsPacket(); | ||
|
||
public static ExperienceHolderSettingsPacket get() { | ||
return INSTANCE; | ||
} | ||
|
||
public void handle(final ExperienceHolderSettingsPayload payload, final IPayloadContext context) { | ||
context.enqueueWork(() -> { | ||
Player sender = context.player(); | ||
AbstractContainerMenu container = sender.containerMenu; | ||
|
||
if (container instanceof ExperienceHolderContainer experienceHolderContainer && experienceHolderContainer.baseMachineBE instanceof ExperienceHolderBE experienceHolderBE) { | ||
experienceHolderBE.changeSettings(payload.targetExp()); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters