generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 8
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
azzy
committed
Nov 3, 2022
1 parent
92ce6b0
commit efa96f7
Showing
11 changed files
with
262 additions
and
5 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
64 changes: 64 additions & 0 deletions
64
src/main/java/net/id/incubus_core/recipe/matchbook/BooleanMatch.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,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
64
src/main/java/net/id/incubus_core/recipe/matchbook/ByteMatch.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,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; | ||
} | ||
} | ||
|
||
} |
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
64 changes: 64 additions & 0 deletions
64
src/main/java/net/id/incubus_core/recipe/matchbook/LongMatch.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,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; | ||
} | ||
} | ||
|
||
} |
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
64 changes: 64 additions & 0 deletions
64
src/main/java/net/id/incubus_core/recipe/matchbook/ShortMatch.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,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; | ||
} | ||
} | ||
|
||
} |
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