-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathDummyWorld.java
More file actions
125 lines (102 loc) · 4.4 KB
/
Copy pathDummyWorld.java
File metadata and controls
125 lines (102 loc) · 4.4 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package gregtech.api.util.world;
import gregtech.api.util.Mods;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.profiler.Profiler;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.*;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.Optional.Method;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import dev.redstudio.alfheim.lighting.LightingEngine;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DummyWorld extends World {
private static final WorldSettings DEFAULT_SETTINGS = new WorldSettings(
1L, GameType.SURVIVAL, true, false, WorldType.DEFAULT);
public static final DummyWorld INSTANCE = new DummyWorld();
public DummyWorld() {
super(new DummySaveHandler(), new WorldInfo(DEFAULT_SETTINGS, "DummyServer"), new WorldProviderSurface(),
new Profiler(), false);
// Guarantee the dimension ID was not reset by the provider
this.provider.setDimension(Integer.MAX_VALUE);
int providerDim = this.provider.getDimension();
this.provider.setWorld(this);
this.provider.setDimension(providerDim);
this.chunkProvider = this.createChunkProvider();
this.calculateInitialSkylight();
this.calculateInitialWeather();
this.getWorldBorder().setSize(30000000);
// De-allocate lightUpdateBlockList, checkLightFor uses this
ObfuscationReflectionHelper.setPrivateValue(World.class, this, null,
FMLLaunchHandler.isDeobfuscatedEnvironment() ? "lightUpdateBlockList" : "field_72994_J");
// De-allocate alfheim lighting engine
if (Mods.Alfheim.isModLoaded()) {
ObfuscationReflectionHelper.setPrivateValue(World.class, this, null,
"alfheim$lightingEngine");
}
}
@Override
public void notifyNeighborsRespectDebug(@NotNull BlockPos pos, @NotNull Block blockType, boolean p_175722_3_) {
// NOOP - do not trigger forge events
}
@Override
public void notifyNeighborsOfStateChange(@NotNull BlockPos pos, @NotNull Block blockType, boolean updateObservers) {
// NOOP - do not trigger forge events
}
@Override
public void notifyNeighborsOfStateExcept(@NotNull BlockPos pos, @NotNull Block blockType,
@NotNull EnumFacing skipSide) {
// NOOP - do not trigger forge events
}
@Override
public void markAndNotifyBlock(@NotNull BlockPos pos, @Nullable Chunk chunk, @NotNull IBlockState iblockstate,
@NotNull IBlockState newState, int flags) {
// NOOP - do not trigger forge events
}
@Override
public void notifyBlockUpdate(@NotNull BlockPos pos, @NotNull IBlockState oldState, @NotNull IBlockState newState,
int flags) {}
@Override
public void markBlockRangeForRenderUpdate(@NotNull BlockPos rangeMin, @NotNull BlockPos rangeMax) {}
@Override
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {}
@Override
public void updateObservingBlocksAt(@NotNull BlockPos pos, @NotNull Block blockType) {}
@NotNull
@Override
protected IChunkProvider createChunkProvider() {
return new DummyChunkProvider(this);
}
@Override
protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
return chunkProvider.isChunkGeneratedAt(x, z);
}
@Override
// De-allocated lightUpdateBlockList, default return
public boolean checkLightFor(@NotNull EnumSkyBlock lightType, @NotNull BlockPos pos) {
return true;
}
@Override
@Method(modid = Mods.Names.ALFHEIM)
public World init() {
return this;
}
@Override
@Method(modid = Mods.Names.ALFHEIM)
public int getLightFromNeighborsFor(EnumSkyBlock type, BlockPos pos) {
return 15;
}
@Method(modid = Mods.Names.ALFHEIM)
public int alfheim$getLight(BlockPos pos, boolean checkNeighbors) {
return 15;
}
@Method(modid = Mods.Names.ALFHEIM)
public LightingEngine getAlfheim$lightingEngine() {
return null;
}
}