Skip to content

Commit fd81293

Browse files
committed
feat: all shit
1 parent b458c7f commit fd81293

File tree

5 files changed

+58
-57
lines changed

5 files changed

+58
-57
lines changed

logs/latest.log

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[02:10:13] [Test worker/INFO]: check 1
2-
[02:10:13] [Test worker/INFO]: running ItemStack tests 2
3-
[02:10:13] [Test worker/INFO]: item:
1+
[22:10:09] [Test worker/INFO]: check 1
2+
[22:10:09] [Test worker/INFO]: running ItemStack tests 2
3+
[22:10:09] [Test worker/INFO]: item:
44
==: org.bukkit.inventory.ItemStack
55
v: 3465
66
type: DIRT
@@ -10,9 +10,9 @@
1010
PublicBukkitValues:
1111
infinityexpansion:display: 351372703i
1212

13-
[02:10:14] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkit.BukkitMetaItem me.matl114.bukkit.BukkitMetaItem.deserialize(java.util.Map) throws java.lang.Throwable' of class me.matl114.bukkit.BukkitMetaItem for deserialization java.lang.ExceptionInInitializerError
14-
[02:10:14] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkit.BukkitItemStack me.matl114.bukkit.BukkitItemStack.deserialize(java.util.Map)' of class me.matl114.bukkit.BukkitItemStack for deserialization java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.item.Items
15-
[02:10:14] [Test worker/INFO]: null
16-
[02:10:14] [Test worker/INFO]: check 2
17-
[02:10:14] [Test worker/INFO]: running ItemStack tests 2
18-
[02:10:14] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkit.BukkitMetaItem me.matl114.bukkit.BukkitMetaItem.deserialize(java.util.Map) throws java.lang.Throwable' of class me.matl114.bukkit.BukkitMetaItem for deserialization java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.item.Items
13+
[22:10:10] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkit.BukkitMetaItem me.matl114.bukkit.BukkitMetaItem.deserialize(java.util.Map) throws java.lang.Throwable' of class me.matl114.bukkit.BukkitMetaItem for deserialization java.lang.ExceptionInInitializerError
14+
[22:10:10] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkit.BukkitItemStack me.matl114.bukkit.BukkitItemStack.deserialize(java.util.Map)' of class me.matl114.bukkit.BukkitItemStack for deserialization java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.item.Items
15+
[22:10:10] [Test worker/INFO]: null
16+
[22:10:10] [Test worker/INFO]: check 2
17+
[22:10:10] [Test worker/INFO]: running ItemStack tests 2
18+
[22:10:10] [Test worker/INFO]: Could not call method 'public static me.matl114.bukkit.BukkitMetaItem me.matl114.bukkit.BukkitMetaItem.deserialize(java.util.Map) throws java.lang.Throwable' of class me.matl114.bukkit.BukkitMetaItem for deserialization java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.item.Items

