Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: SFort/MC-OCAIP
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: r1.2.5
Choose a base ref
...
head repository: SFort/MC-OCAIP
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Nov 15, 2022

  1. Update README.md

    SFort authored Nov 15, 2022
    Copy the full SHA
    01f7234 View commit details

Commits on Jan 9, 2023

  1. 1.19.3 port

    SFort committed Jan 9, 2023
    Copy the full SHA
    cb0a676 View commit details

Commits on Jan 10, 2023

  1. add sha512 pow

    SFort committed Jan 10, 2023
    Copy the full SHA
    8146026 View commit details
  2. Copy the full SHA
    3073051 View commit details
  3. update README.md

    SFort committed Jan 10, 2023
    Copy the full SHA
    98ee24f View commit details
  4. Update README.md

    SFort authored Jan 10, 2023
    Copy the full SHA
    3d4ab90 View commit details
  5. 1.3.0 fixes & add argon2

    SFort committed Jan 10, 2023
    Copy the full SHA
    79c7e4b View commit details
  6. Update README.md

    SFort authored Jan 10, 2023
    Copy the full SHA
    4ce7b7f View commit details
  7. Update README.md

    SFort authored Jan 10, 2023
    Copy the full SHA
    248b7bb View commit details

Commits on Apr 15, 2023

  1. Copy the full SHA
    2d9e9a0 View commit details
  2. Update README.md

    SFort authored Apr 15, 2023
    Copy the full SHA
    bd94a9a View commit details

Commits on Jun 11, 2023

  1. 1.20 port

    SFort committed Jun 11, 2023
    Copy the full SHA
    af7694d View commit details

Commits on Oct 8, 2023

  1. 1.20.2 port

    SFort committed Oct 8, 2023
    Copy the full SHA
    96330ba View commit details
  2. fix mapping nonsense

    SFort committed Oct 8, 2023
    Copy the full SHA
    a9c22dc View commit details
  3. Update README.md

    SFort authored Oct 8, 2023
    Copy the full SHA
    a17d280 View commit details

Commits on Nov 29, 2023

  1. Fix #6

    SFort committed Nov 29, 2023
    Copy the full SHA
    9e5ec25 View commit details
  2. version bump

    SFort committed Nov 29, 2023
    Copy the full SHA
    c195df4 View commit details
  3. change priority; Close #7

    SFort committed Nov 29, 2023
    Copy the full SHA
    e2f6c96 View commit details
  4. Update README.md

    SFort authored Nov 29, 2023
    Copy the full SHA
    07fcb31 View commit details

Commits on Dec 10, 2023

  1. Fix #8

    SFort committed Dec 10, 2023
    Copy the full SHA
    e7465fe View commit details
  2. Update README.md

    SFort authored Dec 10, 2023
    Copy the full SHA
    d3b3cf8 View commit details
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -9,21 +9,18 @@ ____________________________________________________

### Download

