* basic setup for pump

* added proper outward scanner for blocks

* added changes from Spotless

* moved pump to tier2 package
increased energy storage
changed order of checks for lava/water

* added advanced_machine_frame to the recipe as is proper for tier 2

* decreased energy consumption
added config to iterate inwards by default

* fixed one-over block
removed extensive debug logging

* added display of depth and range to GUI
changed minimum range to 0 (pumps directly below)
extracted fluid detection and sound event logic into separate methods
removed delay in search for the next block to pump
added destruction of fully waterlogged blocks (kelp, stairs, fences etc), they drop their default item

* found incorrect reset when range/depth were changed. fixed
optimized check for pumping elapsed time
muffle upgrade now properly silences full tank and not-enough-energy cases
simplified checks for fluid (should work for any properly implemented types)
rewrote checks for failure conditions (failed for quad-overclock setup)

* added "exhausted" label to GUI
added i10n for GUI labels
removed sound sfx for not-enough-energy and tank-not-accepting-fluid failure events

* removed debug logging
updated textures with animation

* updated textures and animation

* grouped fields together and moved constructors and classes
rewrote sound selection + muffled pump now gives no sound at all

* changed replacement blocks for end and nether to endstone and blackstone
added pump block into the functional tab of creative menu

* added pump block into the functional tab of creative menu

* conflict resolved
This commit is contained in:
Maxim Varfolomeyev 2023-03-18 15:27:44 +03:00 committed by GitHub
parent 0b3eb68038
commit 9841d3332d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 655 additions and 1 deletions

View file

@ -68,6 +68,7 @@ import techreborn.blockentity.machine.tier1.SolidCanningMachineBlockEntity;
import techreborn.blockentity.machine.tier1.WireMillBlockEntity; import techreborn.blockentity.machine.tier1.WireMillBlockEntity;
import techreborn.blockentity.machine.tier2.FishingStationBlockEntity; import techreborn.blockentity.machine.tier2.FishingStationBlockEntity;
import techreborn.blockentity.machine.tier2.LaunchpadBlockEntity; import techreborn.blockentity.machine.tier2.LaunchpadBlockEntity;
import techreborn.blockentity.machine.tier2.PumpBlockEntity;
import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity; import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity; import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity;
import techreborn.blockentity.machine.tier3.MatterFabricatorBlockEntity; import techreborn.blockentity.machine.tier3.MatterFabricatorBlockEntity;
@ -118,6 +119,7 @@ import techreborn.client.gui.GuiMFSU;
import techreborn.client.gui.GuiMatterFabricator; import techreborn.client.gui.GuiMatterFabricator;
import techreborn.client.gui.GuiPlasmaGenerator; import techreborn.client.gui.GuiPlasmaGenerator;
import techreborn.client.gui.GuiPlayerDetector; import techreborn.client.gui.GuiPlayerDetector;
import techreborn.client.gui.GuiPump;
import techreborn.client.gui.GuiRecycler; import techreborn.client.gui.GuiRecycler;
import techreborn.client.gui.GuiRollingMachine; import techreborn.client.gui.GuiRollingMachine;
import techreborn.client.gui.GuiScrapboxinator; import techreborn.client.gui.GuiScrapboxinator;
@ -187,6 +189,7 @@ public class ClientGuiType<T extends BlockEntity> {
public static final ClientGuiType<LaunchpadBlockEntity> LAUNCHPAD = register(GuiType.LAUNCHPAD, GuiLaunchpad::new); public static final ClientGuiType<LaunchpadBlockEntity> LAUNCHPAD = register(GuiType.LAUNCHPAD, GuiLaunchpad::new);
public static final ClientGuiType<ElevatorBlockEntity> ELEVATOR = register(GuiType.ELEVATOR, GuiElevator::new); public static final ClientGuiType<ElevatorBlockEntity> ELEVATOR = register(GuiType.ELEVATOR, GuiElevator::new);
public static final ClientGuiType<FishingStationBlockEntity> FISHING_STATION = register(GuiType.FISHING_STATION, GuiFishingStation::new); public static final ClientGuiType<FishingStationBlockEntity> FISHING_STATION = register(GuiType.FISHING_STATION, GuiFishingStation::new);
public static final ClientGuiType<PumpBlockEntity> PUMP = register(GuiType.PUMP, GuiPump::new);
public static <T extends BlockEntity> ClientGuiType<T> register(GuiType<T> type, GuiFactory<T> factory) { public static <T extends BlockEntity> ClientGuiType<T> register(GuiType<T> type, GuiFactory<T> factory) {
return new ClientGuiType<>(type, factory); return new ClientGuiType<>(type, factory);

View file

@ -0,0 +1,100 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.client.gui;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import reborncore.client.ClientNetworkManager;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
import reborncore.common.screen.BuiltScreenHandler;
import techreborn.blockentity.machine.tier2.PumpBlockEntity;
import techreborn.packets.ServerboundPackets;
public class GuiPump extends GuiBase<BuiltScreenHandler> {
private final PumpBlockEntity blockEntity;
public GuiPump(int syncID, final PlayerEntity player, final PumpBlockEntity blockEntity) {
super(player, blockEntity, blockEntity.createScreenHandler(syncID, player));
this.blockEntity = blockEntity;
}
@Override
public void init() {
super.init();
addDrawableChild(new GuiButtonUpDown(x + 84, y + 30, this, b -> onClickDepth(10), GuiButtonUpDown.UpDownButtonType.FASTFORWARD));
addDrawableChild(new GuiButtonUpDown(x + 84 + 12, y + 30, this, b -> onClickDepth(1), GuiButtonUpDown.UpDownButtonType.FORWARD));
addDrawableChild(new GuiButtonUpDown(x + 84 + 24, y + 30, this, b -> onClickDepth(-1), GuiButtonUpDown.UpDownButtonType.REWIND));
addDrawableChild(new GuiButtonUpDown(x + 84 + 36, y + 30, this, b -> onClickDepth(-10), GuiButtonUpDown.UpDownButtonType.FASTREWIND));
addDrawableChild(new GuiButtonUpDown(x + 84, y + 55, this, b -> onClick(10), GuiButtonUpDown.UpDownButtonType.FASTFORWARD));
addDrawableChild(new GuiButtonUpDown(x + 84 + 12, y + 55, this, b -> onClick(1), GuiButtonUpDown.UpDownButtonType.FORWARD));
addDrawableChild(new GuiButtonUpDown(x + 84 + 24, y + 55, this, b -> onClick(-1), GuiButtonUpDown.UpDownButtonType.REWIND));
addDrawableChild(new GuiButtonUpDown(x + 84 + 36, y + 55, this, b -> onClick(-10), GuiButtonUpDown.UpDownButtonType.FASTREWIND));
}
private void onClickDepth(int amount) {
ClientNetworkManager.sendToServer(ServerboundPackets.createPacketPumpDepth(amount, blockEntity));
}
private void onClick(int amount) {
ClientNetworkManager.sendToServer(ServerboundPackets.createPacketPumpRange(amount, blockEntity));
}
@Override
protected void drawBackground(MatrixStack matrixStack, final float partialTicks, final int mouseX, final int mouseY) {
super.drawBackground(matrixStack, partialTicks, mouseX, mouseY);
final Layer layer = Layer.BACKGROUND;
if (hideGuiElements()) return;
drawSlot(matrixStack, 8, 72, layer); // Battery slot
drawText(matrixStack,
Text.translatable("gui.techreborn.pump.depth", Integer.toString(PumpBlockEntity.MIN_DEPTH), Integer.toString(PumpBlockEntity.MAX_DEPTH))
.append(Integer.toString(blockEntity.getDepth())),
80, 20, 0x404040, layer);
drawText(matrixStack,
Text.translatable("gui.techreborn.pump.range", Integer.toString(PumpBlockEntity.MIN_RANGE), Integer.toString(PumpBlockEntity.MAX_RANGE))
.append(Integer.toString(blockEntity.getRange())),
80, 45, 0x404040, layer);
if (blockEntity.getExhausted()) {
drawText(matrixStack, Text.translatable("gui.techreborn.pump.exhausted"), 80, 75, 0x800000, layer);
}
}
@Override
protected void drawForeground(MatrixStack matrixStack, final int mouseX, final int mouseY) {
super.drawForeground(matrixStack, mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
builder.drawTank(matrixStack, this, 33, 25, mouseX, mouseY, blockEntity.getTank().getFluidInstance(), blockEntity.getTank().getFluidValueCapacity(), blockEntity.getTank().isEmpty(), layer);
builder.drawMultiEnergyBar(matrixStack, this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxStoredPower(), mouseX, mouseY, 0, layer);
}
}

View file

@ -53,6 +53,7 @@ import techreborn.blockentity.generator.basic.SolidFuelGeneratorBlockEntity;
import techreborn.blockentity.machine.iron.IronAlloyFurnaceBlockEntity; import techreborn.blockentity.machine.iron.IronAlloyFurnaceBlockEntity;
import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity; import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity; import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
import techreborn.blockentity.machine.tier2.PumpBlockEntity;
import techreborn.blockentity.machine.multiblock.*; import techreborn.blockentity.machine.multiblock.*;
import techreborn.blockentity.machine.tier0.block.BlockBreakerBlockEntity; import techreborn.blockentity.machine.tier0.block.BlockBreakerBlockEntity;
import techreborn.blockentity.machine.tier0.block.BlockPlacerBlockEntity; import techreborn.blockentity.machine.tier0.block.BlockPlacerBlockEntity;
@ -127,6 +128,7 @@ public final class GuiType<T extends BlockEntity> implements IMachineGuiHandler
public static final GuiType<LaunchpadBlockEntity> LAUNCHPAD = register("launchpad"); public static final GuiType<LaunchpadBlockEntity> LAUNCHPAD = register("launchpad");
public static final GuiType<ElevatorBlockEntity> ELEVATOR = register("elevator"); public static final GuiType<ElevatorBlockEntity> ELEVATOR = register("elevator");
public static final GuiType<FishingStationBlockEntity> FISHING_STATION = register("fishing_station"); public static final GuiType<FishingStationBlockEntity> FISHING_STATION = register("fishing_station");
public static final GuiType<PumpBlockEntity> PUMP = register("pump");
private static <T extends BlockEntity> GuiType<T> register(String id) { private static <T extends BlockEntity> GuiType<T> register(String id) {
return register(new Identifier("techreborn", id)); return register(new Identifier("techreborn", id));

View file

@ -0,0 +1,358 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2022 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.blockentity.machine.tier2;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryKey;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.screen.BuiltScreenHandler;
import reborncore.common.screen.BuiltScreenHandlerProvider;
import reborncore.common.screen.builder.ScreenHandlerBuilder;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank;
import techreborn.blockentity.machine.GenericMachineBlockEntity;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import java.util.ArrayList;
import java.util.Iterator;
/**
* @author maxvar (coding), ashendi (textures)
*/
public class PumpBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
public static final FluidValue TANK_CAPACITY = FluidValue.BUCKET.multiply(16);
public static final int DEFAULT_RANGE = 10;
public static final int DEFAULT_DEPTH = 10;
public static final int MIN_RANGE = 0;
public static final int MIN_DEPTH = 1;
public static final int MAX_RANGE = 50;
public static final int MAX_DEPTH = 50;
private Iterator<BlockPos> finder;
protected final @NotNull Tank tank;
private boolean exhausted;
private BlockPos pumpedTargetBlockPos;
private long timeToPump;
private int range;
private int depth;
public PumpBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.PUMP, pos, state, "Pump", TechRebornConfig.pumpMaxInput, TechRebornConfig.pumpMaxEnergy, TRContent.Machine.PUMP.block, 0);
this.inventory = new RebornInventory<>(1, "PumpBlockEntity", 64, this);
this.tank = new Tank("PumpBlockEntity", TANK_CAPACITY, this);
this.exhausted = false;
this.range = DEFAULT_RANGE;
this.depth = DEFAULT_DEPTH;
}
public boolean getExhausted() {
return exhausted;
}
public void setExhausted(boolean exhausted) {
this.exhausted = exhausted;
}
public int getRange() {
return range;
}
public void setRange(int newRange) {
if (newRange < MIN_RANGE) newRange = MIN_RANGE;
if (newRange > MAX_RANGE) newRange = MAX_RANGE;
if (newRange != range) {
range = newRange;
reset();
}
}
public int getDepth() {
return depth;
}
public void setDepth(int newDepth) {
if (newDepth < MIN_DEPTH) newDepth = MIN_DEPTH;
if (newDepth > MAX_DEPTH) newDepth = MAX_DEPTH;
if (newDepth != depth) {
depth = newDepth;
reset();
}
}
private void reset() {
finder = null;
exhausted = false;
pumpedTargetBlockPos = null;
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
}
private void setupFinder() {
this.finder = new BlockPosIterable(pos, range, depth).iterator();
}
@Override
public @NotNull Tank getTank() {
return tank;
}
@Override
public ItemStack getToolDrop(PlayerEntity p0) {
return TRContent.Machine.PUMP.getStack();
}
@Override
public void readNbt(final NbtCompound tagCompound) {
super.readNbt(tagCompound);
tank.read(tagCompound);
this.range = tagCompound.getInt("range");
this.depth = tagCompound.getInt("depth");
finder = null;
}
@Override
public void writeNbt(final NbtCompound tagCompound) {
super.writeNbt(tagCompound);
tank.write(tagCompound);
tagCompound.putInt("range", range);
tagCompound.putInt("depth", depth);
}
@Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
return new ScreenHandlerBuilder("pump")
.player(player.getInventory()).inventory().hotbar().addInventory().blockEntity(this)
.energySlot(0, 8, 72)
.sync(tank)
.syncEnergyValue()
.sync(this::getDepth, this::setDepth)
.sync(this::getRange, this::setRange)
.sync(this::getExhausted, this::setExhausted)
.addInventory()
.create(this, syncID);
}
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) return;
//do nothing if all liquids have been exhausted
if (this.exhausted) return;
//has a target block to pump?
if (pumpedTargetBlockPos != null) {
//pumping time completed?
//has space to store?
//has enough energy to pump?
if ((world.getTime() >= timeToPump)) {
//not enough energy to pump?
if (getEnergy() < (long) (TechRebornConfig.pumpEnergyToCollect * getPowerMultiplier())) {
//don't drop target, retry it again later
timeToPump = world.getTime() + (long) (TechRebornConfig.pumpTicksToComplete * (1 - getSpeedMultiplier()));
return;
}
//recheck the target
BlockState blockState = world.getBlockState(pumpedTargetBlockPos);
Fluid fluid = getFluid(blockState);
//no longer fluid there?
if (fluid == Fluids.EMPTY) {
//play oops
if (!isMuffled()) {
world.playSound(null, this.pos, SoundEvents.BLOCK_DISPENSER_FAIL, SoundCategory.BLOCKS, 1.0f, 1.0f);
}
//drop target (and find the next)
pumpedTargetBlockPos = null;
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
return;
}
//cannot fit fluid into the tank?
if (!tank.canFit(fluid, FluidValue.BUCKET)) {
//don't drop target, retry it again later
timeToPump = world.getTime() + (long) (TechRebornConfig.pumpTicksToComplete * (1 - getSpeedMultiplier()));
return;
}
//fill tank
if (tank.getFluidInstance().isEmpty()) {
tank.setFluidInstance(new FluidInstance(fluid, FluidValue.BUCKET));
} else {
tank.getFluidInstance().addAmount(FluidValue.BUCKET);
}
//play sound
if (!isMuffled()) {
world.playSound(null, this.pos, tank.getFluid().getBucketFillSound().orElse(SoundEvents.ITEM_BUCKET_FILL), SoundCategory.BLOCKS, 1.0f, 1.0f);
}
//consume energy
this.useEnergy((long) (TechRebornConfig.pumpEnergyToCollect * getPowerMultiplier()));
//extract drops
DefaultedList<ItemStack> drops = getDrops(blockState);
if (!drops.isEmpty()) ItemScatterer.spawn(world, pumpedTargetBlockPos, drops);
//replace target with solid based on dimension
final Block replacementBlock;
final RegistryKey<World> worldRegistryKey = world.getRegistryKey();
if (worldRegistryKey == World.NETHER) replacementBlock = Blocks.BLACKSTONE;
else if (worldRegistryKey == World.END) replacementBlock = Blocks.END_STONE;
else replacementBlock = Blocks.COBBLESTONE;
world.setBlockState(pumpedTargetBlockPos, replacementBlock.getDefaultState());
pumpedTargetBlockPos = null;
}
} else if (!tank.isFull()) {
//find next target
findNextToPump(world);
if (pumpedTargetBlockPos != null) {
timeToPump = world.getTime() + (long) (TechRebornConfig.pumpTicksToComplete * (1 - getSpeedMultiplier()));
} else {
//else - consider exhausted
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
this.exhausted = true;
}
}
}
private void findNextToPump(World world) {
if (finder == null) {
setupFinder();
}
while (finder.hasNext()) {
BlockPos blockPos = finder.next();
BlockState blockState = world.getBlockState(blockPos);
Fluid fluid = getFluid(blockState);
if (fluid != Fluids.EMPTY && (fluid == tank.getFluid() || tank.getFluid() == Fluids.EMPTY)) {
//if any found - start pumping
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
pumpedTargetBlockPos = blockPos;
return;
}
}
}
@NotNull
private Fluid getFluid(BlockState blockState) {
FluidState fluidState = blockState.getFluidState();
Fluid fluid = fluidState.getFluid();
if (fluidState.getLevel() == 8) return fluid;
else return Fluids.EMPTY;
}
@NotNull
private DefaultedList<ItemStack> getDrops(BlockState blockState) {
Block block = blockState.getBlock();
Item item = block.asItem();
if (item == Items.AIR) {
return DefaultedList.ofSize(0);
} else {
ItemStack itemStack = item.getDefaultStack();
return DefaultedList.ofSize(1, itemStack);
}
}
public void handleDepthGuiInputFromClient(int buttonAmount) {
setDepth(depth + buttonAmount);
}
public void handleRangeGuiInputFromClient(int buttonAmount) {
setRange(range + buttonAmount);
}
static class BlockPosIterable implements Iterable<BlockPos> {
int index;
final int layerSize;
final int m;
final ArrayList<MeasuredPos> layer;
public BlockPosIterable(BlockPos centerTop, int range, int depth) {
this.index = 0;
this.layerSize = (range * 2 + 1) * (range * 2 + 1);
this.m = layerSize * depth;
layer = new ArrayList<>(layerSize);
for (int i = centerTop.getX() - range; i <= centerTop.getX() + range; i++)
for (int j = centerTop.getZ() - range; j <= centerTop.getZ() + range; j++)
layer.add(new MeasuredPos(i, centerTop.getY(), j, centerTop.getSquaredDistance(i, centerTop.getY(), j)));
layer.sort((o1, o2) -> (int) (o1.weight - o2.weight));
}
/**
* Returns an iterator over elements of type {@code T}.
*
* @return an Iterator.
*/
@NotNull
@Override
public Iterator<BlockPos> iterator() {
return new Iterator<>() {
@Override
public boolean hasNext() {
return index < m;
}
@Override
public BlockPos next() {
final BlockPos pos;
if (TechRebornConfig.pumpIterateOutwards) {
pos = layer.get(index % layerSize).down(1 + index / layerSize);
} else {
pos = layer.get((m - index - 1) % layerSize).down(1 + (m - index - 1) / layerSize);
}
index++;
return pos;
}
};
}
static class MeasuredPos extends BlockPos {
private final double weight;
public MeasuredPos(int x, int y, int z, double weight) {
super(x, y, z);
this.weight = weight;
}
}
}
}

View file

@ -645,6 +645,21 @@ public class TechRebornConfig {
@Config(config = "machines", category = "fishing_station", key = "FishingStationInterval", comment = "Fishing Station Catch Interval in Ticks > 0") @Config(config = "machines", category = "fishing_station", key = "FishingStationInterval", comment = "Fishing Station Catch Interval in Ticks > 0")
public static int fishingStationInterval = 400; // 20 seconds public static int fishingStationInterval = 400; // 20 seconds
@Config(config = "machines", category = "pump", key = "PumpTicksToComplete", comment = "How many ticks it takes to pump a source block.")
public static int pumpTicksToComplete = 100;
@Config(config = "machines", category = "pump", key = "PumpMaxInput", comment = "Pump Max Input (Energy per tick)")
public static int pumpMaxInput = 128;
@Config(config = "machines", category = "pump", key = "PumpMaxEnergy", comment = "Pump Max Energy")
public static int pumpMaxEnergy = 40_000;
@Config(config = "machines", category = "pump", key = "PumpEnergyToCollect", comment = "Base amount of Energy to collect a block of fluid")
public static int pumpEnergyToCollect = 1_000;
@Config(config = "machines", category = "pump", key = "PumpIterateOutwards", comment = "If true then the pump will collect closest fluid and scan outwards")
public static boolean pumpIterateOutwards = false;
// Misc // Misc
@Config(config = "misc", category = "general", key = "IC2TransformersStyle", comment = "Input from dots side, output from other sides, like in IC2.") @Config(config = "misc", category = "general", key = "IC2TransformersStyle", comment = "Input from dots side, output from other sides, like in IC2.")
public static boolean IC2TransformersStyle = true; public static boolean IC2TransformersStyle = true;

View file

@ -50,6 +50,7 @@ import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity;
import techreborn.blockentity.machine.misc.AlarmBlockEntity; import techreborn.blockentity.machine.misc.AlarmBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity; import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
import techreborn.blockentity.machine.misc.DrainBlockEntity; import techreborn.blockentity.machine.misc.DrainBlockEntity;
import techreborn.blockentity.machine.tier2.PumpBlockEntity;
import techreborn.blockentity.machine.multiblock.*; import techreborn.blockentity.machine.multiblock.*;
import techreborn.blockentity.machine.multiblock.casing.MachineCasingBlockEntity; import techreborn.blockentity.machine.multiblock.casing.MachineCasingBlockEntity;
import techreborn.blockentity.machine.tier0.block.BlockBreakerBlockEntity; import techreborn.blockentity.machine.tier0.block.BlockBreakerBlockEntity;
@ -149,6 +150,7 @@ public class TRBlockEntities {
public static final BlockEntityType<LaunchpadBlockEntity> LAUNCHPAD = register(LaunchpadBlockEntity::new, "launchpad", TRContent.Machine.LAUNCHPAD); public static final BlockEntityType<LaunchpadBlockEntity> LAUNCHPAD = register(LaunchpadBlockEntity::new, "launchpad", TRContent.Machine.LAUNCHPAD);
public static final BlockEntityType<ElevatorBlockEntity> ELEVATOR = register(ElevatorBlockEntity::new, "elevator", TRContent.Machine.ELEVATOR); public static final BlockEntityType<ElevatorBlockEntity> ELEVATOR = register(ElevatorBlockEntity::new, "elevator", TRContent.Machine.ELEVATOR);
public static final BlockEntityType<FishingStationBlockEntity> FISHING_STATION = register(FishingStationBlockEntity::new, "fishing_station", TRContent.Machine.FISHING_STATION); public static final BlockEntityType<FishingStationBlockEntity> FISHING_STATION = register(FishingStationBlockEntity::new, "fishing_station", TRContent.Machine.FISHING_STATION);
public static final BlockEntityType<PumpBlockEntity> PUMP = register(PumpBlockEntity::new, "pump", TRContent.Machine.PUMP);
public static <T extends BlockEntity> BlockEntityType<T> register(BiFunction<BlockPos, BlockState, T> supplier, String name, ItemConvertible... items) { public static <T extends BlockEntity> BlockEntityType<T> register(BiFunction<BlockPos, BlockState, T> supplier, String name, ItemConvertible... items) {
return register(supplier, name, Arrays.stream(items).map(itemConvertible -> Block.getBlockFromItem(itemConvertible.asItem())).toArray(Block[]::new)); return register(supplier, name, Arrays.stream(items).map(itemConvertible -> Block.getBlockFromItem(itemConvertible.asItem())).toArray(Block[]::new));

View file

@ -70,6 +70,7 @@ import techreborn.blockentity.generator.basic.WaterMillBlockEntity;
import techreborn.blockentity.generator.basic.WindMillBlockEntity; import techreborn.blockentity.generator.basic.WindMillBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity; import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
import techreborn.blockentity.machine.misc.DrainBlockEntity; import techreborn.blockentity.machine.misc.DrainBlockEntity;
import techreborn.blockentity.machine.tier2.PumpBlockEntity;
import techreborn.blockentity.machine.multiblock.DistillationTowerBlockEntity; import techreborn.blockentity.machine.multiblock.DistillationTowerBlockEntity;
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity; import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
import techreborn.blockentity.machine.multiblock.ImplosionCompressorBlockEntity; import techreborn.blockentity.machine.multiblock.ImplosionCompressorBlockEntity;
@ -839,7 +840,7 @@ public class TRContent {
WIND_MILL(new GenericGeneratorBlock(null, WindMillBlockEntity::new)), WIND_MILL(new GenericGeneratorBlock(null, WindMillBlockEntity::new)),
DRAIN(new GenericMachineBlock(null, DrainBlockEntity::new)), DRAIN(new GenericMachineBlock(null, DrainBlockEntity::new)),
PUMP(new GenericMachineBlock(GuiType.PUMP, PumpBlockEntity::new)),
ADJUSTABLE_SU(new AdjustableSUBlock()), ADJUSTABLE_SU(new AdjustableSUBlock()),
CHARGE_O_MAT(new GenericMachineBlock(GuiType.CHARGEBENCH, ChargeOMatBlockEntity::new)), CHARGE_O_MAT(new GenericMachineBlock(GuiType.CHARGEBENCH, ChargeOMatBlockEntity::new)),
INTERDIMENSIONAL_SU(new InterdimensionalSUBlock()), INTERDIMENSIONAL_SU(new InterdimensionalSUBlock()),

View file

@ -462,6 +462,7 @@ public class TRItemGroup {
TRContent.Machine.DISTILLATION_TOWER); TRContent.Machine.DISTILLATION_TOWER);
entries.addAfter(Items.CAULDRON, entries.addAfter(Items.CAULDRON,
TRContent.Machine.DRAIN, TRContent.Machine.DRAIN,
TRContent.Machine.PUMP,
TRContent.Machine.FLUID_REPLICATOR, TRContent.Machine.FLUID_REPLICATOR,
TRContent.Machine.FISHING_STATION); TRContent.Machine.FISHING_STATION);
entries.addAfter(Items.LODESTONE, TRContent.Machine.CHUNK_LOADER); entries.addAfter(Items.LODESTONE, TRContent.Machine.CHUNK_LOADER);

View file

@ -33,6 +33,7 @@ import reborncore.common.network.IdentifiedPacket;
import reborncore.common.network.NetworkManager; import reborncore.common.network.NetworkManager;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity; import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity;
import techreborn.blockentity.machine.tier2.PumpBlockEntity;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity; import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity; import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity;
import techreborn.blockentity.machine.tier1.ElevatorBlockEntity; import techreborn.blockentity.machine.tier1.ElevatorBlockEntity;
@ -58,6 +59,8 @@ public class ServerboundPackets {
public static final Identifier DETECTOR_RADIUS = new Identifier(TechReborn.MOD_ID, "detector_radius"); public static final Identifier DETECTOR_RADIUS = new Identifier(TechReborn.MOD_ID, "detector_radius");
public static final Identifier LAUNCH_SPEED = new Identifier(TechReborn.MOD_ID, "launch_speed"); public static final Identifier LAUNCH_SPEED = new Identifier(TechReborn.MOD_ID, "launch_speed");
public static final Identifier JUMP = new Identifier(TechReborn.MOD_ID, "jump"); public static final Identifier JUMP = new Identifier(TechReborn.MOD_ID, "jump");
public static final Identifier PUMP_DEPTH = new Identifier(TechReborn.MOD_ID, "pump_depth");
public static final Identifier PUMP_RANGE = new Identifier(TechReborn.MOD_ID, "pump_range");
public static void init() { public static void init() {
NetworkManager.registerServerBoundHandler(AESU, (server, player, handler, buf, responseSender) -> { NetworkManager.registerServerBoundHandler(AESU, (server, player, handler, buf, responseSender) -> {
@ -198,6 +201,31 @@ public class ServerboundPackets {
} }
}); });
}); });
NetworkManager.registerServerBoundHandler(PUMP_DEPTH, ((server, player, handler, buf, responseSender) -> {
BlockPos pos = buf.readBlockPos();
int buttonAmount = buf.readInt();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
if (blockEntity instanceof PumpBlockEntity) {
((PumpBlockEntity) blockEntity).handleDepthGuiInputFromClient(buttonAmount);
}
});
}));
NetworkManager.registerServerBoundHandler(PUMP_RANGE, ((server, player, handler, buf, responseSender) -> {
BlockPos pos = buf.readBlockPos();
int buttonAmount = buf.readInt();
server.execute(() -> {
BlockEntity blockEntity = player.world.getBlockEntity(pos);
if (blockEntity instanceof PumpBlockEntity) {
((PumpBlockEntity) blockEntity).handleRangeGuiInputFromClient(buttonAmount);
}
});
}));
} }
public static IdentifiedPacket createPacketAesu(int buttonID, boolean shift, boolean ctrl, AdjustableSUBlockEntity blockEntity) { public static IdentifiedPacket createPacketAesu(int buttonID, boolean shift, boolean ctrl, AdjustableSUBlockEntity blockEntity) {
@ -275,4 +303,18 @@ public class ServerboundPackets {
packetBuffer.writeBlockPos(pos); packetBuffer.writeBlockPos(pos);
}); });
} }
public static IdentifiedPacket createPacketPumpDepth(int buttonAmount, PumpBlockEntity blockEntity) {
return NetworkManager.createServerBoundPacket(PUMP_DEPTH, buf -> {
buf.writeBlockPos(blockEntity.getPos());
buf.writeInt(buttonAmount);
});
}
public static IdentifiedPacket createPacketPumpRange(int buttonAmount, PumpBlockEntity blockEntity) {
return NetworkManager.createServerBoundPacket(PUMP_RANGE, buf -> {
buf.writeBlockPos(blockEntity.getPos());
buf.writeInt(buttonAmount);
});
}
} }

View file

@ -0,0 +1,12 @@
{
"variants": {
"facing=north,active=false": { "model": "techreborn:block/machines/tier2_machines/pump" },
"facing=south,active=false": { "model": "techreborn:block/machines/tier2_machines/pump", "y": 180 },
"facing=west,active=false": { "model": "techreborn:block/machines/tier2_machines/pump", "y": 270 },
"facing=east,active=false": { "model": "techreborn:block/machines/tier2_machines/pump", "y": 90 },
"facing=north,active=true": { "model": "techreborn:block/machines/tier2_machines/pump_on" },
"facing=south,active=true": { "model": "techreborn:block/machines/tier2_machines/pump_on", "y": 180 },
"facing=west,active=true": { "model": "techreborn:block/machines/tier2_machines/pump_on", "y": 270 },
"facing=east,active=true": { "model": "techreborn:block/machines/tier2_machines/pump_on", "y": 90 }
}
}

View file

@ -1126,6 +1126,10 @@
"gui.techreborn.block.progress.stopped": "Idle (Stopped)", "gui.techreborn.block.progress.stopped": "Idle (Stopped)",
"gui.techreborn.block.progress.paused": "Idle (%s)", "gui.techreborn.block.progress.paused": "Idle (%s)",
"gui.techreborn.pump.depth": "Depth (%s..%s):",
"gui.techreborn.pump.range": "Range (%s..%s):",
"gui.techreborn.pump.exhausted": "Exhausted!",
"_comment28": "Villagers", "_comment28": "Villagers",
"entity.minecraft.villager.techreborn.metallurgist": "Metallurgist", "entity.minecraft.villager.techreborn.metallurgist": "Metallurgist",
"entity.minecraft.villager.metallurgist": "Metallurgist", "entity.minecraft.villager.metallurgist": "Metallurgist",

View file

@ -0,0 +1,11 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"top": "techreborn:block/machines/tier2_machines/pump_top",
"down": "techreborn:block/machines/tier2_machines/pump_bottom",
"east": "techreborn:block/machines/tier2_machines/pump_side",
"west": "techreborn:block/machines/tier2_machines/pump_side",
"front": "techreborn:block/machines/tier2_machines/pump_front",
"south": "techreborn:block/machines/tier2_machines/pump_front"
}
}

View file

@ -0,0 +1,11 @@
{
"parent": "minecraft:block/orientable",
"textures": {
"top": "techreborn:block/machines/tier2_machines/pump_top",
"down": "techreborn:block/machines/tier2_machines/pump_bottom",
"east": "techreborn:block/machines/tier2_machines/pump_side",
"west": "techreborn:block/machines/tier2_machines/pump_side",
"front": "techreborn:block/machines/tier2_machines/pump_front_on",
"south": "techreborn:block/machines/tier2_machines/pump_front_on"
}
}

View file

@ -0,0 +1,4 @@
{
"parent": "techreborn:block/machines/tier2_machines/pump"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

View file

@ -0,0 +1,6 @@
{
"animation": {
"frametime": 3,
"interpolate": true
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

View file

@ -0,0 +1,54 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"techreborn:crafting_table/machine/pump"
]
},
"criteria": {
"has_refined_iron_plate": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": ["techreborn:refined_iron_plate"]
}
]
}
},
"has_basic_tank_unit": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": ["techreborn:basic_tank_unit"]
}
]
}
},
"has_drain": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": ["techreborn:drain"]
}
]
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "techreborn:crafting_table/machine/pump"
}
}
},
"requirements": [
[
"has_refined_iron_plate",
"has_basic_tank_unit",
"has_drain",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,28 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"PFP",
"PTP",
"DXD"
],
"key": {
"F": {
"item": "techreborn:advanced_machine_frame"
},
"P": {
"item": "techreborn:refined_iron_plate"
},
"T": {
"item": "techreborn:basic_tank_unit"
},
"D": {
"item": "techreborn:drain"
},
"X": {
"item": "minecraft:iron_bars"
}
},
"result": {
"item": "techreborn:pump"
}
}