mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-24 20:48:34 +01:00
Compare commits
2 commits
f8b618a1d2
...
bb221cb623
Author | SHA1 | Date | |
---|---|---|---|
bb221cb623 | |||
b2c69bc67b |
4 changed files with 27 additions and 3 deletions
|
@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
version = '1.9.4'
|
version = '1.9.5'
|
||||||
group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = 'PrettyPipes'
|
archivesBaseName = 'PrettyPipes'
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
@ -29,8 +31,10 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ItemTerminalBlock extends ContainerBlock {
|
public class ItemTerminalBlock extends ContainerBlock {
|
||||||
|
|
||||||
public ItemTerminalBlock() {
|
public ItemTerminalBlock() {
|
||||||
super(Properties.create(Material.ROCK).hardnessAndResistance(3).sound(SoundType.STONE));
|
super(Properties.create(Material.ROCK).hardnessAndResistance(3).sound(SoundType.STONE));
|
||||||
}
|
}
|
||||||
|
@ -38,8 +42,14 @@ public class ItemTerminalBlock extends ContainerBlock {
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult result) {
|
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult result) {
|
||||||
ItemTerminalTileEntity tile = Utility.getTileEntity(ItemTerminalTileEntity.class, worldIn, pos);
|
ItemTerminalTileEntity tile = Utility.getTileEntity(ItemTerminalTileEntity.class, worldIn, pos);
|
||||||
if (tile == null || tile.getConnectedPipe() == null)
|
if (tile == null)
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
|
String reason = tile.getInvalidTerminalReason();
|
||||||
|
if (reason != null) {
|
||||||
|
if (!worldIn.isRemote)
|
||||||
|
player.sendMessage(new TranslationTextComponent(reason).mergeStyle(TextFormatting.RED), UUID.randomUUID());
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
||||||
tile.updateItems(player);
|
tile.updateItems(player);
|
||||||
|
|
|
@ -112,6 +112,18 @@ public class ItemTerminalTileEntity extends TileEntity implements INamedContaine
|
||||||
this.lazyThis.invalidate();
|
this.lazyThis.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getInvalidTerminalReason() {
|
||||||
|
PipeNetwork network = PipeNetwork.get(this.world);
|
||||||
|
long pipes = Arrays.stream(Direction.values())
|
||||||
|
.map(d -> network.getPipe(this.pos.offset(d)))
|
||||||
|
.filter(Objects::nonNull).count();
|
||||||
|
if (pipes <= 0)
|
||||||
|
return "info." + PrettyPipes.ID + ".no_pipe_connected";
|
||||||
|
if (pipes > 1)
|
||||||
|
return "info." + PrettyPipes.ID + ".too_many_pipes_connected";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public PipeTileEntity getConnectedPipe() {
|
public PipeTileEntity getConnectedPipe() {
|
||||||
PipeNetwork network = PipeNetwork.get(this.world);
|
PipeNetwork network = PipeNetwork.get(this.world);
|
||||||
for (Direction dir : Direction.values()) {
|
for (Direction dir : Direction.values()) {
|
||||||
|
|
|
@ -85,5 +85,7 @@
|
||||||
"info.prettypipes.energy": "%s / %s FE",
|
"info.prettypipes.energy": "%s / %s FE",
|
||||||
"info.prettypipes.crafting": "Awaiting",
|
"info.prettypipes.crafting": "Awaiting",
|
||||||
"info.prettypipes.cancel_all": "Cancel",
|
"info.prettypipes.cancel_all": "Cancel",
|
||||||
"info.prettypipes.cancel_all.desc": "Stops waiting for current crafting outputs\nDoesn't remove inputs from blocks"
|
"info.prettypipes.cancel_all.desc": "Stops waiting for current crafting outputs\nDoesn't remove inputs from blocks",
|
||||||
|
"info.prettypipes.no_pipe_connected": "The terminal needs to be connected to a pipe network",
|
||||||
|
"info.prettypipes.too_many_pipes_connected": "The terminal can only be connected to a single pipe at a time"
|
||||||
}
|
}
|
Loading…
Reference in a new issue