mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-22 23:39:22 +01:00
backport 27aa6809ae
This commit is contained in:
parent
43bf12924f
commit
cb98ef5be1
2 changed files with 16 additions and 8 deletions
|
@ -1,9 +1,6 @@
|
||||||
package de.ellpeck.prettypipes.pressurizer;
|
package de.ellpeck.prettypipes.pressurizer;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
|
||||||
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
|
||||||
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.block.BlockRenderType;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.ContainerBlock;
|
import net.minecraft.block.ContainerBlock;
|
||||||
|
@ -15,7 +12,6 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
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;
|
||||||
|
@ -28,6 +24,7 @@ import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PressurizerBlock extends ContainerBlock {
|
public class PressurizerBlock extends ContainerBlock {
|
||||||
|
|
||||||
public PressurizerBlock() {
|
public PressurizerBlock() {
|
||||||
super(Properties.create(Material.ROCK).hardnessAndResistance(3).sound(SoundType.STONE));
|
super(Properties.create(Material.ROCK).hardnessAndResistance(3).sound(SoundType.STONE));
|
||||||
}
|
}
|
||||||
|
@ -56,4 +53,17 @@ public class PressurizerBlock extends ContainerBlock {
|
||||||
public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
||||||
Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
|
Utility.addTooltip(this.getRegistryName().getPath(), tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasComparatorInputOverride(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getComparatorInputOverride(BlockState state, World world, BlockPos pos) {
|
||||||
|
PressurizerTileEntity pipe = Utility.getTileEntity(PressurizerTileEntity.class, world, pos);
|
||||||
|
if (pipe == null)
|
||||||
|
return 0;
|
||||||
|
return (int) (pipe.getEnergy() / (float) pipe.getMaxEnergy() * 15);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
||||||
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
@ -19,12 +18,10 @@ import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
import net.minecraft.util.Direction;
|
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.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
|
@ -136,9 +133,10 @@ public class PressurizerTileEntity extends TileEntity implements INamedContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send energy update
|
// send energy update and comparator output
|
||||||
if (this.lastEnergy != this.storage.getEnergyStored() && this.world.getGameTime() % 10 == 0) {
|
if (this.lastEnergy != this.storage.getEnergyStored() && this.world.getGameTime() % 10 == 0) {
|
||||||
this.lastEnergy = this.storage.getEnergyStored();
|
this.lastEnergy = this.storage.getEnergyStored();
|
||||||
|
this.world.updateComparatorOutputLevel(this.pos, this.getBlockState().getBlock());
|
||||||
Utility.sendTileEntityToClients(this);
|
Utility.sendTileEntityToClients(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue