mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-22 23:39:22 +01:00
added the redstone module
This commit is contained in:
parent
d8255ca07b
commit
16c7a67a13
11 changed files with 78 additions and 0 deletions
|
@ -5,6 +5,7 @@ import de.ellpeck.prettypipes.entities.PipeFrameRenderer;
|
|||
import de.ellpeck.prettypipes.items.*;
|
||||
import de.ellpeck.prettypipes.pipe.modules.FilterModifierModule;
|
||||
import de.ellpeck.prettypipes.pipe.modules.LowPriorityModuleItem;
|
||||
import de.ellpeck.prettypipes.pipe.modules.RedstoneModuleItem;
|
||||
import de.ellpeck.prettypipes.pipe.modules.SpeedModuleItem;
|
||||
import de.ellpeck.prettypipes.pipe.modules.extraction.ExtractionModuleContainer;
|
||||
import de.ellpeck.prettypipes.pipe.modules.extraction.ExtractionModuleGui;
|
||||
|
@ -107,6 +108,7 @@ public final class Registry {
|
|||
registry.registerAll(createTieredModule("retrieval_module", RetrievalModuleItem::new));
|
||||
registry.register(new StackSizeModuleItem("stack_size_module"));
|
||||
registry.registerAll(Arrays.stream(FilterModifierModule.Type.values()).map(t -> new FilterModifierModule(t.name().toLowerCase(Locale.ROOT) + "_filter_modifier", t)).toArray(Item[]::new));
|
||||
registry.register(new RedstoneModuleItem("redstone_module"));
|
||||
|
||||
ForgeRegistries.BLOCKS.getValues().stream()
|
||||
.filter(b -> b.getRegistryName().getNamespace().equals(PrettyPipes.ID))
|
||||
|
|
|
@ -26,4 +26,6 @@ public interface IModule {
|
|||
AbstractPipeContainer<?> getContainer(ItemStack module, PipeTileEntity tile, int windowId, PlayerInventory inv, PlayerEntity player, int moduleIndex);
|
||||
|
||||
float getItemSpeedIncrease(ItemStack module, PipeTileEntity tile);
|
||||
|
||||
boolean canPipeWork(ItemStack module, PipeTileEntity tile);
|
||||
}
|
||||
|
|
|
@ -71,4 +71,9 @@ public abstract class ModuleItem extends Item implements IModule {
|
|||
public float getItemSpeedIncrease(ItemStack module, PipeTileEntity tile) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeWork(ItemStack module, PipeTileEntity tile) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,8 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
}
|
||||
|
||||
public BlockPos getAvailableDestination(ItemStack stack, boolean internal, boolean preventOversending) {
|
||||
if (!this.canWork())
|
||||
return null;
|
||||
if (!internal && this.streamModules().anyMatch(m -> !m.getRight().canAcceptItem(m.getLeft(), this, stack)))
|
||||
return null;
|
||||
for (Direction dir : Direction.values()) {
|
||||
|
@ -179,6 +181,10 @@ public class PipeTileEntity extends TileEntity implements INamedContainerProvide
|
|||
return 0.05F + speed;
|
||||
}
|
||||
|
||||
public boolean canWork() {
|
||||
return this.streamModules().allMatch(m -> m.getRight().canPipeWork(m.getLeft(), this));
|
||||
}
|
||||
|
||||
public IItemHandler getItemHandler(Direction dir) {
|
||||
if (!this.isConnected(dir))
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules;
|
||||
|
||||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RedstoneModuleItem extends ModuleItem {
|
||||
|
||||
public RedstoneModuleItem(String name) {
|
||||
super(name);
|
||||
this.setRegistryName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeWork(ItemStack module, PipeTileEntity tile) {
|
||||
return !tile.getWorld().isBlockPowered(tile.getPos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatible(ItemStack module, PipeTileEntity tile, IModule other) {
|
||||
return other != this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainer(ItemStack module, PipeTileEntity tile) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -33,6 +33,8 @@ public class ExtractionModuleItem extends ModuleItem {
|
|||
public void tick(ItemStack module, PipeTileEntity tile) {
|
||||
if (tile.getWorld().getGameTime() % this.speed != 0)
|
||||
return;
|
||||
if(!tile.canWork())
|
||||
return;
|
||||
ItemFilter filter = new ItemFilter(this.filterSlots, module, tile);
|
||||
|
||||
PipeNetwork network = PipeNetwork.get(tile.getWorld());
|
||||
|
|
|
@ -38,6 +38,8 @@ public class RetrievalModuleItem extends ModuleItem {
|
|||
public void tick(ItemStack module, PipeTileEntity tile) {
|
||||
if (tile.getWorld().getGameTime() % this.speed != 0)
|
||||
return;
|
||||
if (!tile.canWork())
|
||||
return;
|
||||
PipeNetwork network = PipeNetwork.get(tile.getWorld());
|
||||
List<NetworkLocation> locations = null;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"item.prettypipes.damage_filter_modifier": "Damage Filter Modifier",
|
||||
"item.prettypipes.nbt_filter_modifier": "Data Filter Modifier",
|
||||
"item.prettypipes.tag_filter_modifier": "Tag Filter Modifier",
|
||||
"item.prettypipes.redstone_module": "Redstone Module",
|
||||
"info.prettypipes.extraction_module": "Pulls items from adjacent inventories\nFilters and pull rates vary by tier\nHigh tiers prevent over-sending",
|
||||
"info.prettypipes.filter_module": "Restricts flow from pipes into adjacent inventories\nFilter amount varies by tier",
|
||||
"info.prettypipes.speed_module": "Increases speed of items exiting adjacent inventories\nSpeed varies by tier",
|
||||
|
@ -31,6 +32,7 @@
|
|||
"info.prettypipes.damage_filter_modifier": "Causes any filter slots to filter by item damage",
|
||||
"info.prettypipes.nbt_filter_modifier": "Causes any filter slots to filter by item data (NBT)",
|
||||
"info.prettypipes.tag_filter_modifier": "Causes any filter slots to filter by tags\n(Modern equivalent of the Ore Dictionary)",
|
||||
"info.prettypipes.redstone_module": "Allows disabling the pipe with a redstone signal\nWorks for both extraction and retrieval",
|
||||
"block.prettypipes.pipe": "Pipe",
|
||||
"itemGroup.prettypipes": "Pretty Pipes",
|
||||
"container.prettypipes.pipe": "Pipe",
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "prettypipes:item/redstone_module"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 301 B |
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
" S ",
|
||||
"RMR",
|
||||
" R "
|
||||
],
|
||||
"key": {
|
||||
"R": {
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
"S": {
|
||||
"item": "minecraft:redstone_torch"
|
||||
},
|
||||
"M": {
|
||||
"item": "prettypipes:blank_module"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "prettypipes:redstone_module"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue