Skip to content

Commit 057b9c0

Browse files
committed
Add pump model and improved visuals
1 parent 61741cf commit 057b9c0

File tree

19 files changed

+377
-40
lines changed

19 files changed

+377
-40
lines changed

src/main/generated/.cache/19c08d24c255c2719fbb8ac01f9dff290b763461

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
// 1.20.4 2024-04-09T18:04:21.9188741 Oritech/Model Definitions
1+
// 1.20.4 2024-04-09T20:01:08.562303 Oritech/Model Definitions
22
b4b5bb16cd9934be2399058ea8772b23ac699345 assets\oritech\models\item\exo_chestplate.json
3-
0ea8315aed10abcf90ec950fee0062aed26075cb assets\oritech\models\item\energy_pipe.json
43
8ede0997449fd1c3f65a07df184768a843b473ed assets\oritech\models\item\centrifuge_block.json
4+
0ea8315aed10abcf90ec950fee0062aed26075cb assets\oritech\models\item\energy_pipe.json
55
90e28b721796ff7ee21c8eefe4525f03a251d2fb assets\oritech\models\block\machine_extender.json
6-
b783791f300e3eaafeea4ee5c9409080e000fd47 assets\oritech\models\item\giga_storage_block.json
76
3fcaea2f05319816f7904137763182c4106c91a9 assets\oritech\blockstates\destroyer_block.json
87
e6f197ee5ac22cd68bc502a86d40b65bfe40884a assets\oritech\models\item\target_designator.json
9-
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\centrifuge_block.json
108
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\lava_generator_block.json
9+
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\centrifuge_block.json
1110
8ef5ff056a3d2fa26393ec9ccb4b6f3b410f8be8 assets\oritech\models\item\item_pipe.json
12-
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\fragment_forge_block.json
1311
b91305cbccecb97f9d74e2b92787ae9fa6387786 assets\oritech\blockstates\fluid_pipe.json
14-
cf4f804b64f5b0eda2f74519b2c79da4c8aff2d9 assets\oritech\blockstates\giga_storage_block.json
12+
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\fragment_forge_block.json
1513
98d62a615b70fca694eb00c6b8aa9297c4a92b62 assets\oritech\blockstates\energy_pipe_connection.json
1614
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\big_solar_panel_block.json
15+
ff8c539de2afd50edaef11008239ffb8e08c66de assets\oritech\models\block\pump_trunk_block.json
1716
3e5d7c884b038c90ab274adde5d4c3657b3895ae assets\oritech\models\item\exo_boots.json
1817
3ceff0ef4325bb269831205626285bc857c60de8 assets\oritech\models\item\destroyer_block.json
1918
829faf2dfb04c9aea2dd6c971037fbfdaa9aa389 assets\oritech\models\item\pump_block.json
@@ -23,15 +22,15 @@ e4497bad8afbd4f4b4e830d892284a05718b06dd assets\oritech\models\block\machine_cor
2322
505d30e3b61ee0ba1f2616e1226689e2cdb7ab58 assets\oritech\models\block\addon_indicator_block.json
2423
a5651b8d4a27308b40c404f7cd3abcf9769b64b6 assets\oritech\models\item\machine_core_basic.json
2524
fb03aa413ddd02d32aca58d75003db4dbc224080 assets\oritech\models\item\exo_leggings.json
26-
c3174dc9e04055bae724425eb8b2c2894297bf70 assets\oritech\blockstates\pump_block.json
25+
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\pump_block.json
2726
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\basic_generator_block.json
2827
2f7dfa17792770a034a13f117e6b8b1942b459e4 assets\oritech\models\block\placer_block.json
2928
ee822d455f99c8c53c789fdb744979f678ca2729 assets\oritech\blockstates\fertilizer_block.json
3029
46af77abe62b29d232feadccde429fd59d5603fc assets\oritech\blockstates\placer_block.json
3130
3d37038977380bd685f913e722cc3b1c3a25c35d assets\oritech\models\item\atomic_forge_block.json
3231
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\test_generator_block.json
33-
b5ee97616ae0d2da17dfaecf45aa42f2cf19f691 assets\oritech\blockstates\machine_extender.json
3432
eafe84c787830ab2a866e0878e9ed718d58659f5 assets\oritech\blockstates\banana_block.json
33+
b5ee97616ae0d2da17dfaecf45aa42f2cf19f691 assets\oritech\blockstates\machine_extender.json
3534
25864df3cd7786f2bf4fe6fa9855b3cf366c28ca assets\oritech\models\item\banana.json
3635
1fdbeb99862a58436d745edb768b503539ecb295 assets\oritech\models\item\placer_block.json
3736
58b38bcc6c404953490330d4cc797464b6874d88 assets\oritech\models\item\test_generator_block.json
@@ -50,15 +49,15 @@ c0a08ce14172e22abd9f55d82686f7e96e74834a assets\oritech\blockstates\large_storag
5049
ff59e92a557b29eeb7f85b1c15ef206c5b99aff6 assets\oritech\models\item\foundry_block.json
5150
907e1d1717c926ebc0455ebe3291c7e917eb74d2 assets\oritech\models\item\basic_generator_block.json
5251
c641d411ad252487b93d779cee9028b9ee920281 assets\oritech\blockstates\machine_core_basic.json
52+
78f4a2e5abfbdcb3a8cd6f797ad3aa776614617d assets\oritech\blockstates\pump_trunk_block.json
5353
70cd17a84bf2d31647992ee3d21766ca5ea23151 assets\oritech\models\item\fragment_forge_block.json
5454
a5afa0ba8780ec08bd0a9284bc08e0c681fe7158 assets\oritech\blockstates\block_placer_head.json
5555
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\assembler_block.json
5656
5054284e6d5fe0785ac93bdda5101c47337953cf assets\oritech\models\item\machine_frame_block.json
5757
7b3ae67ec28f9b36b96539cd48b92096861d0853 assets\oritech\models\item\oil_bucket.json
58-
56c7ceb5cc86d67913ad95cb4ae5ec192aed926f assets\oritech\models\block\pump_block.json
5958
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\powered_furnace_block.json
60-
1b9cd3719105dc1e03398de41f2cab37337816fe assets\oritech\blockstates\machine_core_good.json
6159
ccd7e87c2ba5a5062bb88aa6e103d49d47cd56ff assets\oritech\blockstates\energy_pipe.json
60+
1b9cd3719105dc1e03398de41f2cab37337816fe assets\oritech\blockstates\machine_core_good.json
6261
5462a2453fcdd2f8b99129894aec60f282d29ca9 assets\oritech\models\item\pulverizer_block.json
6362
ae8496aa356910304cb7036f1290ca3f7d76437e assets\oritech\models\item\item_filter_block.json
6463
a3f9b72f6f36d42af4e5c3a87d7e180b2e36a2ed assets\oritech\models\item\machine_core_good.json