src/main/java/me/matl114/hacks/RecipeTasks.java

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ public class RecipeTasks {
2222
public static final Map EMPTY = Map.of();
2323
public static final Map<String, RecipeType> TYPE_MAP = new LinkedHashMap<>();
2424

25-
26-
public static RecipeType getById(String id){
27-
if(TYPE_MAP .isEmpty()){
28-
Registries.RECIPE_TYPE.stream().forEach(rt->TYPE_MAP.put(Registries.RECIPE_TYPE.getId(rt).toString(),rt));
29-
}
30-
return TYPE_MAP.get(id);
25+
public static boolean isVanillaRecipeType(String rid){
26+
return Registries.RECIPE_TYPE.getOrEmpty(Identifier.tryParse(rid)).isPresent();
3127
}
3228

3329
public static Map<Identifier, RecipeRecord> getAllRecipe(){
@@ -61,7 +57,7 @@ private static void resetCache(){
6157
}
6258
public static record RecipeRecord(Identifier identifier, Recipe<?> instance, RecipeType<?> type, ItemStack output, RecipeIngredient[] ingredients) implements me.matl114.hacks.utils.recipes.RecipeEntry {
6359
public static RecipeRecord of(RecipeEntry<?> instance, RecipeType type){
64-
return new RecipeRecord(instance.id(), (Recipe<?>) (Object)instance.value(), type, instance.value().getResult( mc.world.getRegistryManager()), SlimefunTasks.transfer3x3RecipeDisplay(instance.value(), instance.value().getIngredients().stream().map(v -> new RecipeIngredient(v.getMatchingStacks())).toArray(RecipeIngredient[]::new)));
60+
return new RecipeRecord(instance.id(), (Recipe<?>) (Object)instance.value(), type, instance.value().getResult( mc.world.getRegistryManager()), RecipeTasks.transfer3x3RecipeDisplay(instance.value(), instance.value().getIngredients().stream().map(v -> new RecipeIngredient(v.getMatchingStacks())).toArray(RecipeIngredient[]::new)));
6561
}
6662
@Override
6763
public String rid() {
@@ -80,6 +76,43 @@ public RecipeIngredient[] ingredient() {
8076

8177
}
8278

79+
80+
public static RecipeIngredient[] transfer3x3RecipeDisplay(RecipeTasks.RecipeRecord recipeRecord){
81+
return recipeRecord.ingredients();
82+
}
83+
public static RecipeIngredient[] transfer3x3RecipeDisplay(Recipe<?> instance, RecipeIngredient[] ingred){
84+
85+
RecipeIngredient[] ingredients = new RecipeIngredient[9];
86+
87+
if(instance instanceof ShapedRecipe shaped){
88+
List<Ingredient> raw = RecipeTasks.getIngredients(shaped);
89+
int width = shaped.getWidth();
90+
int height = shaped.getHeight();
91+
for (int i=0; i< 3; ++i){
92+
for(int j = 0; j< 3; ++j){
93+
if(i < height && j < width){
94+
ingredients[3*i + j] = new RecipeIngredient(RecipeTasks.streamIngredientOptions(raw.get(width * i + j)).toArray(ItemStack[]::new));
95+
}else {
96+
ingredients[3*i + j] = RecipeIngredient.EMPTY;
97+
}
98+
}
99+
}
100+
}else {
101+
System.arraycopy(ingred, 0, ingredients, 0, ingred.length);
102+
for (int i = ingred.length; i<9 ; ++i){
103+
ingredients[i] = RecipeIngredient.EMPTY;
104+
}
105+
}
106+
return ingredients;
107+
}
108+
109+
110+
111+
112+
113+
114+
115+
83116
public static List<Ingredient> getIngredients(Recipe<?> recipe){
84117
return recipe.getIngredients();
85118
}
@@ -92,6 +125,10 @@ public static List<Ingredient> getIngredients(RecipeEntry<?> recipeEntry){
92125
return recipeEntry.value().getIngredients();
93126
}
94127

128+
public static ItemStack getRecipeResult(RecipeEntry<?> recipeEntry){
129+
return recipeEntry.value().getResult(MinecraftClient.getInstance().world.getRegistryManager());
130+
}
131+
95132
static{
96133
// Listener.getServerDisconnectPoint().registerHandler((v)->{
97134
// resetCache();

src/main/java/me/matl114/hacks/SlimefunTasks.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -302,41 +302,6 @@ public static void moveSlimefunRecipePatternToContainer(RecipeEntry entry, Scree
302302
InvTasks.moveRecipePatternToContainer(screen, ingredients, acceptSlots, amount, removeOrigin, ((screen1, itemStack) -> getItemStackMatchingSlot(screen1, itemStack, true, playerInv)));
303303
}
304304

305-
public static RecipeIngredient[] transfer3x3RecipeDisplay(RecipeTasks.RecipeRecord recipeRecord){
306-
return recipeRecord.ingredients();
307-
}
308-
public static RecipeIngredient[] transfer3x3RecipeDisplay(Recipe<?> instance, RecipeIngredient[] ingred){
309-
310-
RecipeIngredient[] ingredients = new RecipeIngredient[9];
311-
312-
if(instance instanceof ShapedRecipe shaped){
313-
List<Ingredient> raw = RecipeTasks.getIngredients(shaped);
314-
int width = shaped.getWidth();
315-
int height = shaped.getHeight();
316-
for (int i=0; i< 3; ++i){
317-
for(int j = 0; j< 3; ++j){
318-
if(i < height && j < width){
319-
ingredients[3*i + j] = new RecipeIngredient(RecipeTasks.streamIngredientOptions(raw.get(width * i + j)).toArray(ItemStack[]::new));
320-
}else {
321-
ingredients[3*i + j] = RecipeIngredient.EMPTY;
322-
}
323-
}
324-
}
325-
}else {
326-
System.arraycopy(ingred, 0, ingredients, 0, ingred.length);
327-
for (int i = ingred.length; i<9 ; ++i){
328-
ingredients[i] = RecipeIngredient.EMPTY;
329-
}
330-
}
331-
return ingredients;
332-
}
333-
334-
335-
336-
337-
338-
339-
340305
static{
341306
Tasks.scheduleDelayed(()->{
342307
//post init tasks

src/main/java/me/matl114/hacks/modules/inv/FastCraft.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ public void craftAtSlotIndex(HandledScreen<?> screen, int maxCraft, int slot){
135135

136136
@Getter
137137
boolean lock;
138-
RecipeEntry<?> entry;
139138
private ItemStack getDisplayItemStack(){
140-
if(entry != null){
141-
return entry.value().getResult(MinecraftClient.getInstance().world.getRegistryManager());
139+
if(lastCrafted != null){
140+
return RecipeTasks.getRecipeResult(lastCrafted);
142141
}else{
143142
return new ItemStack(Items.BARRIER);
144143
}

src/main/java/me/matl114/hacks/modules/slimefun/SlimefunGuide.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ public void openVanillaRecipesMenu(){
199199

200200
public void onClickRecipeType(String type, boolean isLeft){
201201
if(handleNotEnable())return;
202-
RecipeType type1 = RecipeTasks.getById(type);
203202
List<RecipeEntry> myEntry;
204-
if(type1 != null){
203+
204+
if(RecipeTasks.isVanillaRecipeType(type)){
205205
Map<Identifier, RecipeTasks.RecipeRecord> myCache = RecipeTasks.getAllRecipe();
206206
myEntry = myCache.values() // RecipeTasks.getRecipeByType(type1)
207207
.stream()
208-
.filter(i-> i.type() == type1)
208+
.filter(i-> Objects.equals(i.rid(), type))
209209
.map(RecipeEntry.class::cast)
210210
// .map(i->(RecipeEntry)myCache.get(i.id()))
211211
// .filter(Objects::nonNull)

0 commit comments

Comments
 (0)