mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 06:28:48 +00:00
Stuff
This commit is contained in:
1 parent
9c4a30d224
commit
666398e480
174 files changed
+8694
-2942
No files matched your search
@@ -0,0 +1,12 @@
|
||||
package com.moulberry.flashback.action;
|
||||
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface Action {
|
||||
|
||||
ResourceLocation name();
|
||||
void handle(ReplayServer replayServer, RegistryFriendlyByteBuf friendlyByteBuf);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.moulberry.flashback.action;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ActionConfigurationPacket implements Action {
|
||||
|
||||
private static final ResourceLocation NAME = Flashback.createResourceLocation("action/configuration_packet");
|
||||
public static final ActionConfigurationPacket INSTANCE = new ActionConfigurationPacket();
|
||||
private ActionConfigurationPacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ReplayServer replayServer, RegistryFriendlyByteBuf friendlyByteBuf) {
|
||||
replayServer.handleConfigurationPacket(friendlyByteBuf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.moulberry.flashback.action;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ActionCreateLocalPlayer implements Action {
|
||||
|
||||
private static final ResourceLocation NAME = Flashback.createResourceLocation("action/create_local_player");
|
||||
public static final ActionCreateLocalPlayer INSTANCE = new ActionCreateLocalPlayer();
|
||||
private ActionCreateLocalPlayer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ReplayServer replayServer, RegistryFriendlyByteBuf friendlyByteBuf) {
|
||||
replayServer.handleCreateLocalPlayer(friendlyByteBuf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.moulberry.flashback.action;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ActionGamePacket implements Action {
|
||||
|
||||
private static final ResourceLocation NAME = Flashback.createResourceLocation("action/game_packet");
|
||||
public static final ActionGamePacket INSTANCE = new ActionGamePacket();
|
||||
private ActionGamePacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ReplayServer replayServer, RegistryFriendlyByteBuf friendlyByteBuf) {
|
||||
replayServer.handleGamePacket(friendlyByteBuf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.moulberry.flashback.action;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ActionLevelChunkCached implements Action {
|
||||
|
||||
private static final ResourceLocation NAME = Flashback.createResourceLocation("action/level_chunk_cached");
|
||||
public static final ActionLevelChunkCached INSTANCE = new ActionLevelChunkCached();
|
||||
private ActionLevelChunkCached() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ReplayServer replayServer, RegistryFriendlyByteBuf friendlyByteBuf) {
|
||||
replayServer.handleLevelChunkCached(friendlyByteBuf.readVarInt());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.moulberry.flashback.action;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ActionMoveEntities implements Action {
|
||||
|
||||
private static final ResourceLocation NAME = Flashback.createResourceLocation("action/move_entities");
|
||||
public static final ActionMoveEntities INSTANCE = new ActionMoveEntities();
|
||||
private ActionMoveEntities() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ReplayServer replayServer, RegistryFriendlyByteBuf friendlyByteBuf) {
|
||||
replayServer.handleMoveEntities(friendlyByteBuf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.moulberry.flashback.action;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.playback.ReplayServer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class ActionNextTick implements Action {
|
||||
|
||||
private static final ResourceLocation NAME = Flashback.createResourceLocation("action/next_tick");
|
||||
public static final ActionNextTick INSTANCE = new ActionNextTick();
|
||||
private ActionNextTick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ReplayServer replayServer, RegistryFriendlyByteBuf friendlyByteBuf) {
|
||||
replayServer.handleNextTick();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.moulberry.flashback.action;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionRegistry {
|
||||
|
||||
private static final List<Action> actions = new ArrayList<>();
|
||||
private static final Map<ResourceLocation, Action> resourceToAction = new HashMap<>();
|
||||
private static final Set<Class<? extends Action>> registeredActions = new HashSet<>();
|
||||
|
||||
public static void register(Action action) {
|
||||
if (!registeredActions.add(action.getClass())) {
|
||||
throw new IllegalArgumentException("Action already registered: " + action.getClass());
|
||||
}
|
||||
if (resourceToAction.containsKey(action.name())) {
|
||||
throw new IllegalArgumentException("Action already registered by name: " + action.name());
|
||||
}
|
||||
|
||||
actions.add(action);
|
||||
resourceToAction.put(action.name(), action);
|
||||
}
|
||||
|
||||
public static List<Action> getActions() {
|
||||
return Collections.unmodifiableList(actions);
|
||||
}
|
||||
|
||||
public static @Nullable Action getAction(ResourceLocation actionName) {
|
||||
return resourceToAction.get(actionName);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user