src/main/generated/assets/oritech/blockstates/giga_storage_block.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"variants": {
33
"": {
4-
"model": "oritech:block/pump_block"
4+
"model": "oritech:block/machine_speed_addon"
55
}
66
}
77
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"variants": {
3+
"": {
4+
"model": "oritech:block/pump_trunk_block"
5+
}
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"parent": "minecraft:block/cube_all",
33
"textures": {
4-
"all": "oritech:block/pump_block"
4+
"all": "oritech:block/pump_trunk_block"
55
}
66
}

src/main/generated/assets/oritech/models/item/giga_storage_block.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/main/java/rearth/oritech/block/blocks/machines/interaction/PumpBlock.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,22 @@
77
import net.minecraft.block.entity.BlockEntity;
88
import net.minecraft.block.entity.BlockEntityTicker;
99
import net.minecraft.block.entity.BlockEntityType;
10-
import net.minecraft.entity.player.PlayerEntity;
11-
import net.minecraft.state.StateManager;
12-
import net.minecraft.state.property.BooleanProperty;
13-
import net.minecraft.text.Text;
14-
import net.minecraft.util.ActionResult;
15-
import net.minecraft.util.Hand;
16-
import net.minecraft.util.hit.BlockHitResult;
1710
import net.minecraft.util.math.BlockPos;
1811
import net.minecraft.world.World;
1912
import org.jetbrains.annotations.Nullable;
20-
import rearth.oritech.block.entity.machines.interaction.LaserArmBlockEntity;
2113
import rearth.oritech.block.entity.machines.interaction.PumpBlockEntity;
22-
import rearth.oritech.network.NetworkContent;
23-
import rearth.oritech.util.MultiblockMachineController;
2414

