Add Reactor Fuel To REI
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-08-03 13:50:13 -04:00
parent 2ca8870775
commit 2c6bed1868
9 changed files with 192 additions and 45 deletions

View File

@ -51,6 +51,20 @@ public class InfuserRegistry {
return map.getOrDefault(item, null); return map.getOrDefault(item, null);
} }
private static void addTransform(Item[] items, long cost, double successChance) {
for (Item item : items) {
InfuserAction[] success = new InfuserAction[items.length - 1];
int i = 0;
for (Item item2 : items) {
if (item != item2) {
success[i] = new InfuserAction.ItemAction(new ItemStack(item2, 8));
i++;
}
}
add(item, new InfuserEntry(cost, successChance, success, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ItemAction(Items.STRING)}));
}
}
static { static {
add(Items.SUGAR, new InfuserEntry(320, 0.4d, new InfuserAction[]{new InfuserAction.ItemAction(new ItemStack(Items.GLOWSTONE_DUST, 48))}, new InfuserAction[]{new InfuserAction.ItemAction(Items.SUGAR_CANE), new InfuserAction.ExplosionAction()})); add(Items.SUGAR, new InfuserEntry(320, 0.4d, new InfuserAction[]{new InfuserAction.ItemAction(new ItemStack(Items.GLOWSTONE_DUST, 48))}, new InfuserAction[]{new InfuserAction.ItemAction(Items.SUGAR_CANE), new InfuserAction.ExplosionAction()}));
@ -66,20 +80,6 @@ public class InfuserRegistry {
add(Items.IRON_NUGGET, new InfuserEntry(260, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_INGOT)}, new InfuserAction[]{new InfuserAction.ParticleAction()})); add(Items.IRON_NUGGET, new InfuserEntry(260, 0.3d, new InfuserAction[]{new InfuserAction.ItemAction(Items.IRON_INGOT)}, new InfuserAction[]{new InfuserAction.ParticleAction()}));
} }
private static void addTransform(Item[] items, long cost, double successChance) {
for (Item item : items) {
InfuserAction[] success = new InfuserAction[items.length - 1];
int i = 0;
for (Item item2 : items) {
if (item != item2) {
success[i] = new InfuserAction.ItemAction(new ItemStack(item2, 8));
i++;
}
}
add(item, new InfuserEntry(cost, successChance, success, new InfuserAction[]{new InfuserAction.ParticleAction(), new InfuserAction.ItemAction(Items.STRING)}));
}
}
private static Item[] getWool() { private static Item[] getWool() {
List<Item> wool = new ArrayList<>(); List<Item> wool = new ArrayList<>();
for (Item item : Registry.ITEM) { for (Item item : Registry.ITEM) {

View File

@ -1,6 +1,5 @@
package com.thebrokenrail.energonrelics.block.entity.reactor; package com.thebrokenrail.energonrelics.block.entity.reactor;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.battery.PassiveBatteryControllerBlock; import com.thebrokenrail.energonrelics.block.battery.PassiveBatteryControllerBlock;
import com.thebrokenrail.energonrelics.block.entity.battery.PassiveBatteryControllerBlockEntity; import com.thebrokenrail.energonrelics.block.entity.battery.PassiveBatteryControllerBlockEntity;
import com.thebrokenrail.energonrelics.block.reactor.ReactorControllerBlock; import com.thebrokenrail.energonrelics.block.reactor.ReactorControllerBlock;
@ -44,13 +43,7 @@ public class ReactorControllerBlockEntity extends EnergyGeneratorBlockEntity {
} }
for (int i = 0; i < input.size(); i++) { for (int i = 0; i < input.size(); i++) {
Item item = input.getStack(i).getItem(); Item item = input.getStack(i).getItem();
if (item == EnergonRelics.VERIDIUM_INGOT_ITEM) { fuelMultiplier = ReactorFuelRegistry.get(item);
fuelMultiplier = 1f;
} else if (item == EnergonRelics.VERIDIUM_BLOCK_BLOCK.asItem()) {
fuelMultiplier = 9f;
} else if (item == EnergonRelics.VERIDIUM_POWDER_ITEM) {
fuelMultiplier = 0.25f;
}
if (fuelMultiplier != 0f) { if (fuelMultiplier != 0f) {
input.removeStack(i, 1); input.removeStack(i, 1);
break; break;

View File

@ -0,0 +1,33 @@
package com.thebrokenrail.energonrelics.block.entity.reactor;
import com.thebrokenrail.energonrelics.EnergonRelics;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.Item;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class ReactorFuelRegistry {
private static final Map<Item, Float> map = new HashMap<>();
private static void add(Item item, float multiplier) {
map.put(item, multiplier);
}
public static float get(Item item) {
return map.getOrDefault(item, 0f);
}
@Environment(EnvType.CLIENT)
public static Set<Map.Entry<Item, Float>> entrySet() {
return map.entrySet();
}
static {
add(EnergonRelics.VERIDIUM_INGOT_ITEM, 1f);
add(EnergonRelics.VERIDIUM_BLOCK_BLOCK.asItem(), 9f);
add(EnergonRelics.VERIDIUM_POWDER_ITEM, 0.25f);
}
}

View File

@ -1,25 +1,19 @@
package com.thebrokenrail.energonrelics.client.rei; package com.thebrokenrail.energonrelics.client.rei;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.entity.infuser.InfuserEntry; import com.thebrokenrail.energonrelics.client.rei.infuser.InfuserCategory;
import com.thebrokenrail.energonrelics.block.entity.infuser.InfuserOutputItem; import com.thebrokenrail.energonrelics.client.rei.reactor.ReactorFuelCategory;
import com.thebrokenrail.energonrelics.block.entity.infuser.InfuserRegistry;
import com.thebrokenrail.energonrelics.util.BooleanIterator;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeHelper; import me.shedaniel.rei.api.RecipeHelper;
import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.api.plugins.REIPluginV0;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import java.util.List;
import java.util.Map;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class EnergonRelicsPlugin implements REIPluginV0 { public class EnergonRelicsPlugin implements REIPluginV0 {
public static final Identifier INFUSER = new Identifier(EnergonRelics.NAMESPACE, "plugin/infuser"); public static final Identifier INFUSER = new Identifier(EnergonRelics.NAMESPACE, "plugin/infuser");
public static final Identifier REACTOR_FUEL = new Identifier(EnergonRelics.NAMESPACE, "plugin/reactor_fuel");
@Override @Override
public Identifier getPluginIdentifier() { public Identifier getPluginIdentifier() {
@ -28,23 +22,18 @@ public class EnergonRelicsPlugin implements REIPluginV0 {
@Override @Override
public void registerOthers(RecipeHelper recipeHelper) { public void registerOthers(RecipeHelper recipeHelper) {
recipeHelper.registerWorkingStations(INFUSER, EntryStack.create(EnergonRelics.INFUSER_BLOCK.asItem())); recipeHelper.registerWorkingStations(INFUSER, EntryStack.create(EnergonRelics.INFUSER_BLOCK));
recipeHelper.registerWorkingStations(REACTOR_FUEL, EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK));
} }
@Override @Override
public void registerRecipeDisplays(RecipeHelper recipeHelper) { public void registerRecipeDisplays(RecipeHelper recipeHelper) {
for (Map.Entry<Item, InfuserEntry> entry : InfuserRegistry.entrySet()) { InfuserCategory.register(recipeHelper);
BooleanIterator.run(isFail -> { ReactorFuelCategory.register(recipeHelper);
List<InfuserOutputItem> list = entry.getValue().getOutputItems(isFail);
for (InfuserOutputItem item : list) {
recipeHelper.registerDisplay(new InfuserDisplay(new ItemStack(entry.getKey()), item, entry.getValue().getSingleChance(isFail), entry.getValue().cost));
}
});
}
} }
@Override @Override
public void registerPluginCategories(RecipeHelper recipeHelper) { public void registerPluginCategories(RecipeHelper recipeHelper) {
recipeHelper.registerCategories(new InfuserCategory()); recipeHelper.registerCategories(new InfuserCategory(), new ReactorFuelCategory());
} }
} }

View File

@ -1,16 +1,24 @@
package com.thebrokenrail.energonrelics.client.rei; package com.thebrokenrail.energonrelics.client.rei.infuser;
import com.thebrokenrail.energonrelics.EnergonRelics; import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.entity.infuser.InfuserEntry;
import com.thebrokenrail.energonrelics.block.entity.infuser.InfuserOutputItem;
import com.thebrokenrail.energonrelics.block.entity.infuser.InfuserRegistry;
import com.thebrokenrail.energonrelics.client.rei.EnergonRelicsPlugin;
import com.thebrokenrail.energonrelics.config.HardcodedConfig; import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.util.BooleanIterator;
import me.shedaniel.math.Point; import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeCategory; import me.shedaniel.rei.api.RecipeCategory;
import me.shedaniel.rei.api.RecipeHelper;
import me.shedaniel.rei.api.widgets.Widgets; import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget; import me.shedaniel.rei.gui.widget.Widget;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -19,6 +27,7 @@ import net.minecraft.util.registry.Registry;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class InfuserCategory implements RecipeCategory<InfuserDisplay> { public class InfuserCategory implements RecipeCategory<InfuserDisplay> {
@ -64,4 +73,15 @@ public class InfuserCategory implements RecipeCategory<InfuserDisplay> {
public String getCategoryName() { public String getCategoryName() {
return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".infuser.name"); return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".infuser.name");
} }
public static void register(RecipeHelper recipeHelper) {
for (Map.Entry<Item, InfuserEntry> entry : InfuserRegistry.entrySet()) {
BooleanIterator.run(isFail -> {
List<InfuserOutputItem> list = entry.getValue().getOutputItems(isFail);
for (InfuserOutputItem item : list) {
recipeHelper.registerDisplay(new InfuserDisplay(new ItemStack(entry.getKey()), item, entry.getValue().getSingleChance(isFail), entry.getValue().cost));
}
});
}
}
} }

View File

@ -1,6 +1,7 @@
package com.thebrokenrail.energonrelics.client.rei; package com.thebrokenrail.energonrelics.client.rei.infuser;
import com.thebrokenrail.energonrelics.block.entity.infuser.InfuserOutputItem; import com.thebrokenrail.energonrelics.block.entity.infuser.InfuserOutputItem;
import com.thebrokenrail.energonrelics.client.rei.EnergonRelicsPlugin;
import me.shedaniel.rei.api.EntryStack; import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeDisplay; import me.shedaniel.rei.api.RecipeDisplay;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;

View File

@ -0,0 +1,66 @@
package com.thebrokenrail.energonrelics.client.rei.reactor;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.entity.reactor.ReactorFuelRegistry;
import com.thebrokenrail.energonrelics.client.rei.EnergonRelicsPlugin;
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.RecipeHelper;
import me.shedaniel.rei.api.widgets.Widgets;
import me.shedaniel.rei.gui.widget.Widget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Environment(EnvType.CLIENT)
public class ReactorFuelCategory implements RecipeCategory<ReactorFuelDisplay> {
@Override
public List<Widget> setupDisplay(ReactorFuelDisplay display, Rectangle bounds) {
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
List<Widget> widgets = new ArrayList<>();
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createSlot(new Point(bounds.x + 9, startPoint.y + 5)).entries(display.getInputEntries().get(0)).markInput());
Text text = new TranslatableText("category.rei." + EnergonRelics.NAMESPACE + ".reactor_fuel.multiplier", String.valueOf(display.multiplier));
widgets.add(Widgets.createLabel(new Point(bounds.x + 29, startPoint.y + 8), text).noShadow().leftAligned().color(0xFF404040, 0xFFBBBBBB));
return widgets;
}
@Override
public int getDisplayHeight() {
return 36;
}
@Override
public Identifier getIdentifier() {
return EnergonRelicsPlugin.REACTOR_FUEL;
}
@Override
public EntryStack getLogo() {
return EntryStack.create(EnergonRelics.REACTOR_INPUT_BLOCK);
}
@Override
public String getCategoryName() {
return I18n.translate("category.rei." + EnergonRelics.NAMESPACE + ".reactor_fuel.name");
}
public static void register(RecipeHelper recipeHelper) {
for (Map.Entry<Item, Float> entry : ReactorFuelRegistry.entrySet()) {
recipeHelper.registerDisplay(new ReactorFuelDisplay(new ItemStack(entry.getKey()), entry.getValue()));
}
}
}

View File

@ -0,0 +1,43 @@
package com.thebrokenrail.energonrelics.client.rei.reactor;
import com.thebrokenrail.energonrelics.client.rei.EnergonRelicsPlugin;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.RecipeDisplay;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import java.util.Collections;
import java.util.List;
@Environment(EnvType.CLIENT)
public class ReactorFuelDisplay implements RecipeDisplay {
private final EntryStack input;
public final float multiplier;
public ReactorFuelDisplay(ItemStack input, float multiplier) {
this.input = EntryStack.create(input);
this.multiplier = multiplier;
}
@Override
public List<List<EntryStack>> getInputEntries() {
return Collections.singletonList(Collections.singletonList(input));
}
@Override
public List<EntryStack> getOutputEntries() {
return Collections.emptyList();
}
@Override
public Identifier getRecipeCategory() {
return EnergonRelicsPlugin.REACTOR_FUEL;
}
@Override
public List<List<EntryStack>> getRequiredEntries() {
return getInputEntries();
}
}

View File

@ -46,7 +46,7 @@
"block.energonrelics.industrial_laser": "Industrial Laser", "block.energonrelics.industrial_laser": "Industrial Laser",
"death.attack.energonrelics.industrial_laser": "%s was melted by an industrial laser", "death.attack.energonrelics.industrial_laser": "%s was melted by an industrial laser",
"death.attack.energonrelics.industrial_laser.player": "%s was melted by an industrial laser whilst fighting %s", "death.attack.energonrelics.industrial_laser.player": "%s was melted by an industrial laser whilst fighting %s",
"block.energonrelics.infuser": "Infuser", "block.energonrelics.infuser": "Infusing",
"text.energonrelics.infuser_progress": "Infusion Progress: %s%%", "text.energonrelics.infuser_progress": "Infusion Progress: %s%%",
"text.energonrelics.battery_core_tooltip": "%s Energon", "text.energonrelics.battery_core_tooltip": "%s Energon",
"text.energonrelics.multimeter_separator": ", ", "text.energonrelics.multimeter_separator": ", ",
@ -59,5 +59,7 @@
"block.energonrelics.energy_portal": "Energy Portal", "block.energonrelics.energy_portal": "Energy Portal",
"block.energonrelics.energized_obsidian": "Energized Obsidian", "block.energonrelics.energized_obsidian": "Energized Obsidian",
"category.rei.energonrelics.infuser.display_item.minecraft.tnt": "Explosion", "category.rei.energonrelics.infuser.display_item.minecraft.tnt": "Explosion",
"category.rei.energonrelics.infuser.display_item.minecraft.fire_charge": "Nothing" "category.rei.energonrelics.infuser.display_item.minecraft.fire_charge": "Nothing",
"category.rei.energonrelics.reactor_fuel.name": "Reactor Fuel",
"category.rei.energonrelics.reactor_fuel.multiplier": "%sx Reaction"
} }