mining lens part 2.

This commit is contained in:
Flanks255 2022-08-31 12:07:18 -05:00
parent 7251e3390c
commit c6f226c2da
6 changed files with 38 additions and 71 deletions

View file

@ -47,6 +47,7 @@ public final class ActuallyAdditionsAPI {
public static final List<PressingRecipe> PRESSING_RECIPES = new ArrayList<>();
public static final List<FermentingRecipe> FERMENTING_RECIPES = new ArrayList<>();
public static final List<LaserRecipe> CONVERSION_LASER_RECIPES = new ArrayList<>();
public static final List<MiningLensRecipe> MINING_LENS_RECIPES = new ArrayList<>();
/**
* Farmer behaviors are sorted when first accessed, this will not be done until after loading, but do not add behaviors at runtime.
@ -59,7 +60,9 @@ public final class ActuallyAdditionsAPI {
public static final List<IBookletChapter> ALL_CHAPTERS = new ArrayList<>();
//This is added to automatically, you don't need to add anything to this list
public static final List<IBookletPage> BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList<>();
@Deprecated
public static final List<WeightedOre> STONE_ORES = new ArrayList<>();
@Deprecated
public static final List<WeightedOre> NETHERRACK_ORES = new ArrayList<>();
/**

View file

@ -2,11 +2,7 @@ package de.ellpeck.actuallyadditions.data;
import com.google.gson.JsonObject;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IFinishedRecipe;
@ -17,7 +13,6 @@ import net.minecraft.tags.ITag;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.Tags;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
import java.nio.file.Path;

View file

@ -24,13 +24,13 @@ public class MiningLensRecipe extends WeightedRandom.Item implements IRecipe<IIn
private final ResourceLocation id;
private final Ingredient input;
private final int weight;
//private final int weight;
private final ItemStack output;
public MiningLensRecipe(ResourceLocation id, Ingredient input, int weight, ItemStack output) {
super(weight);
this.input = input;
this.weight = weight;
//this.weight = weight;
this.output = output;
this.id = id;
}
@ -65,7 +65,7 @@ public class MiningLensRecipe extends WeightedRandom.Item implements IRecipe<IIn
@Override
public ItemStack getResultItem() {
return output.copy();
return output;
}
@Override

View file

@ -16,18 +16,25 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.recipe.WeightedOre;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.NetherrackBlock;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.Tags;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class LensMining extends Lens {
@Deprecated
public static void init() {
//These need to be moved to datagen conditionals if the appropriate mod is loaded.
@ -77,50 +84,36 @@ public class LensMining extends Lens {
if (tile.getEnergy() >= energyUse) {
int adaptedUse = energyUse;
List<WeightedOre> ores = null;
List<MiningLensRecipe> ores = new ArrayList<>();
Block hitBlock = hitState.getBlock();
if (hitBlock.is(Tags.Blocks.STONE)) { //TODO maybe?
ItemStack item = new ItemStack(hitBlock.asItem());
for(MiningLensRecipe r:ActuallyAdditionsAPI.MINING_LENS_RECIPES) {
if (r.matches(item))
ores.add(r);
}
/* if (hitBlock.is(Tags.Blocks.STONE)) { //TODO maybe?
ores = ActuallyAdditionsAPI.STONE_ORES;
} else if (hitBlock instanceof NetherrackBlock) {
ores = ActuallyAdditionsAPI.NETHERRACK_ORES;
adaptedUse += 10000;
}
adaptedUse += 10000; //TODO uh oh!?
}*/
if (ores != null) {
if (!ores.isEmpty()) {
int totalWeight = WeightedRandom.getTotalWeight(ores);
ItemStack stack = null;
MiningLensRecipe ore = WeightedRandom.getRandomItem(tile.getWorldObject().random, ores);
boolean found = false;
while (!found) {
WeightedOre ore = WeightedRandom.getRandomItem(tile.getWorldObject().random, ores, totalWeight);
/* if (ore != null) {
List<ItemStack> stacks = OreDictionary.getOres(ore.name, false);
if (stacks != null && !stacks.isEmpty()) {
for (ItemStack aStack : stacks) {
if (StackUtil.isValid(aStack) && !CrusherRecipeRegistry.hasBlacklistedOutput(aStack, ConfigStringListValues.MINING_LENS_BLACKLIST.getValue()) && aStack.getItem() instanceof ItemBlock) {
if (ConfigBoolValues.MINING_LENS_ADAPTED_USE.isEnabled()) {
adaptedUse += (totalWeight - ore.weight) % 40000;
}
stack = aStack;
found = true;
break;
}
}
}
}*/
}
if (tile.getEnergy() >= adaptedUse) {
Block block = Block.byItem(stack.getItem());
/* if (block != Blocks.AIR) {
BlockState state = block.getStateForPlacement(tile.getWorldObject(), hitPos, Direction.UP, 0, 0, 0, stack.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), Hand.MAIN_HAND);
tile.getWorldObject().setBlock(hitPos, state, 2);
tile.getWorldObject().levelEvent(2001, hitPos, Block.getId(state));
ItemStack stack = ore.getResultItem().copy();
if (stack.getItem() instanceof BlockItem) {
Block toPlace = Block.byItem(stack.getItem());
BlockState state2Place = toPlace.defaultBlockState();
tile.getWorldObject().setBlock(hitPos, state2Place, 2);
tile.getWorldObject().levelEvent(2001, hitPos, Block.getId(state2Place));
tile.extractEnergy(adaptedUse);
}*/
}
}
}

View file

@ -1,27 +0,0 @@
/*
* This file ("Lenses.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.items.lens;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
public final class Lenses {
public static void init() {
// ActuallyAdditionsAPI.lensDefaultConversion = new LensConversion();
// ActuallyAdditionsAPI.lensDetonation = new LensDetonation();
// ActuallyAdditionsAPI.lensDeath = new LensDeath();
// ActuallyAdditionsAPI.lensEvenMoarDeath = new LensKiller();
// ActuallyAdditionsAPI.lensColor = new LensColor();
// ActuallyAdditionsAPI.lensDisenchanting = new LensDisenchanting();
// ActuallyAdditionsAPI.lensMining = new LensMining();
}
}

View file

@ -41,5 +41,8 @@ public class ResourceReloader implements IResourceManagerReloadListener {
ActuallyAdditionsAPI.COLOR_CHANGE_RECIPES.clear();
ActuallyAdditionsAPI.COLOR_CHANGE_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.COLOR_CHANGE));
ActuallyAdditionsAPI.MINING_LENS_RECIPES.clear();
ActuallyAdditionsAPI.MINING_LENS_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.MINING_LENS));
}
}