2515
public class PumpBlock extends Block implements BlockEntityProvider {
2616

2717
public PumpBlock(Settings settings) {
2818
super(settings);
2919
}
3020

31-
// @Override
32-
// public BlockRenderType getRenderType(BlockState state) {
33-
// return BlockRenderType.ENTITYBLOCK_ANIMATED;
34-
// }
21+
22+
@Override
23+
public BlockRenderType getRenderType(BlockState state) {
24+
return BlockRenderType.ENTITYBLOCK_ANIMATED;
25+
}
3526

3627
@Nullable
3728
@Override

src/main/java/rearth/oritech/block/entity/machines/interaction/PumpBlockEntity.java

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,43 @@
1212
import net.minecraft.fluid.FluidState;
1313
import net.minecraft.fluid.Fluids;
1414
import net.minecraft.nbt.NbtCompound;
15+
import net.minecraft.particle.ParticleTypes;
16+
import net.minecraft.registry.Registries;
1517
import net.minecraft.util.math.BlockPos;
1618
import net.minecraft.util.math.Direction;
1719
import net.minecraft.world.World;
20+
import rearth.oritech.block.base.entity.MachineBlockEntity;
1821
import rearth.oritech.init.BlockContent;
1922
import rearth.oritech.init.BlockEntitiesContent;
23+
import rearth.oritech.init.FluidContent;
24+
import rearth.oritech.network.NetworkContent;
2025
import rearth.oritech.util.EnergyProvider;
2126
import rearth.oritech.util.FluidProvider;
27+
import software.bernie.geckolib.animatable.GeoBlockEntity;
28+
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
29+
import software.bernie.geckolib.core.animation.AnimatableManager;
30+
import software.bernie.geckolib.core.animation.AnimationController;
31+
import software.bernie.geckolib.core.object.PlayState;
32+
import software.bernie.geckolib.util.GeckoLibUtil;
2233
import team.reborn.energy.api.EnergyStorage;
2334
import team.reborn.energy.api.base.SimpleEnergyStorage;
2435

2536
import java.util.*;
2637
import java.util.stream.Collectors;
2738

28-
public class PumpBlockEntity extends BlockEntity implements BlockEntityTicker<PumpBlockEntity>, FluidProvider, EnergyProvider {
39+
public class PumpBlockEntity extends BlockEntity implements BlockEntityTicker<PumpBlockEntity>, FluidProvider, EnergyProvider, GeoBlockEntity {
2940

3041
private static final int MAX_SEARCH_COUNT = 100000;
3142
private static final int ENERGY_USAGE = 1000; // per block pumped
3243
private static final int PUMP_RATE = 5; // pump every n ticks
3344

45+
protected final AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this);
46+
private final AnimationController<PumpBlockEntity> animationController = getAnimationController();
47+
48+
// client only
49+
public FluidVariant lastPumpedVariant;
50+
public long lastPumpTime;
51+
3452
private final SingleVariantStorage<FluidVariant> fluidStorage = new SingleVariantStorage<>() {
3553
@Override
3654
protected FluidVariant getBlankVariant() {
@@ -85,7 +103,11 @@ public void readNbt(NbtCompound nbt) {
85103

86104
@Override
87105
public void tick(World world, BlockPos pos, BlockState state, PumpBlockEntity blockEntity) {
88-
if (world.isClient) return;
106+
if (world.isClient) {
107+
if (isBusy())
108+
spawnWorkingParticles();
109+
return;
110+
}
89111

90112
if (!initialized) {
91113
progressStartup();
@@ -112,10 +134,22 @@ public void tick(World world, BlockPos pos, BlockState state, PumpBlockEntity bl
112134
addLiquidToTank(targetState);
113135
useEnergy();
114136
this.markDirty();
137+
updateNetwork(fluidStorage.variant);
115138
}
116139

117140
}
118141

142+
private void spawnWorkingParticles() {
143+
if (world.getTime() % 5 != 0) return;
144+
145+
var targetPos = pos.toCenterPos();
146+
var targetType = ParticleTypes.BUBBLE_COLUMN_UP;
147+
if (lastPumpedVariant.getFluid().equals(Fluids.LAVA)) targetType = ParticleTypes.LAVA;
148+
if (lastPumpedVariant.getFluid().equals(FluidContent.STILL_OIL)) targetType = ParticleTypes.FALLING_OBSIDIAN_TEAR;
149+
150+
world.addParticle(targetType, targetPos.getX(), targetPos.getY(), targetPos.getZ(), 0, 0.3, 0);
151+
}
152+
119153
private boolean hasEnoughEnergy() {
120154
return energyStorage.getAmount() >= ENERGY_USAGE;
121155
}
@@ -178,7 +212,7 @@ private void moveToolheadDown() {
178212
}
179213

180214
toolheadPosition = toolheadPosition.down();
181-
world.setBlockState(toolheadPosition, BlockContent.BANANA_BLOCK.getDefaultState());
215+
world.setBlockState(toolheadPosition, BlockContent.PUMP_TRUNK_BLOCK.getDefaultState());
182216
}
183217

184218
private boolean checkToolheadEnd(BlockPos newPosition) {
@@ -218,6 +252,40 @@ public EnergyStorage getStorage(Direction direction) {
218252
return energyStorage;
219253
}
220254

255+
@Override
256+
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
257+
controllers.add(animationController);
258+
}
259+
260+
private void updateNetwork(FluidVariant variant) {
261+
var fluid = Registries.FLUID.getId(variant.getFluid()).toString();
262+
NetworkContent.MACHINE_CHANNEL.serverHandle(this).send(new NetworkContent.PumpWorkSyncPacket(pos, fluid, world.getTime()));
263+
}
264+
265+
@Override
266+
public AnimatableInstanceCache getAnimatableInstanceCache() {
267+
return animatableInstanceCache;
268+
}
269+
270+
private boolean isBusy() {
271+
return world.getTime() - lastPumpTime < 40;
272+
}
273+
274+
private AnimationController<PumpBlockEntity> getAnimationController() {
275+
return new AnimationController<>(this, state -> {
276+
if (isBusy()) return state.setAndContinue(MachineBlockEntity.WORKING);
277+
return PlayState.STOP;
278+
});
279+
}
280+
281+
public void setLastPumpedVariant(FluidVariant lastPumpedVariant) {
282+
this.lastPumpedVariant = lastPumpedVariant;
283+
}
284+
285+
public void setLastPumpTime(long lastPumpTime) {
286+
this.lastPumpTime = lastPumpTime;
287+
}
288+
221289
private static class FloodFillSearch {
222290

223291
final HashSet<BlockPos> checkedPositions = new HashSet<>();

src/main/java/rearth/oritech/client/init/ModRenderers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static void registerRenderers() {
3636

3737
// interactions
3838
BlockEntityRendererFactories.register(BlockEntitiesContent.LASER_ARM_BLOCK, ctx -> new LaserArmRenderer<>("models/laser_arm_block"));
39+
BlockEntityRendererFactories.register(BlockEntitiesContent.PUMP_BLOCK, ctx -> new MachineRenderer<>("models/pump_block"));
3940
BlockEntityRendererFactories.register(BlockEntitiesContent.PLACER_BLOCK_ENTITY, ctx -> new MachineGantryRenderer());
4041
BlockEntityRendererFactories.register(BlockEntitiesContent.DESTROYER_BLOCK_ENTITY, ctx -> new MachineGantryRenderer());
4142
BlockEntityRendererFactories.register(BlockEntitiesContent.FERTILIZER_BLOCK_ENTITY, ctx -> new MachineGantryRenderer());

src/main/java/rearth/oritech/init/BlockContent.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class BlockContent implements BlockRegistryContainer {
3737
@ItemGroups.ItemGroupTarget(ItemGroups.GROUPS.second)
3838
public static final Block BANANA_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK));
3939

40+
4041
@ItemGroups.ItemGroupTarget(ItemGroups.GROUPS.second)
4142
public static final Block MACHINE_FRAME_BLOCK = new MachineFrameBlock(FabricBlockSettings.copyOf(Blocks.IRON_BARS));
4243
@ItemGroups.ItemGroupTarget(ItemGroups.GROUPS.second)
@@ -63,6 +64,8 @@ public class BlockContent implements BlockRegistryContainer {
6364
public static final Block BLOCK_PLACER_HEAD = new Block(FabricBlockSettings.copyOf(Blocks.CHAIN).nonOpaque());
6465
@NoBlockItem
6566
public static final Block BLOCK_FERTILIZER_HEAD = new Block(FabricBlockSettings.copyOf(Blocks.CHAIN).nonOpaque());
67+
@NoBlockItem
68+
public static final Block PUMP_TRUNK_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.CHAIN).nonOpaque());
6669

6770
@NoBlockItem
6871
public static final Block ADDON_INDICATOR_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.GLASS));
@@ -98,6 +101,8 @@ public class BlockContent implements BlockRegistryContainer {
98101
public static final Block PLACER_BLOCK = new PlacerBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque());
99102
public static final Block DESTROYER_BLOCK = new DestroyerBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque());
100103
public static final Block FERTILIZER_BLOCK = new FertilizerBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque());
104+
105+
@UseGeoBlockItem(scale = 0.7f)
101106
public static final Block PUMP_BLOCK = new PumpBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque());
102107

103108
public static final Block MACHINE_CORE_BASIC = new MachineCoreBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), 1);

0 commit comments

Comments
 (0)