Removed scrapboxlist usage. Closes #1407
This commit is contained in:
parent
a7d302115b
commit
4fc45221a2
5 changed files with 34 additions and 37 deletions
|
@ -37,7 +37,6 @@ import reborncore.api.recipe.RecipeHandler;
|
|||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.api.ScrapboxList;
|
||||
import techreborn.api.recipe.BaseRecipe;
|
||||
import techreborn.api.recipe.ScrapboxRecipe;
|
||||
import techreborn.compat.crafttweaker.CTGeneric.Remove;
|
||||
|
@ -50,13 +49,11 @@ public class CTScrapbox {
|
|||
|
||||
@ZenMethod
|
||||
public static void addScrapboxDrop(IIngredient input) {
|
||||
ScrapboxList.stacks.add(CraftTweakerMC.getItemStack(input));
|
||||
RecipeHandler.addRecipe(new ScrapboxRecipe(CraftTweakerMC.getItemStack(input)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
ScrapboxList.stacks.remove(CraftTweakerCompat.toStack(output));
|
||||
CraftTweakerAPI.apply(new Remove(CraftTweakerCompat.toStack(output), getMachineName()));
|
||||
}
|
||||
|
||||
|
@ -79,7 +76,6 @@ public class CTScrapbox {
|
|||
|
||||
@Override
|
||||
public void apply() {
|
||||
ScrapboxList.stacks.clear();
|
||||
for (IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(name)) {
|
||||
removedRecipes.add((BaseRecipe) recipeType);
|
||||
RecipeHandler.recipeList.remove(recipeType);
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
package techreborn.dispenser;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
|
@ -32,9 +35,11 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntityDispenser;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.recipe.IBaseRecipeType;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import techreborn.api.ScrapboxList;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
|
@ -46,11 +51,9 @@ public class BehaviorDispenseScrapbox extends BehaviorDefaultDispenseItem {
|
|||
@Override
|
||||
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
|
||||
if (dispenseScrapboxes) {
|
||||
int random = source.getWorld().rand.nextInt(ScrapboxList.stacks.size());
|
||||
ItemStack out = ScrapboxList.stacks.get(random).copy();
|
||||
/* float xOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;
|
||||
float yOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;
|
||||
float zOffset = source.getWorld().rand.nextFloat() * 0.8F + 0.1F;*/
|
||||
List<IBaseRecipeType> scrapboxRecipeList = RecipeHandler.getRecipeClassFromName(Reference.scrapboxRecipe);
|
||||
int random = new Random().nextInt(scrapboxRecipeList.size());
|
||||
ItemStack out = scrapboxRecipeList.get(random).getOutput(0);
|
||||
stack.splitStack(1);
|
||||
|
||||
TileEntityDispenser tile = source.getBlockTileEntity();
|
||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraft.init.Items;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import techreborn.api.ScrapboxList;
|
||||
import techreborn.api.recipe.ScrapboxRecipe;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
|
@ -215,17 +214,13 @@ public class ScrapboxRecipes extends RecipeMethods {
|
|||
registerDyable(Blocks.STAINED_GLASS);
|
||||
registerDyable(Blocks.STAINED_GLASS_PANE);
|
||||
registerDyable(Blocks.STAINED_HARDENED_CLAY);
|
||||
|
||||
for (int i = 0; i < ScrapboxList.stacks.size(); i++) {
|
||||
RecipeHandler.addRecipe(new ScrapboxRecipe(ScrapboxList.stacks.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
static void register(ItemStack stack) {
|
||||
if(stack == null || stack.isEmpty()){
|
||||
static void register(ItemStack output) {
|
||||
if(output == null || output.isEmpty()){
|
||||
return;
|
||||
}
|
||||
ScrapboxList.stacks.add(stack);
|
||||
RecipeHandler.addRecipe(new ScrapboxRecipe(output));
|
||||
}
|
||||
|
||||
static void registerDyable(Item item) {
|
||||
|
|
|
@ -24,14 +24,18 @@
|
|||
|
||||
package techreborn.items;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.api.ScrapboxList;
|
||||
import reborncore.api.recipe.IBaseRecipeType;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
|
||||
public class ItemScrapBox extends ItemTR {
|
||||
|
@ -42,20 +46,13 @@ public class ItemScrapBox extends ItemTR {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player,
|
||||
EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!world.isRemote) {
|
||||
int random = world.rand.nextInt(ScrapboxList.stacks.size());
|
||||
ItemStack out = ScrapboxList.stacks.get(random).copy();
|
||||
float xOffset = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float yOffset = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
float zOffset = world.rand.nextFloat() * 0.8F + 0.1F;
|
||||
EntityItem entityitem = new EntityItem(world, player.getPosition().getX() + xOffset,
|
||||
player.getPosition().getY() + yOffset, player.getPosition().getZ() + zOffset, out);
|
||||
|
||||
entityitem.setPickupDelay(20);
|
||||
world.spawnEntity(entityitem);
|
||||
List<IBaseRecipeType> scrapboxRecipeList = RecipeHandler.getRecipeClassFromName(Reference.scrapboxRecipe);
|
||||
int random = world.rand.nextInt(scrapboxRecipeList.size());
|
||||
ItemStack out = scrapboxRecipeList.get(random).getOutput(0);
|
||||
WorldUtils.dropItem(out, world, player.getPosition());
|
||||
stack.shrink(1);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||
|
|
|
@ -24,18 +24,22 @@
|
|||
|
||||
package techreborn.tiles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IBaseRecipeType;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.api.ScrapboxList;
|
||||
import techreborn.api.Reference;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
|
@ -107,8 +111,9 @@ public class TileScrapboxinator extends TilePowerAcceptor
|
|||
|
||||
public void recycleItems() {
|
||||
if (this.canOpen() && !this.world.isRemote) {
|
||||
int random = world.rand.nextInt(ScrapboxList.stacks.size());
|
||||
ItemStack out = ScrapboxList.stacks.get(random).copy();
|
||||
List<IBaseRecipeType> scrapboxRecipeList = RecipeHandler.getRecipeClassFromName(Reference.scrapboxRecipe);
|
||||
int random = world.rand.nextInt(scrapboxRecipeList.size());
|
||||
ItemStack out = scrapboxRecipeList.get(random).getOutput(0);
|
||||
if (this.getStackInSlot(this.output).isEmpty()) {
|
||||
this.useEnergy(cost);
|
||||
this.setInventorySlotContents(this.output, out);
|
||||
|
@ -125,8 +130,9 @@ public class TileScrapboxinator extends TilePowerAcceptor
|
|||
}
|
||||
|
||||
public boolean canOpen() {
|
||||
List<IBaseRecipeType> scrapboxRecipeList = RecipeHandler.getRecipeClassFromName(Reference.scrapboxRecipe);
|
||||
return !this.getStackInSlot(this.input1).isEmpty() && this.getStackInSlot(this.output).isEmpty()
|
||||
&& ScrapboxList.stacks.size() > 0;
|
||||
&& scrapboxRecipeList.size() > 0;
|
||||
}
|
||||
|
||||
public boolean isBurning() {
|
||||
|
|
Loading…
Add table
Reference in a new issue