- End Stone Smelter REI fuel display
- End Furnaces REI fuel and smelting displays
This commit is contained in:
parent
2fabb39f41
commit
f29d69c69b
8 changed files with 205 additions and 34 deletions
|
@ -8,6 +8,6 @@ import ru.betterend.blocks.basis.BlockBase;
|
|||
public class CharcoalBlock extends BlockBase {
|
||||
public CharcoalBlock() {
|
||||
super(FabricBlockSettings.copyOf(Blocks.COAL_BLOCK));
|
||||
FuelRegistry.INSTANCE.add(this, 6000);
|
||||
FuelRegistry.INSTANCE.add(this, 16000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
package ru.betterend.blocks.entities;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.fabricmc.fabric.impl.content.registry.FuelRegistryImpl;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
||||
import net.minecraft.block.entity.LockableContainerBlockEntity;
|
||||
import net.minecraft.entity.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -23,12 +19,7 @@ import net.minecraft.item.ItemConvertible;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.recipe.BlastingRecipe;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeFinder;
|
||||
import net.minecraft.recipe.RecipeInputProvider;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.recipe.RecipeUnlocker;
|
||||
import net.minecraft.recipe.*;
|
||||
import net.minecraft.screen.PropertyDelegate;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -46,6 +37,10 @@ import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
|
|||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity implements SidedInventory, RecipeUnlocker, RecipeInputProvider, Tickable {
|
||||
|
||||
private static final int[] TOP_SLOTS = new int[] { 0, 1 };
|
||||
|
@ -102,14 +97,6 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
|
|||
return 4;
|
||||
}
|
||||
};
|
||||
|
||||
this.registerFuels();
|
||||
}
|
||||
|
||||
private void registerFuels() {
|
||||
registerFuel(Items.LAVA_BUCKET, 16000);
|
||||
registerFuel(Blocks.COAL_BLOCK, 12000);
|
||||
registerFuel(Items.BLAZE_ROD, 2000);
|
||||
}
|
||||
|
||||
private boolean isBurning() {
|
||||
|
@ -458,4 +445,12 @@ public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity imp
|
|||
Integer ticks = FuelRegistry.INSTANCE.get(stack.getItem());
|
||||
return ticks == null ? 0 : ticks;
|
||||
}
|
||||
|
||||
static {
|
||||
AbstractFurnaceBlockEntity.createFuelTimeMap().forEach((item, time) -> {
|
||||
if (time >= 2000) {
|
||||
registerFuel(item, time);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ public class Configs {
|
|||
public static final IdConfig BIOME_CONFIG = new EntryConfig("biomes");
|
||||
public static final PathConfig GENERATOR_CONFIG = new PathConfig("generator");
|
||||
public static final PathConfig RECIPE_CONFIG = new PathConfig("recipes");
|
||||
public static final PortalsConfig PORTALS_CONFIG = new PortalsConfig("portals");
|
||||
|
||||
@Environment(value = EnvType.CLIENT)
|
||||
public static final PathConfig CLENT_CONFIG = new PathConfig("client");
|
||||
|
|
19
src/main/java/ru/betterend/config/PortalsConfig.java
Normal file
19
src/main/java/ru/betterend/config/PortalsConfig.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package ru.betterend.config;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class PortalsConfig {
|
||||
|
||||
|
||||
private final ConfigWriter writer;
|
||||
private final JsonObject configObject;
|
||||
|
||||
public PortalsConfig(String path) {
|
||||
this.writer = new ConfigWriter(path);
|
||||
this.configObject = writer.load();
|
||||
}
|
||||
|
||||
public void saveChanges() {
|
||||
writer.save();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.shedaniel.math.Point;
|
||||
import me.shedaniel.math.Rectangle;
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeCategory;
|
||||
import me.shedaniel.rei.api.widgets.Slot;
|
||||
import me.shedaniel.rei.api.widgets.Tooltip;
|
||||
import me.shedaniel.rei.api.widgets.Widgets;
|
||||
import me.shedaniel.rei.gui.entries.RecipeEntry;
|
||||
import me.shedaniel.rei.gui.widget.Widget;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class REIAlloyingFuelCategory implements RecipeCategory<REIAlloyingFuelDisplay> {
|
||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getIdentifier() {
|
||||
return REIPlugin.ALLOYING_FUEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getCategoryName() {
|
||||
return I18n.translate("category.rei.fuel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayHeight() {
|
||||
return 49;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return EntryStack.create(Items.COAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Widget> setupDisplay(REIAlloyingFuelDisplay recipeDisplay, Rectangle bounds) {
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 17);
|
||||
String burnTime = DECIMAL_FORMAT.format(recipeDisplay.getFuelTime());
|
||||
List<Widget> widgets = Lists.newArrayList();
|
||||
widgets.add(Widgets.createRecipeBase(bounds));
|
||||
widgets.add(Widgets.createLabel(new Point(bounds.x + 26, bounds.getMaxY() - 15), new TranslatableText("category.rei.fuel.time", burnTime))
|
||||
.color(0xFF404040, 0xFFBBBBBB).noShadow().leftAligned());
|
||||
widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1)).animationDurationTicks(recipeDisplay.getFuelTime()));
|
||||
widgets.add(Widgets.createSlot(new Point(bounds.x + 6, startPoint.y + 18)).entries(recipeDisplay.getInputEntries().get(0)).markInput());
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RecipeEntry getSimpleRenderer(REIAlloyingFuelDisplay recipe) {
|
||||
Slot slot = Widgets.createSlot(new Point(0, 0)).entries(recipe.getInputEntries().get(0)).disableBackground().disableHighlight();
|
||||
String burnItems = DECIMAL_FORMAT.format(recipe.getFuelTime() / 200d);
|
||||
return new RecipeEntry() {
|
||||
private TranslatableText text = new TranslatableText("category.rei.fuel.time_short.items", burnItems);
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Tooltip getTooltip(Point point) {
|
||||
if (slot.containsMouse(point))
|
||||
return slot.getCurrentTooltip(point);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
|
||||
slot.setZ(getZ() + 50);
|
||||
slot.getBounds().setLocation(bounds.x + 4, bounds.y + 2);
|
||||
slot.render(matrices, mouseX, mouseY, delta);
|
||||
MinecraftClient.getInstance().textRenderer.drawWithShadow(matrices, text.asOrderedText(), bounds.x + 25, bounds.y + 8, -1);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeDisplay;
|
||||
import me.shedaniel.rei.plugin.DefaultPlugin;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class REIAlloyingFuelDisplay implements RecipeDisplay {
|
||||
private EntryStack fuel;
|
||||
private int fuelTime;
|
||||
|
||||
public REIAlloyingFuelDisplay(EntryStack fuel, int fuelTime) {
|
||||
this.fuel = fuel;
|
||||
this.fuelTime = fuelTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getInputEntries() {
|
||||
return Collections.singletonList(Collections.singletonList(fuel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<List<EntryStack>> getResultingEntries() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identifier getRecipeCategory() {
|
||||
return REIPlugin.ALLOYING_FUEL;
|
||||
}
|
||||
|
||||
public int getFuelTime() {
|
||||
return fuelTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -41,7 +42,7 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
|||
|
||||
@Override
|
||||
public @NotNull EntryStack getLogo() {
|
||||
return REIPlugin.ANVILS.get(0);
|
||||
return REIPlugin.ANVILS[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +56,7 @@ public class REIAnvilCategory implements TransferRecipeCategory<REIAnvilDisplay>
|
|||
List<List<EntryStack>> inputEntries = display.getInputEntries();
|
||||
List<EntryStack> materials = inputEntries.get(1);
|
||||
int anvilLevel = display.getAnvilLevel();
|
||||
List<EntryStack> anvils = REIPlugin.ANVILS.stream().filter(anvil -> {
|
||||
List<EntryStack> anvils = Arrays.stream(REIPlugin.ANVILS).filter(anvil -> {
|
||||
Block block = ((BlockItem) anvil.getItem()).getBlock();
|
||||
if (block instanceof EndAnvilBlock) {
|
||||
return ((EndAnvilBlock) block).getCraftingLevel() >= anvilLevel;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.integration.rei;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -8,14 +9,19 @@ import com.google.common.collect.Lists;
|
|||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeHelper;
|
||||
import me.shedaniel.rei.api.plugins.REIPluginV0;
|
||||
import me.shedaniel.rei.plugin.DefaultPlugin;
|
||||
import me.shedaniel.rei.plugin.fuel.DefaultFuelDisplay;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.impl.content.registry.FuelRegistryImpl;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.recipe.BlastingRecipe;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.blocks.basis.EndFurnaceBlock;
|
||||
import ru.betterend.blocks.entities.EndStoneSmelterBlockEntity;
|
||||
import ru.betterend.recipe.builders.AlloyingRecipe;
|
||||
import ru.betterend.recipe.builders.AnvilRecipe;
|
||||
import ru.betterend.recipe.builders.InfusionRecipe;
|
||||
|
@ -26,13 +32,15 @@ import ru.betterend.registry.EndItems;
|
|||
public class REIPlugin implements REIPluginV0 {
|
||||
|
||||
public final static Identifier PLUGIN_ID = BetterEnd.makeID("rei_plugin");
|
||||
public final static Identifier ALLOYING_FUEL = BetterEnd.makeID("alloying_fuel");
|
||||
public final static Identifier ALLOYING = AlloyingRecipe.ID;
|
||||
public final static Identifier SMITHING = AnvilRecipe.ID;
|
||||
public final static Identifier INFUSION = InfusionRecipe.ID;
|
||||
|
||||
public final static EntryStack END_STONE_SMELTER = EntryStack.create(EndBlocks.END_STONE_SMELTER);
|
||||
public final static EntryStack INFUSION_RITUAL = EntryStack.create(EndBlocks.INFUSION_PEDESTAL);
|
||||
public final static List<EntryStack> ANVILS;
|
||||
public final static EntryStack[] FURNACES;
|
||||
public final static EntryStack[] ANVILS;
|
||||
|
||||
@Override
|
||||
public Identifier getPluginIdentifier() {
|
||||
|
@ -45,26 +53,43 @@ public class REIPlugin implements REIPluginV0 {
|
|||
recipeHelper.registerRecipes(ALLOYING, BlastingRecipe.class, REIAlloyingDisplay::new);
|
||||
recipeHelper.registerRecipes(SMITHING, AnvilRecipe.class, REIAnvilDisplay::new);
|
||||
recipeHelper.registerRecipes(INFUSION, InfusionRecipe.class, REIInfusionDisplay::new);
|
||||
FuelRegistryImpl.INSTANCE.getFuelTimes().forEach((item, time) -> {
|
||||
if (time >= 2000) {
|
||||
System.out.println(item);
|
||||
recipeHelper.registerDisplay(new REIAlloyingFuelDisplay(EntryStack.create(item), time));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOthers(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerWorkingStations(ALLOYING_FUEL, END_STONE_SMELTER);
|
||||
recipeHelper.registerWorkingStations(ALLOYING, END_STONE_SMELTER);
|
||||
recipeHelper.registerWorkingStations(INFUSION, INFUSION_RITUAL);
|
||||
recipeHelper.registerWorkingStations(SMITHING, ANVILS.toArray(new EntryStack[]{}));
|
||||
recipeHelper.registerWorkingStations(SMITHING, ANVILS);
|
||||
recipeHelper.removeAutoCraftButton(ALLOYING_FUEL);
|
||||
recipeHelper.removeAutoCraftButton(SMITHING);
|
||||
|
||||
recipeHelper.registerWorkingStations(DefaultPlugin.SMELTING, FURNACES);
|
||||
recipeHelper.registerWorkingStations(DefaultPlugin.FUEL, FURNACES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPluginCategories(RecipeHelper recipeHelper) {
|
||||
recipeHelper.registerCategories(new REIAlloyingCategory(),
|
||||
new REIInfusionCategory(),
|
||||
new REIAnvilCategory());
|
||||
recipeHelper.registerCategories(
|
||||
new REIAlloyingFuelCategory(),
|
||||
new REIAlloyingCategory(),
|
||||
new REIInfusionCategory(),
|
||||
new REIAnvilCategory());
|
||||
}
|
||||
|
||||
static {
|
||||
ANVILS = Lists.newArrayList(EntryStack.ofItems(EndItems.getModBlocks().stream()
|
||||
List<EntryStack> anvils = Lists.newArrayList(EntryStack.ofItems(EndItems.getModBlocks().stream()
|
||||
.filter(item -> ((BlockItem) item).getBlock() instanceof EndAnvilBlock).collect(Collectors.toList())));
|
||||
ANVILS.add(0, EntryStack.create(Blocks.ANVIL));
|
||||
anvils.add(0, EntryStack.create(Blocks.ANVIL));
|
||||
ANVILS = anvils.toArray(new EntryStack[0]);
|
||||
FURNACES = Lists.newArrayList(EntryStack.ofItems(EndItems.getModBlocks().stream()
|
||||
.filter(item -> ((BlockItem) item).getBlock() instanceof EndFurnaceBlock).collect(Collectors.toList())))
|
||||
.toArray(new EntryStack[0]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue