This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added printed pages and custom code to handle them
- Loading branch information
Showing
7 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
61 changes: 60 additions & 1 deletion
61
common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityAssembler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
common/src/main/java/muramasa/gregtech/items/ItemPrintedPages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+338 Bytes
common/src/main/resources/assets/gti/textures/item/basic/data_stick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+436 Bytes
common/src/main/resources/assets/gti/textures/item/basic/printed_pages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.