-
Notifications
You must be signed in to change notification settings - Fork 361
Expand file tree
/
Copy pathIGregtechBlockEntity.java
More file actions
61 lines (45 loc) · 1.75 KB
/
IGregtechBlockEntity.java
File metadata and controls
61 lines (45 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.gregtechceu.gtceu.api.blockentity;
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.sync_system.ISyncManaged;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.extensions.IForgeBlockEntity;
public interface IGregtechBlockEntity extends ISyncManaged, ITickSubscription, IForgeBlockEntity {
Level getLevel();
BlockPos getBlockPos();
BlockState getBlockState();
long getOffsetTimer();
boolean isRemoved();
void notifyBlockUpdate();
default void scheduleNeighborShapeUpdate() {
Level level = getLevel();
BlockPos pos = getBlockPos();
if (level == null || pos == null)
return;
level.getBlockState(pos).updateNeighbourShapes(level, pos, Block.UPDATE_ALL);
}
void markAsChanged();
default boolean isRemote() {
return getLevel() == null ? GTCEu.isClientThread() : getLevel().isClientSide;
}
default void scheduleRenderUpdate() {
var pos = getBlockPos();
var level = getLevel();
if (level != null) {
var state = getLevel().getBlockState(pos);
if (level.isClientSide) {
level.sendBlockUpdated(pos, state, state, Block.UPDATE_IMMEDIATE);
requestModelDataUpdate();
} else {
level.blockEvent(pos, state.getBlock(), 1, 0);
}
}
}
default BlockEntity getNeighbor(Direction direction) {
return getLevel().getBlockEntity(getBlockPos().relative(direction));
}
}