mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 19:58:35 +01:00
parent
60dd405f5d
commit
035254227c
3 changed files with 15 additions and 6 deletions
|
@ -393,6 +393,7 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundNBT>, GraphL
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemsOnTheWay(BlockPos goalInv, ItemStack type, ItemEqualityType... equalityTypes) {
|
public int getItemsOnTheWay(BlockPos goalInv, ItemStack type, ItemEqualityType... equalityTypes) {
|
||||||
|
// TODO pending auto-crafting requests should be marked as "on the way" here to allow over-sending prevention
|
||||||
return this.getPipeItemsOnTheWay(goalInv)
|
return this.getPipeItemsOnTheWay(goalInv)
|
||||||
.filter(i -> type == null || ItemEqualityType.compareItems(i.stack, type, equalityTypes))
|
.filter(i -> type == null || ItemEqualityType.compareItems(i.stack, type, equalityTypes))
|
||||||
.mapToInt(i -> i.stack.getCount()).sum();
|
.mapToInt(i -> i.stack.getCount()).sum();
|
||||||
|
|
|
@ -191,9 +191,10 @@ public class PipeBlock extends ContainerBlock implements IPipeConnectable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onStateChanged(World world, BlockPos pos, BlockState newState) {
|
public static void onStateChanged(World world, BlockPos pos, BlockState newState) {
|
||||||
|
// wait a few ticks before checking if we have to drop our modules, so that things like iron -> gold chest work
|
||||||
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, world, pos);
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, world, pos);
|
||||||
if (tile != null && !tile.canHaveModules())
|
if (tile != null)
|
||||||
Utility.dropInventory(tile, tile.modules);
|
tile.moduleDropCheck = 5;
|
||||||
|
|
||||||
PipeNetwork network = PipeNetwork.get(world);
|
PipeNetwork network = PipeNetwork.get(world);
|
||||||
int connections = 0;
|
int connections = 0;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package de.ellpeck.prettypipes.pipe;
|
package de.ellpeck.prettypipes.pipe;
|
||||||
|
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.Registry;
|
import de.ellpeck.prettypipes.Registry;
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
|
@ -8,7 +7,6 @@ import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.network.PipeItem;
|
import de.ellpeck.prettypipes.network.PipeItem;
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.MainPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.MainPipeContainer;
|
||||||
import de.ellpeck.prettypipes.pressurizer.PressurizerBlock;
|
|
||||||
import de.ellpeck.prettypipes.pressurizer.PressurizerTileEntity;
|
import de.ellpeck.prettypipes.pressurizer.PressurizerTileEntity;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.ChestBlock;
|
import net.minecraft.block.ChestBlock;
|
||||||
|
@ -28,7 +26,6 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.common.util.Constants;
|
|
||||||
import net.minecraftforge.common.util.Constants.NBT;
|
import net.minecraftforge.common.util.Constants.NBT;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
@ -60,6 +57,7 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public PressurizerTileEntity pressurizer;
|
public PressurizerTileEntity pressurizer;
|
||||||
|
public int moduleDropCheck;
|
||||||
protected List<PipeItem> items;
|
protected List<PipeItem> items;
|
||||||
private int lastItemAmount;
|
private int lastItemAmount;
|
||||||
private int priority;
|
private int priority;
|
||||||
|
@ -75,12 +73,14 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT write(CompoundNBT compound) {
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
compound.put("modules", this.modules.serializeNBT());
|
compound.put("modules", this.modules.serializeNBT());
|
||||||
|
compound.putInt("module_drop_check", this.moduleDropCheck);
|
||||||
return super.write(compound);
|
return super.write(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(BlockState state, CompoundNBT compound) {
|
public void read(BlockState state, CompoundNBT compound) {
|
||||||
this.modules.deserializeNBT(compound.getCompound("modules"));
|
this.modules.deserializeNBT(compound.getCompound("modules"));
|
||||||
|
this.moduleDropCheck = compound.getInt("module_drop_check");
|
||||||
super.read(state, compound);
|
super.read(state, compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +111,13 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
||||||
IProfiler profiler = this.world.getProfiler();
|
IProfiler profiler = this.world.getProfiler();
|
||||||
|
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
|
// drop modules here to give a bit of time for blocks to update (iron -> gold chest etc.)
|
||||||
|
if (this.moduleDropCheck > 0) {
|
||||||
|
this.moduleDropCheck--;
|
||||||
|
if (this.moduleDropCheck <= 0 && !this.canHaveModules())
|
||||||
|
Utility.dropInventory(this, this.modules);
|
||||||
|
}
|
||||||
|
|
||||||
profiler.startSection("ticking_modules");
|
profiler.startSection("ticking_modules");
|
||||||
int prio = 0;
|
int prio = 0;
|
||||||
Iterator<Pair<ItemStack, IModule>> modules = this.streamModules().iterator();
|
Iterator<Pair<ItemStack, IModule>> modules = this.streamModules().iterator();
|
||||||
|
|
Loading…
Reference in a new issue