Skip to content

Commit

Permalink
Prep for final release.
Browse files Browse the repository at this point in the history
  • Loading branch information
azzy committed Nov 3, 2022
1 parent 92ce6b0 commit efa96f7
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ max_errors=400
fabric_version=0.58.0+1.18.2

# Mod Properties
mod_version = 1.7.2.INDEV-4
mod_version = 1.7.2
# todo change
maven_group = azzy.fabric
archives_base_name = incubus-core
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package net.id.incubus_core.recipe.matchbook;

import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;

public class BooleanMatch extends Match {

private boolean booleanValue;

public BooleanMatch(String name, String key) {
super(name, key);
}

@Override
boolean matches(ItemStack stack) {
var nbt = stack.getOrCreateNbt();

if(nbt.contains(key)) {
return nbt.getBoolean(key) == booleanValue;
}

return false;
}

@Override
void configure(JsonObject json) {
booleanValue = json.get("value").getAsBoolean();
}

@Override
void configure(PacketByteBuf buf) {
booleanValue = buf.readBoolean();
}

@Override
void write(PacketByteBuf buf) {
buf.writeBoolean(booleanValue);
}

public static class Factory extends MatchFactory<BooleanMatch> {

public Factory() {
super("boolean");
}

@Override
public BooleanMatch create(String key, JsonObject object) {
var match = new BooleanMatch(name, key);
match.configure(object);

return match;
}

@Override
public BooleanMatch fromPacket(PacketByteBuf buf) {
var match = new BooleanMatch(name, buf.readString());
match.configure(buf);

return match;
}
}

}
64 changes: 64 additions & 0 deletions src/main/java/net/id/incubus_core/recipe/matchbook/ByteMatch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package net.id.incubus_core.recipe.matchbook;

import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;

public class ByteMatch extends Match {

private byte targetByte;

public ByteMatch(String name, String key) {
super(name, key);
}

@Override
boolean matches(ItemStack stack) {
var nbt = stack.getOrCreateNbt();

if(nbt.contains(key)) {
return nbt.getByte(key) == targetByte;
}

return false;
}

@Override
void configure(JsonObject json) {
targetByte = json.get("target").getAsByte();
}

@Override
void configure(PacketByteBuf buf) {
targetByte = buf.readByte();
}

@Override
void write(PacketByteBuf buf) {
buf.writeByte(targetByte);
}

public static class Factory extends MatchFactory<ByteMatch> {

public Factory() {
super("byte");
}

@Override
public ByteMatch create(String key, JsonObject object) {
var match = new ByteMatch(name, key);
match.configure(object);

return match;
}

@Override
public ByteMatch fromPacket(PacketByteBuf buf) {
var match = new ByteMatch(name, buf.readString());
match.configure(buf);

return match;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void configure(PacketByteBuf buf) {

@Override
void write(PacketByteBuf buf) {
buf.writeString(key);
buf.writeFloat(min);
buf.writeFloat(max);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ public static void init() {
MatchRegistry.registerInternal("int", new IntMatch.Factory());
MatchRegistry.registerInternal("intRange", new IntRangeMatch.Factory());
MatchRegistry.registerInternal("float", new FloatMatch.Factory());
MatchRegistry.registerInternal("long", new LongMatch.Factory());
MatchRegistry.registerInternal("short", new ShortMatch.Factory());
MatchRegistry.registerInternal("byte", new ByteMatch.Factory());
MatchRegistry.registerInternal("string", new StringMatch.Factory());
MatchRegistry.registerInternal("boolean", new BooleanMatch.Factory());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void configure(PacketByteBuf buf) {

@Override
void write(PacketByteBuf buf) {
buf.writeString(key);
buf.writeInt(targetInt);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void configure(PacketByteBuf buf) {

@Override
void write(PacketByteBuf buf) {
buf.writeString(key);
buf.writeInt(min);
buf.writeInt(max);
}
Expand Down
64 changes: 64 additions & 0 deletions src/main/java/net/id/incubus_core/recipe/matchbook/LongMatch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package net.id.incubus_core.recipe.matchbook;

import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;

public class LongMatch extends Match {

private long targetLong;

public LongMatch(String name, String key) {
super(name, key);
}

@Override
boolean matches(ItemStack stack) {
var nbt = stack.getOrCreateNbt();

if(nbt.contains(key)) {
return nbt.getLong(key) == targetLong;
}

return false;
}

@Override
void configure(JsonObject json) {
targetLong = json.get("target").getAsLong();
}

@Override
void configure(PacketByteBuf buf) {
targetLong = buf.readLong();
}

@Override
void write(PacketByteBuf buf) {
buf.writeLong(targetLong);
}

public static class Factory extends MatchFactory<LongMatch> {

public Factory() {
super("long");
}

@Override
public LongMatch create(String key, JsonObject object) {
var match = new LongMatch(name, key);
match.configure(object);

return match;
}

@Override
public LongMatch fromPacket(PacketByteBuf buf) {
var match = new LongMatch(name, buf.readString());
match.configure(buf);

return match;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public String getName() {

public void writeInternal(PacketByteBuf buf) {
buf.writeString(name);
buf.writeString(key);
write(buf);
}

Expand Down
64 changes: 64 additions & 0 deletions src/main/java/net/id/incubus_core/recipe/matchbook/ShortMatch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package net.id.incubus_core.recipe.matchbook;

import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;

public class ShortMatch extends Match {

private short targetShort;

public ShortMatch(String name, String key) {
super(name, key);
}

@Override
boolean matches(ItemStack stack) {
var nbt = stack.getOrCreateNbt();

if(nbt.contains(key)) {
return nbt.getShort(key) == targetShort;
}

return false;
}

@Override
void configure(JsonObject json) {
targetShort = json.get("target").getAsShort();
}

@Override
void configure(PacketByteBuf buf) {
targetShort = buf.readShort();
}

@Override
void write(PacketByteBuf buf) {
buf.writeShort(targetShort);
}

public static class Factory extends MatchFactory<ShortMatch> {

public Factory() {
super("short");
}

@Override
public ShortMatch create(String key, JsonObject object) {
var match = new ShortMatch(name, key);
match.configure(object);

return match;
}

@Override
public ShortMatch fromPacket(PacketByteBuf buf) {
var match = new ShortMatch(name, buf.readString());
match.configure(buf);

return match;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void configure(PacketByteBuf buf) {

@Override
void write(PacketByteBuf buf) {
buf.writeString(key);
buf.writeString(targetString);
}

Expand Down

0 comments on commit efa96f7

Please sign in to comment.