generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item Collector now has a respect pickup delay option as requested in #…
- Loading branch information
1 parent
c6c1458
commit 287be95
Showing
9 changed files
with
105 additions
and
2 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-10-18T20:02:46.3102567 Languages: en_us for mod: justdirethings | ||
c7f1cc2b04789bf34333113ee3c1fcd58eb116b2 assets/justdirethings/lang/en_us.json | ||
// 1.21.1 2024-10-18T20:34:14.9851392 Languages: en_us for mod: justdirethings | ||
8688cf4f7590dcf15b5692827931cc7556bd9a23 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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/direwolf20/justdirethings/client/screens/ItemCollectorScreen.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 |
---|---|---|
@@ -1,17 +1,37 @@ | ||
package com.direwolf20.justdirethings.client.screens; | ||
|
||
import com.direwolf20.justdirethings.client.screens.basescreens.BaseMachineScreen; | ||
import com.direwolf20.justdirethings.client.screens.standardbuttons.ToggleButtonFactory; | ||
import com.direwolf20.justdirethings.client.screens.widgets.GrayscaleButton; | ||
import com.direwolf20.justdirethings.common.blockentities.ItemCollectorBE; | ||
import com.direwolf20.justdirethings.common.containers.ItemCollectorContainer; | ||
import com.direwolf20.justdirethings.common.network.data.ItemCollectorSettingsPayload; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.neoforged.neoforge.network.PacketDistributor; | ||
|
||
public class ItemCollectorScreen extends BaseMachineScreen<ItemCollectorContainer> { | ||
public boolean respectPickupDelay = false; | ||
public ItemCollectorScreen(ItemCollectorContainer container, Inventory inv, Component name) { | ||
super(container, inv, name); | ||
if (container.baseMachineBE instanceof ItemCollectorBE itemCollectorBE) { | ||
respectPickupDelay = itemCollectorBE.respectPickupDelay; | ||
} | ||
} | ||
|
||
@Override | ||
public void init() { | ||
super.init(); | ||
addRenderableWidget(ToggleButtonFactory.RESPECTPICKUPDELAY(getGuiLeft() + 116, topSectionTop + 62, respectPickupDelay, b -> { | ||
respectPickupDelay = !respectPickupDelay; | ||
((GrayscaleButton) b).toggleActive(); | ||
saveSettings(); | ||
})); | ||
} | ||
|
||
@Override | ||
public void saveSettings() { | ||
super.saveSettings(); | ||
PacketDistributor.sendToServer(new ItemCollectorSettingsPayload(respectPickupDelay)); | ||
} | ||
} |
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
.../java/com/direwolf20/justdirethings/common/network/data/ItemCollectorSettingsPayload.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 ItemCollectorSettingsPayload( | ||
boolean respectPickupDelay | ||
) implements CustomPacketPayload { | ||
public static final Type<ItemCollectorSettingsPayload> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(JustDireThings.MODID, "item_collector_settings")); | ||
|
||
@Override | ||
public Type<ItemCollectorSettingsPayload> type() { | ||
return TYPE; | ||
} | ||
|
||
public static final StreamCodec<FriendlyByteBuf, ItemCollectorSettingsPayload> STREAM_CODEC = StreamCodec.composite( | ||
ByteBufCodecs.BOOL, ItemCollectorSettingsPayload::respectPickupDelay, | ||
ItemCollectorSettingsPayload::new | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
...ava/com/direwolf20/justdirethings/common/network/handler/ItemCollectorSettingsPacket.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.ItemCollectorBE; | ||
import com.direwolf20.justdirethings.common.containers.ItemCollectorContainer; | ||
import com.direwolf20.justdirethings.common.network.data.ItemCollectorSettingsPayload; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.inventory.AbstractContainerMenu; | ||
import net.neoforged.neoforge.network.handling.IPayloadContext; | ||
|
||
public class ItemCollectorSettingsPacket { | ||
public static final ItemCollectorSettingsPacket INSTANCE = new ItemCollectorSettingsPacket(); | ||
|
||
public static ItemCollectorSettingsPacket get() { | ||
return INSTANCE; | ||
} | ||
|
||
public void handle(final ItemCollectorSettingsPayload payload, final IPayloadContext context) { | ||
context.enqueueWork(() -> { | ||
Player sender = context.player(); | ||
AbstractContainerMenu container = sender.containerMenu; | ||
|
||
if (container instanceof ItemCollectorContainer itemCollectorContainer && itemCollectorContainer.baseMachineBE instanceof ItemCollectorBE itemCollectorBE) { | ||
itemCollectorBE.setSettings(payload.respectPickupDelay()); | ||
} | ||
}); | ||
} | ||
} |
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