-
Notifications
You must be signed in to change notification settings - Fork 13
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
Showing
31 changed files
with
380 additions
and
285 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase = GRADLE_USER_HOME | ||
distributionPath = wrapper/dists | ||
distributionUrl = https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
distributionUrl = https\://services.gradle.org/distributions/gradle-8.8-bin.zip | ||
zipStoreBase = GRADLE_USER_HOME | ||
zipStorePath = wrapper/dists |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/almostreliable/merequester/MERequesterClient.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,29 @@ | ||
package com.almostreliable.merequester; | ||
|
||
import appeng.init.client.InitScreens; | ||
import com.almostreliable.merequester.client.RequesterScreen; | ||
import com.almostreliable.merequester.client.RequesterTerminalScreen; | ||
import com.almostreliable.merequester.requester.RequesterMenu; | ||
import com.almostreliable.merequester.terminal.RequesterTerminalMenu; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; | ||
|
||
@Mod(value = BuildConfig.MOD_ID, dist = Dist.CLIENT) | ||
public final class MERequesterClient { | ||
|
||
public MERequesterClient(IEventBus modEventBus) { | ||
modEventBus.addListener(this::registerScreens); | ||
} | ||
|
||
private void registerScreens(RegisterMenuScreensEvent event) { | ||
InitScreens.register(event, RequesterMenu.TYPE, RequesterScreen::new, String.format("/screens/%s.json", MERequester.REQUESTER_ID)); | ||
InitScreens.<RequesterTerminalMenu, RequesterTerminalScreen<RequesterTerminalMenu>> register( | ||
event, | ||
RequesterTerminalMenu.TYPE, | ||
RequesterTerminalScreen::new, | ||
String.format("/screens/%s.json", MERequester.TERMINAL_ID) | ||
); | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/almostreliable/merequester/data/MERequesterData.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,31 @@ | ||
package com.almostreliable.merequester.data; | ||
|
||
import com.almostreliable.merequester.BuildConfig; | ||
import net.minecraft.core.component.DataComponentType; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
|
||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
public final class MERequesterData { | ||
|
||
private MERequesterData() {} | ||
|
||
public static final DeferredRegister<DataComponentType<?>> DR = DeferredRegister | ||
.create(Registries.DATA_COMPONENT_TYPE, BuildConfig.MOD_ID); | ||
|
||
public static final DataComponentType<List<MERequesterRequest>> EXPORTED_REQUESTER_REQUESTS = register("exported_requests", builder -> { | ||
builder.persistent(MERequesterRequest.CODEC.listOf()) | ||
.networkSynchronized(MERequesterRequest.STREAM_CODEC.apply(ByteBufCodecs.list())); | ||
}); | ||
|
||
private static <T> DataComponentType<T> register(String name, Consumer<DataComponentType.Builder<T>> customizer) { | ||
var builder = DataComponentType.<T> builder(); | ||
customizer.accept(builder); | ||
var componentType = builder.build(); | ||
DR.register(name, () -> componentType); | ||
return componentType; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/almostreliable/merequester/data/MERequesterRequest.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,37 @@ | ||
package com.almostreliable.merequester.data; | ||
|
||
import appeng.api.stacks.AEKey; | ||
import com.almostreliable.merequester.requester.status.RequestStatus; | ||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
|
||
import java.util.Optional; | ||
|
||
public record MERequesterRequest( | ||
boolean state, | ||
Optional<AEKey> key, | ||
long amount, | ||
long batch, | ||
RequestStatus clientStatus | ||
) { | ||
|
||
public static final Codec<MERequesterRequest> CODEC = RecordCodecBuilder.create(builder -> builder.group( | ||
Codec.BOOL.fieldOf("state").forGetter(MERequesterRequest::state), | ||
Codec.optionalField("key", AEKey.CODEC, false).forGetter(MERequesterRequest::key), | ||
Codec.LONG.fieldOf("amount").forGetter(MERequesterRequest::amount), | ||
Codec.LONG.fieldOf("batch").forGetter(MERequesterRequest::batch), | ||
RequestStatus.CODEC.fieldOf("client_status").forGetter(MERequesterRequest::clientStatus) | ||
).apply(builder, MERequesterRequest::new)); | ||
|
||
public static final StreamCodec<RegistryFriendlyByteBuf, MERequesterRequest> STREAM_CODEC = StreamCodec.composite( | ||
ByteBufCodecs.BOOL, MERequesterRequest::state, | ||
ByteBufCodecs.optional(AEKey.STREAM_CODEC), MERequesterRequest::key, | ||
ByteBufCodecs.VAR_LONG, MERequesterRequest::amount, | ||
ByteBufCodecs.VAR_LONG, MERequesterRequest::batch, | ||
RequestStatus.STREAM_CODEC, MERequesterRequest::clientStatus, | ||
MERequesterRequest::new | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/almostreliable/merequester/data/package-info.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,6 @@ | ||
@ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault | ||
package com.almostreliable.merequester.data; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
Oops, something went wrong.