1.19.2 - [1.2.4](https://github.com/SFort/MC-OCAIP/releases/tag/r1.2.4)
1.18.2 - [1.2.3](https://github.com/SFort/MC-OCAIP/releases/tag/r1.2.3)
1.20.2 - 1.20.4 - [1.3.5](https://github.com/SFort/MC-OCAIP/releases/tag/r1.3.5)
1.20 - 1.20.1 - [1.3.2](https://github.com/SFort/MC-OCAIP/releases/tag/r1.3.2)
1.19.3 - 1.19.4 - [1.3.1](https://github.com/SFort/MC-OCAIP/releases/tag/r1.3.1)
1.19.2 - [1.2.5](https://github.com/SFort/MC-OCAIP/releases/tag/r1.2.5)
1.18.2 - [1.2.5-1.18.2](https://github.com/SFort/MC-OCAIP/releases/tag/r1.2.5)

____________________________________________________

### Features:
- Offline logins can be restricted by a registration password
by creating `ocaip/password` and putting the password inside

- Offline logins can be restricted by a registration proof of work
by creating `ocaip/sha1pow` and putting the amount of zero bits inside.
The recommended value is: `24`
Higher values mean longer wait time
They can also require multiple proofs of work, for example two 23 leadingZero ones by inserting `23*2`.


____________________________________________________

12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -10,22 +10,26 @@ archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
maven {
url = "https://maven.ssf.tf/"
}
}
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation include('net.i2p.crypto:eddsa:0.3.0')
modImplementation include("tf.ssf.sfort.ini:SF-INI:${project.sfini_version}")

// Fabric API. This is technically optional, but you probably want it anyway.
//modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// modImplementation "net.fabricmc.fabric-api:fabric-api:0.91.1+1.20.2"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}
loom {
accessWidenerPath = file("src/main/resources/ocaip.accesswidener")
}

processResources {
inputs.property "version", project.version

9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -3,11 +3,12 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.8
loader_version=0.14.9
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.22
sfini_version=1

# Mod Properties
mod_version = 1.2.5
mod_version = 1.3.5
maven_group = tf.ssf.sfort
archives_base_name = OCAIP
55 changes: 34 additions & 21 deletions src/main/java/sf/ssf/sfort/ocaip/AuthScreen.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package sf.ssf.sfort.ocaip;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.client.network.ServerInfo;

import java.net.InetSocketAddress;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class AuthScreen extends Screen {

final AtomicInteger processCount;
final AtomicBoolean canceled = new AtomicBoolean(false);
final Screen parent;
final ServerAddress address;
final boolean reqPass;
@@ -29,20 +34,26 @@ public AuthScreen(InetSocketAddress address, Screen parent, boolean requirePass,
this.parent = parent;
this.address = new ServerAddress(address.getHostName(), address.getPort());
this.reqPass = requirePass;
this.powCompute = powPrompt == null ? null : POW.computeSolutionAsync(powPrompt, ()->{
if (this.button != null){
button.setMessage(Text.of("Register"));
this.button.active = true;
}
}, () -> {
if (this.button != null){
button.setMessage(Text.of("Failed"));
text = "Failed to compute requirements, check logs for full error";
}
});
this.processCount = new AtomicInteger((powPrompt != null ? 1 : 0));
if (powPrompt == null) {
this.powCompute = null;
} else {
this.powCompute = POW.computeSolutionAsync(powPrompt, this::decrementProcessCount, () -> {
if (this.button != null){
button.setMessage(Text.of("Failed"));
text = "Failed to compute requirements, check logs for full error";
}
}, canceled);
}
this.init(MinecraftClient.getInstance(), parent.width, parent.height);
}

public void decrementProcessCount() {
if (this.button != null & processCount.decrementAndGet() < 1){
button.setMessage(Text.of("Register"));
this.button.active = true;
}
}
public static ServerInfo dummyInfo = new ServerInfo("dummy", "0", ServerInfo.ServerType.OTHER);
@Override
public void init() {
super.init();
@@ -53,17 +64,18 @@ public void init() {
pass.visible = false;
pass.active = false;
}
button = new ButtonWidget(width/2-62, height/2+10, 124, 20, Text.of("Register"), a -> {
ConnectScreen.connect(parent, client, address, null);

button = ButtonWidget.builder(Text.of("Register"), a -> {
ConnectScreen.connect(parent, client, address, dummyInfo, false);
String powRez = null;
try {
if (powCompute != null) powRez = powCompute.get();
} catch (InterruptedException | ExecutionException e) {
Reel.log.error("Error getting pow", e);
}
Tape.auth = new AuthObject(pass.getText(), powRez);
});
if (this.powCompute != null){
}).position(width/2-62, height/2+10).size(124, 20).build();
if (processCount.getAcquire() > 0){
button.setMessage(Text.of("Computing requirements"));
button.active = false;
}
@@ -73,15 +85,16 @@ public void init() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
if (client == null) return;
renderBackground(matrices);
textRenderer.drawWithShadow(matrices, text, width / 2f - textRenderer.getWidth(text) / 2f, height / 2f - 40, -1);
super.render(matrices, mouseX, mouseY, delta);
renderBackground(context, mouseX, mouseY, delta);
context.drawTextWithShadow(textRenderer, text, (int)(width / 2f - textRenderer.getWidth(text) / 2f), (int)(height / 2f - 40), -1);
super.render(context, mouseX, mouseY, delta);
}

@Override
public void close() {
canceled.set(true);
this.client.setScreen(parent);
}

42 changes: 18 additions & 24 deletions src/main/java/sf/ssf/sfort/ocaip/OfflineSkinResourcePack.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sf.ssf.sfort.ocaip;

import com.google.common.collect.ImmutableSet;
import net.minecraft.resource.InputSupplier;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourceType;
import net.minecraft.resource.metadata.ResourceMetadataReader;
@@ -13,28 +14,26 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;

public class OfflineSkinResourcePack implements ResourcePack {
@Nullable
@Override
public InputStream openRoot(String fileName) throws IOException {
if (fileName.contains("/") || fileName.contains("\\")) {
throw new IllegalArgumentException("Root resources can only be filenames, not paths (no / allowed!)");
@Nullable @Override
public InputSupplier<InputStream> openRoot(String... segments) {
if (segments.length == 0) return null;
if (segments.length > 1) {
throw new IllegalArgumentException("Too many segments");
}
return getIS(fileName);
String name = segments[0];
return () -> getIS(name);
}

public static byte[] getPngBytes(String name) {
try {
return Files.readAllBytes(new File(Reel.skinDir+"/"+name+".png").toPath());
} catch (IOException e) {
Reel.log.error("Failed to read png: "+name, e);
Reel.log.warn("Failed to read png: "+name);
}
return null;
}
@@ -56,24 +55,19 @@ public static InputStream getIS(String name) throws IOException {
}

@Override
public InputStream open(ResourceType type, Identifier id) throws IOException {
if (type!= ResourceType.CLIENT_RESOURCES) throw new FileNotFoundException(id.toString());
return getIS(id.getPath()+".png");
public InputSupplier<InputStream> open(ResourceType type, Identifier id) {
if (type!= ResourceType.CLIENT_RESOURCES) return null;
try {
if (getIS(id.getPath() + ".png") == null) return null;
} catch (Exception e) {
return null;
}
return () -> getIS(id.getPath()+".png");
}

@Override
public Collection<Identifier> findResources(ResourceType type, String namespace, String prefix, Predicate<Identifier> allowedPathPredicate) {
return Collections.emptySet();
}
public void findResources(ResourceType type, String namespace, String prefix, ResultConsumer consumer) {

@Override
public boolean contains(ResourceType type, Identifier id) {
try {
getIS(id.getPath()+".png");
} catch (IOException e) {
return false;
}
return true;
}

@Override
91 changes: 91 additions & 0 deletions src/main/java/sf/ssf/sfort/ocaip/OldCustomPayload.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package sf.ssf.sfort.ocaip;

import io.netty.buffer.Unpooled;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.network.packet.c2s.login.LoginQueryResponsePayload;
import net.minecraft.network.packet.s2c.login.LoginQueryRequestPayload;
import net.minecraft.util.Identifier;

public abstract class OldCustomPayload {
public Identifier id = null;
public PacketByteBuf buf = null;

public OldCustomPayload(Identifier id, PacketByteBuf buf) {
this.id = id;
this.buf = buf;
}

public OldCustomPayload(PacketByteBuf buf) {
this.id = buf.readIdentifier();
byte[] arr = buf.readByteArray();
this.buf = new PacketByteBuf(Unpooled.buffer(arr.length));
this.buf.writeBytes(arr);
}

public static class LoginRequest extends OldCustomPayload implements LoginQueryRequestPayload {

public LoginRequest(Identifier id, PacketByteBuf buf) {
super(id, buf);
}

public LoginRequest(PacketByteBuf buf) {
super(buf);
}

@Override
public void write(PacketByteBuf buf) {
buf.writeIdentifier(this.id);
buf.writeByteArray(this.buf.capacity(this.buf.readableBytes()).array());
}

@Override
public Identifier id() {
return id;
}
}

public static class LoginResponse extends OldCustomPayload implements LoginQueryResponsePayload {

public LoginResponse(Identifier id, PacketByteBuf buf) {
super(id, buf);
}

public LoginResponse(PacketByteBuf buf) {
super(buf);
}

@Override
public void write(PacketByteBuf buf) {
buf.writeIdentifier(this.id);
buf.writeByteArray(this.buf.capacity(this.buf.readableBytes()).array());
}

public Identifier id() {
return id;
}
}

public static class Custom extends OldCustomPayload implements CustomPayload {

public Custom(Identifier id, PacketByteBuf buf) {
super(id, buf);
}

public Custom(PacketByteBuf buf) {
super(buf);
}

@Override
public void write(PacketByteBuf buf) {
buf.writeIdentifier(this.id);
buf.writeByteArray(this.buf.capacity(this.buf.readableBytes()).array());
}

@Override
public Identifier id() {
return id;
}
}

}
Loading