Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
added printed pages and custom code to handle them
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Dec 3, 2023
1 parent 8db8762 commit 1768ddf
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
package muramasa.gregtech.blockentity.single;public class BlockEntityAssembler {
package muramasa.gregtech.blockentity.single;

import earth.terrarium.botarium.common.fluid.base.FluidContainer;
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.capability.machine.MachineRecipeHandler;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.recipe.IRecipe;
import muramasa.antimatter.recipe.ingredient.RecipeIngredient;
import muramasa.gregtech.caps.ParallelRecipeHandler;
import muramasa.gregtech.data.GregTechData;
import muramasa.gregtech.data.RecipeMaps;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.state.BlockState;
import tesseract.TesseractGraphWrappers;
import tesseract.api.item.ExtendedItemContainer;

import static muramasa.gregtech.data.Materials.Glue;

public class BlockEntityAssembler extends BlockEntityMachine<BlockEntityAssembler> {
public BlockEntityAssembler(Machine<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
recipeHandler.set(() -> new MachineRecipeHandler<>(this){
@Override
public IRecipe findRecipe() {
IRecipe recipe = super.findRecipe();
if (recipe == null){
ExtendedItemContainer container = itemHandler.get().getInputHandler();
ItemStack printedPages = ItemStack.EMPTY;
boolean leather = false;
for (int i = 0; i < container.getContainerSize(); i++) {
ItemStack stack = container.getItem(i);
if (stack.getItem() == GregTechData.PrintedPages && printedPages.isEmpty()){
printedPages = stack;
} else if (stack.getItem() == Items.LEATHER){
leather = true;
}
}
if (!printedPages.isEmpty() && leather){
FluidHolder glue = fluidHandler.map(f -> f.getFluidInTank(0)).orElse(FluidHooks.emptyFluid());
if (!glue.isEmpty() && glue.matches(Glue.getLiquid(20)) && glue.getFluidAmount() >= 20 * TesseractGraphWrappers.dropletMultiplier){
ItemStack output = new ItemStack(Items.WRITTEN_BOOK);
output.setTag(printedPages.copy().getTag());
return RecipeMaps.ASSEMBLING.RB().recipeMapOnly().ii(RecipeIngredient.of(printedPages.copy()), RecipeIngredient.of(Items.LEATHER)).fi(Glue.getLiquid(20)).io(output).add("written_book", 32, 8);
}
}
}
return recipe;
}

@Override
public boolean accepts(ItemStack stack) {
return super.accepts(stack) || stack.getItem() == GregTechData.PrintedPages;
}
});
//recipeHandler.set(() -> new ParallelRecipeHandler<>(this, true, 5));
}
}
2 changes: 2 additions & 0 deletions common/src/main/java/muramasa/gregtech/data/GregTechData.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import muramasa.gregtech.block.BlockCoil.CoilData;
import muramasa.gregtech.cover.*;
import muramasa.gregtech.cover.redstone.CoverRedstoneMachineController;
import muramasa.gregtech.items.ItemPrintedPages;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -100,6 +101,7 @@ public static void init(Side side) {
public static ItemFluidCell CellTungstensteel = new ItemFluidCell(GTIRef.ID, TungstenSteel, 64000);
public static ItemBasic<?> Scrap = new ItemBasic<>(GTIRef.ID, "scrap");
public static ItemBasic<?> WoodPellet = new ItemBasic<>(GTIRef.ID, "wood_pellet");
public static ItemBasic<?> PrintedPages = new ItemPrintedPages(GTIRef.ID, "printed_pages").tip("Used to make written Books");
public static ItemBasic<?> QuantumEye = new ItemBasic<>(GTIRef.ID, "quantum_eye").tip("Improved Ender Eye");
public static ItemBasic<?> QuantumStar = new ItemBasic<>(GTIRef.ID, "quantum_star").tip("Improved Nether Star");
public static ItemBasic<?> GraviStar = new ItemBasic<>(GTIRef.ID, "gravi_star").tip("Ultimate Nether Star");
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/muramasa/gregtech/data/Machines.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Machines {
public static BasicMachine ALLOY_SMELTER = new BasicMachine(GTIRef.ID, "alloy_smelter").setMap(ALLOY_SMELTING).addFlags(GUI, ITEM).setSound(GregTechSounds.FURNACE, 0.6f);
public static BasicMachine AMP_FABRICATOR = new BasicMachine(GTIRef.ID, "amp_fabricator").setMap(AMP_FABRICATING).addFlags(GUI, ITEM);
public static BasicMachine ARC_FURNACE = new BasicMachine(GTIRef.ID, "arc_furnace").setMap(ARC_SMELTING).addFlags(GUI, ITEM, FLUID).setSound(GregTechSounds.FURNACE, 0.6f).amps(3);
public static BasicMachine ASSEMBLER = new BasicMachine(GTIRef.ID, "assembler").setMap(ASSEMBLING).addFlags(GUI, ITEM, FLUID).setVerticalFacingAllowed(true).custom();
public static BasicMachine ASSEMBLER = new BasicMachine(GTIRef.ID, "assembler").setMap(ASSEMBLING).setTile(BlockEntityAssembler::new).addFlags(GUI, ITEM, FLUID).setVerticalFacingAllowed(true).custom();
public static BasicMachine AUTOCLAVE = new BasicMachine(GTIRef.ID, "autoclave").setMap(AUTOCLAVING).addFlags(GUI, ITEM, FLUID);
public static BasicMachine BENDER = new BasicMachine(GTIRef.ID, "bender").setMap(BENDING).addFlags(GUI, ITEM);
public static BasicMachine CANNER = new BasicMachine(GTIRef.ID, "canner").setMap(CANNING).addFlags(GUI, ITEM);
Expand Down
37 changes: 37 additions & 0 deletions common/src/main/java/muramasa/gregtech/items/ItemPrintedPages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package muramasa.gregtech.items;

import muramasa.antimatter.item.ItemBasic;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.StringUtil;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class ItemPrintedPages extends ItemBasic<ItemPrintedPages> {
public ItemPrintedPages(String domain, String id) {
super(domain, id);
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltipComponents, TooltipFlag isAdvanced) {
super.appendHoverText(stack, level, tooltipComponents, isAdvanced);
if (stack.hasTag()) {
CompoundTag compoundTag = stack.getTag();
String string = compoundTag.getString("title");
if (!StringUtil.isNullOrEmpty(string)) {
tooltipComponents.add(new TextComponent(string));
}
string = compoundTag.getString("author");
if (!StringUtil.isNullOrEmpty(string)) {
tooltipComponents.add((new TranslatableComponent("book.byAuthor", string)));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ private static void frames(){
}

private static void misc(){
ASSEMBLING.RB().ii(PrintedPages, Items.LEATHER).fi(Glue.getLiquid(20)).io(Items.WRITTEN_BOOK).fake().add("written_book", 32, 8);
ASSEMBLING.RB().ii(of(Machines.TRANSFORMER.getItem(ULV), 8), of(Machines.TRANSFORMER.getItem(LV), 4), of(Machines.TRANSFORMER.getItem(MV), 2),
of(Machines.TRANSFORMER.getItem(HV), 1), of(ComputerMonitor), of(TIER_CIRCUITS.apply(EV), 4)).io(Machines.ADJUSTABLE_TRANSFORMER.getItem(EV)).add("ev_adjustable_transformer", 50, 1920);
ASSEMBLING.RB().ii(of(Machines.TRANSFORMER.getItem(EV), 1), of(Machines.ADJUSTABLE_TRANSFORMER.getItem(EV), 2), of(ComputerMonitor), of(TIER_CIRCUITS.apply(IV), 4)).io(Machines.ADJUSTABLE_TRANSFORMER.getItem(IV)).add("iv_adjustable_transformer", 50, 1920);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1768ddf

Please sign in to comment.