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

Commit

Permalink
more work on prospection stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Dec 3, 2023
1 parent 36213a2 commit da107b7
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package muramasa.gregtech.blockentity.single;

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.data.GregTechData;
import muramasa.gregtech.data.RecipeMaps;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
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 BlockEntityScanner extends BlockEntityMachine<BlockEntityScanner> {
public BlockEntityScanner(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 dataStick = ItemStack.EMPTY;
for (int i = 0; i < container.getContainerSize(); i++) {
ItemStack stack = container.getItem(i);
if (stack.getItem() == GregTechData.DataStick && dataStick.isEmpty()){
dataStick = stack.copy();
}
}
if (!dataStick.isEmpty()){
CompoundTag prospect = dataStick.getTagElement("prospectData");
if (prospect != null){
ItemStack output = dataStick.copy();
output.getTagElement("prospectData").putBoolean("analyzed", true);
return RecipeMaps.SCANNING.RB().recipeMapOnly().ii(RecipeIngredient.of(dataStick.copy())).io(output).add("data_stick_prospection", 1000, 32);
}
}
}
return recipe;
}

@Override
public boolean accepts(ItemStack stack) {
return super.accepts(stack) || stack.getItem() == GregTechData.DataStick;
}
});
//recipeHandler.set(() -> new ParallelRecipeHandler<>(this, true, 5));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
public class BlockEntitySeismicProspector extends BlockEntityMachine<BlockEntitySeismicProspector> {
int progress, maxProgress;
OilSpoutEntry entry = null;
ChunkPos pos;
List<Material> ores;
public BlockEntitySeismicProspector(Machine<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
Expand All @@ -47,7 +46,7 @@ public InteractionResult onInteractServer(BlockState state, Level world, BlockPo
}
if (stack.getItem() == GregTechData.DataStick && entry != null){
CompoundTag prospectData = stack.getOrCreateTagElement("prospectData");
prospectData.putLong("chunkPos", pos.asLong());
prospectData.putLong("pos", pos.asLong());
prospectData.putString("dimension", level.dimension().location().toString());
if (entry.getFluid() != null){
CompoundTag fluid = new CompoundTag();
Expand Down Expand Up @@ -79,9 +78,9 @@ public void serverTick(Level level, BlockPos pos, BlockState state) {
} else {
progress = maxProgress = 0;
setMachineState(MachineState.IDLE);
this.pos = level.getChunk(pos).getPos();
this.entry = OilSpoutSavedData.getOrCreate((ServerLevel) level).getFluidVeinWorldEntry(this.pos.x, this.pos.z);
this.ores = VeinSavedData.getOrCreate((ServerLevel) level).geOresInChunk(this.pos.x, this.pos.z);
ChunkPos pos1 = level.getChunk(pos).getPos();
this.entry = OilSpoutSavedData.getOrCreate((ServerLevel) level).getFluidVeinWorldEntry(pos1.x, pos1.z);
this.ores = VeinSavedData.getOrCreate((ServerLevel) level).geOresInChunk(pos1.x, pos1.z);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void init(Side side) {
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<?> DataStick = new ItemDataStick(GTIRef.ID, "data_stick");
public static ItemBasic<?> DataStick = new ItemDataStick(GTIRef.ID, "data_stick").tip("A Low Capacity Data Storage");
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 @@ -98,7 +98,7 @@ public class Machines {
public static BasicMachine ROASTER = new BasicMachine(GTIRef.ID, "roaster").setMap(ROASTING).addFlags(GUI, ITEM, FLUID).amps(3);
public static BasicMachine RECYCLER = new BasicMachine(GTIRef.ID, "recycler").setMap(RECYCLING).addFlags(GUI, ITEM, FLUID);
public static BasicMachine REPLICATOR = new BasicMachine(GTIRef.ID, "replicator").setMap(REPLICATING).addFlags(GUI, ITEM, FLUID);
public static BasicMachine SCANNER = new BasicMachine(GTIRef.ID, "scanner").setMap(SCANNING).addFlags(GUI, ITEM, FLUID).setSound(GregTechSounds.MAGNETIZER, 0.6f);
public static BasicMachine SCANNER = new BasicMachine(GTIRef.ID, "scanner").setMap(SCANNING).addFlags(GUI, ITEM, FLUID).setTile(BlockEntityScanner::new).setSound(GregTechSounds.MAGNETIZER, 0.6f);
public static BasicMachine SEISMIC_PROSPECTOR = new BasicMachine(GTIRef.ID, "seismic_prospector").setTiers(LV, EV).setTile(BlockEntitySeismicProspector::new);
public static BasicMachine SIFTER = new BasicMachine(GTIRef.ID, "sifter").setMap(SIFTING).addFlags(GUI, ITEM);
public static BasicMachine THERMAL_CENTRIFUGE = new BasicMachine(GTIRef.ID, "thermal_centrifuge").setMap(THERMAL_CENTRIFUGING).addFlags(GUI,ITEM).amps(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ protected void addTranslations() {
add("tooltip.gti.blacklist", "Blacklist");
add("tooltip.gti.nbt.on", "Don't ignore nbt");
add("tooltip.gti.nbt.off", "Ignore nbt");
add("tooltip.gti.data_stick.raw_prospection_data", "Raw Prospection Data");
add("tooltip.gti.data_stick.analyzed_prospection_data", "Analyzed Prospection Data");
add("tooltip.gti.data_stick.by", "By X: %s Z: %s Dim: %s");
}

@Override
Expand Down
28 changes: 28 additions & 0 deletions common/src/main/java/muramasa/gregtech/items/ItemDataStick.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
package muramasa.gregtech.items;

import muramasa.antimatter.item.ItemBasic;
import muramasa.antimatter.util.Utils;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
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 ItemDataStick extends ItemBasic<ItemDataStick> {
public ItemDataStick(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);
CompoundTag nbt = stack.getTag();
if (nbt != null){
if (nbt.contains("prospectData")){
CompoundTag prospect = nbt.getCompound("prospectData");
String raw = prospect.contains("analyzed") ? "analyzed" : "raw";
tooltipComponents.add(Utils.translatable("tooltip.gti.data_stick." + raw + "_prospection_data"));
if (prospect.contains("analyzed")){
BlockPos pos = BlockPos.of(prospect.getLong("pos"));
String dimension = prospect.getString("dimension");
tooltipComponents.add(Utils.translatable("tooltip.gti.data_stick.by", pos.getX(), pos.getZ(), dimension));
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package muramasa.gregtech.items;

import muramasa.antimatter.item.ItemBasic;
import muramasa.antimatter.util.Utils;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand All @@ -26,11 +27,11 @@ public void appendHoverText(ItemStack stack, @Nullable Level level, List<Compone
CompoundTag compoundTag = stack.getTag();
String string = compoundTag.getString("title");
if (!StringUtil.isNullOrEmpty(string)) {
tooltipComponents.add(new TextComponent(string));
tooltipComponents.add(Utils.literal(string));
}
string = compoundTag.getString("author");
if (!StringUtil.isNullOrEmpty(string)) {
tooltipComponents.add((new TranslatableComponent("book.byAuthor", string)));
tooltipComponents.add((Utils.translatable("book.byAuthor", string)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package muramasa.gregtech.loader.machines;

import muramasa.gregtech.data.RecipeMaps;

public class ScannerLoader {
public static void init(){
//RecipeMaps.SCANNING.RB().
}
}

0 comments on commit da107b7

Please sign in to comment.