Small fixes
This commit is contained in:
parent
8fc439a24d
commit
01d29a3aa7
3 changed files with 34 additions and 3 deletions
|
@ -1,7 +1,11 @@
|
||||||
package ru.betterend;
|
package ru.betterend;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.tag.ItemTags;
|
||||||
import ru.betterend.config.MainConfig;
|
import ru.betterend.config.MainConfig;
|
||||||
|
import ru.betterend.recipe.RecipeBuilder;
|
||||||
import ru.betterend.registry.BiomeRegistry;
|
import ru.betterend.registry.BiomeRegistry;
|
||||||
import ru.betterend.registry.BlockRegistry;
|
import ru.betterend.registry.BlockRegistry;
|
||||||
import ru.betterend.registry.FeatureRegistry;
|
import ru.betterend.registry.FeatureRegistry;
|
||||||
|
@ -21,5 +25,25 @@ public class BetterEnd implements ModInitializer {
|
||||||
FeatureRegistry.register();
|
FeatureRegistry.register();
|
||||||
BiomeRegistry.register();
|
BiomeRegistry.register();
|
||||||
BetterEndBiomeSource.register();
|
BetterEndBiomeSource.register();
|
||||||
|
|
||||||
|
// TEST //
|
||||||
|
new RecipeBuilder("test_block", Blocks.ANVIL)
|
||||||
|
.setShape(new String[] {"I#", "#I"})
|
||||||
|
.addMaterial('I', Items.STRING)
|
||||||
|
.addMaterial('#', Items.APPLE)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
new RecipeBuilder("test_block_shaped", Blocks.STONE)
|
||||||
|
.setShape(new String[] {"I#", "#I"})
|
||||||
|
.addMaterial('I', Items.STRING)
|
||||||
|
.addMaterial('#', ItemTags.LOGS)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
new RecipeBuilder("test_item_shapeless", Items.SUGAR)
|
||||||
|
.setShape(new String[] {"I#Y"})
|
||||||
|
.addMaterial('I', Items.STRING)
|
||||||
|
.addMaterial('#', ItemTags.LOGS)
|
||||||
|
.addMaterial('Y', ItemTags.ARROWS)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class RecipeManagerMixin
|
||||||
@Shadow
|
@Shadow
|
||||||
private Map<RecipeType<?>, Map<Identifier, Recipe<?>>> recipes;
|
private Map<RecipeType<?>, Map<Identifier, Recipe<?>>> recipes;
|
||||||
|
|
||||||
@Inject(method = "apply", at = @At(value = "TAIL"))
|
@Inject(method = "apply", at = @At(value = "RETURN"))
|
||||||
private void setRecipes(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info)
|
private void setRecipes(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info)
|
||||||
{
|
{
|
||||||
recipes = EndRecipeManager.getMap(recipes);
|
recipes = EndRecipeManager.getMap(recipes);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class RecipeBuilder {
|
||||||
private boolean shaped = true;
|
private boolean shaped = true;
|
||||||
private String[] shape = new String[] {"#"};
|
private String[] shape = new String[] {"#"};
|
||||||
private Map<Character, Ingredient> materialKeys = Maps.newHashMap();
|
private Map<Character, Ingredient> materialKeys = Maps.newHashMap();
|
||||||
private int count;
|
private int count = 1;
|
||||||
|
|
||||||
public RecipeBuilder(String name, Item output) {
|
public RecipeBuilder(String name, Item output) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -48,6 +48,12 @@ public class RecipeBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RecipeBuilder setList(String shape) {
|
||||||
|
this.shape = new String[] {shape};
|
||||||
|
this.shaped = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public RecipeBuilder addMaterial(char key, Item value) {
|
public RecipeBuilder addMaterial(char key, Item value) {
|
||||||
materialKeys.put(key, Ingredient.ofItems(value));
|
materialKeys.put(key, Ingredient.ofItems(value));
|
||||||
return this;
|
return this;
|
||||||
|
@ -70,11 +76,12 @@ public class RecipeBuilder {
|
||||||
|
|
||||||
private DefaultedList<Ingredient> getMaterials(int width, int height) {
|
private DefaultedList<Ingredient> getMaterials(int width, int height) {
|
||||||
DefaultedList<Ingredient> materials = DefaultedList.ofSize(width * height, Ingredient.EMPTY);
|
DefaultedList<Ingredient> materials = DefaultedList.ofSize(width * height, Ingredient.EMPTY);
|
||||||
|
int pos = 0;
|
||||||
for (String line: shape) {
|
for (String line: shape) {
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
char c = line.charAt(i);
|
char c = line.charAt(i);
|
||||||
Ingredient material = materialKeys.get(c);
|
Ingredient material = materialKeys.get(c);
|
||||||
materials.add(material == null ? Ingredient.EMPTY : material);
|
materials.set(pos ++, material == null ? Ingredient.EMPTY : material);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return materials;
|
return materials;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue