Skip to content

Commit 5497de1

Browse files
committed
fixed up some issues
1 parent b3bc24e commit 5497de1

File tree

10 files changed

+22
-52
lines changed

10 files changed

+22
-52
lines changed

Diff for: src/main/java/de/ellpeck/naturesaura/InternalHooks.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import net.minecraft.util.Tuple;
1414
import net.minecraft.world.entity.player.Player;
1515
import net.minecraft.world.level.Level;
16+
import net.minecraft.world.level.chunk.LevelChunk;
1617
import net.minecraft.world.phys.AABB;
1718
import net.minecraft.world.phys.Vec3;
1819
import org.apache.commons.lang3.mutable.MutableFloat;
@@ -201,8 +202,8 @@ public ILevelData getLevelData(Level level) {
201202
}
202203

203204
@Override
204-
public IAuraChunk createAuraChunk() {
205-
return new AuraChunk();
205+
public IAuraChunk createAuraChunk(LevelChunk chunk) {
206+
return new AuraChunk(chunk);
206207
}
207208

208209
}

Diff for: src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.google.common.collect.BiMap;
44
import com.google.common.collect.HashBiMap;
5-
import de.ellpeck.naturesaura.api.aura.chunk.AuraChunkProvider;
65
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
76
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
87
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
@@ -23,6 +22,7 @@
2322
import net.minecraft.world.item.ItemStack;
2423
import net.minecraft.world.level.Level;
2524
import net.minecraft.world.level.block.state.BlockState;
25+
import net.minecraft.world.level.chunk.LevelChunk;
2626
import net.minecraft.world.phys.AABB;
2727
import net.minecraft.world.phys.Vec3;
2828
import net.neoforged.neoforge.attachment.AttachmentType;
@@ -99,7 +99,7 @@ public final class NaturesAuraAPI {
9999
/**
100100
* The capability that any chunk in a level has to store Aura in it. As this is only applicable to chunks and all chunks in the level automatically get assigned this capability, using it directly is not necessary for addon developers. To retrieve this capability from any chunk, use the helper method {@link IAuraChunk#getAuraChunk(net.minecraft.world.level.Level, BlockPos)}.
101101
*/
102-
public static final AttachmentType<AuraChunkProvider> AURA_CHUNK_ATTACHMENT = AttachmentType.serializable(AuraChunkProvider::new).build();
102+
public static final AttachmentType<IAuraChunk> AURA_CHUNK_ATTACHMENT = AttachmentType.serializable(h -> NaturesAuraAPI.instance().createAuraChunk((LevelChunk) h)).build();
103103
private static final IInternalHooks INSTANCE;
104104

105105
static {
@@ -260,7 +260,7 @@ public interface IInternalHooks {
260260

261261
ILevelData getLevelData(Level level);
262262

263-
IAuraChunk createAuraChunk();
263+
IAuraChunk createAuraChunk(LevelChunk chunk);
264264

265265
}
266266

Diff for: src/main/java/de/ellpeck/naturesaura/api/aura/chunk/AuraChunkProvider.java

-29
This file was deleted.

Diff for: src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface IAuraChunk extends INBTSerializable<CompoundTag> {
3333
*/
3434
static IAuraChunk getAuraChunk(Level level, BlockPos pos) {
3535
var chunk = (LevelChunk) level.getChunk(pos);
36-
return chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(chunk);
36+
return chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
3737
}
3838

3939
/**
@@ -160,6 +160,4 @@ static BlockPos getHighestSpot(Level level, BlockPos pos, int radius, BlockPos d
160160

161161
void markDirty();
162162

163-
void ensureInitialized(LevelChunk chunk);
164-
165163
}

Diff for: src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected Projectile getProjectile(Level levelIn, Position position, ItemStack s
5050
protected Projectile getProjectile(Level levelIn, Position position, ItemStack stackIn) {
5151
var ret = new ThrownTrident(EntityType.TRIDENT, levelIn);
5252
ret.setPos(position.x(), position.y(), position.z());
53-
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "f_37555_");
53+
ObfuscationReflectionHelper.setPrivateValue(ThrownTrident.class, ret, stackIn.copy(), "pickupItemStack");
5454
ret.pickup = AbstractArrow.Pickup.ALLOWED;
5555
return ret;
5656
}

Diff for: src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickableBlockEntity {
2626

27-
private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceBlockEntity.class, "f_58311_");
27+
private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceBlockEntity.class, "dataAccess");
2828
public boolean isActive;
2929

3030
public BlockEntityFurnaceHeater(BlockPos pos, BlockState state) {

Diff for: src/main/java/de/ellpeck/naturesaura/chunk/AuraChunk.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,12 @@ public class AuraChunk implements IAuraChunk {
3737
private final Table<BlockPos, Integer, Pair<Integer, Integer>> auraAndSpotAmountCache = HashBasedTable.create();
3838
private final Table<BlockPos, Integer, Pair<BlockPos, Integer>[]> limitSpotCache = HashBasedTable.create();
3939
private final List<IDrainSpotEffect> effects = new ArrayList<>();
40+
private final LevelChunk chunk;
41+
private final IAuraType type;
4042

41-
private LevelChunk chunk;
42-
private IAuraType type;
4343
private boolean needsSync;
4444

45-
@Override
46-
public void ensureInitialized(LevelChunk chunk) {
47-
// are we already initialized?
48-
if (this.chunk != null)
49-
return;
50-
45+
public AuraChunk(LevelChunk chunk) {
5146
this.chunk = chunk;
5247
this.type = IAuraType.forLevel(chunk.getLevel());
5348

Diff for: src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333

3434
public class CommonEvents {
3535

36-
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "m_140416_");
36+
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "getChunks");
3737
private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create();
3838

3939
@SubscribeEvent
4040
public void onChunkUnload(ChunkEvent.Unload event) {
4141
var iChunk = event.getChunk();
4242
if (iChunk instanceof LevelChunk chunk) {
43-
var auraChunk = chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(chunk);
43+
var auraChunk = chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
4444
if (auraChunk instanceof AuraChunk) {
4545
var data = (LevelData) ILevelData.getLevelData(chunk.getLevel());
4646
data.auraChunksWithSpots.remove(chunk.getPos().toLong());
@@ -76,7 +76,7 @@ public void onLevelTick(TickEvent.LevelTickEvent event) {
7676
var chunk = holder.getTickingChunk();
7777
if (chunk == null)
7878
continue;
79-
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(chunk);
79+
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
8080
if (auraChunk != null)
8181
auraChunk.update();
8282
}
@@ -116,7 +116,7 @@ private boolean handleChunkWatchDeferred(Player player, ChunkPos pos) {
116116
var chunk = Helper.getLoadedChunk(player.level(), pos.x, pos.z);
117117
if (!(chunk instanceof LevelChunk levelChunk))
118118
return false;
119-
var auraChunk = (AuraChunk) levelChunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(levelChunk);
119+
var auraChunk = (AuraChunk) levelChunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
120120
if (auraChunk == null)
121121
return false;
122122
PacketHandler.sendTo(player, auraChunk.makePacket());

Diff for: src/main/java/de/ellpeck/naturesaura/misc/LevelData.java

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public CompoundTag save(CompoundTag compound) {
7070
return compound;
7171
}
7272

73+
@Override
74+
public boolean isDirty() {
75+
return true;
76+
}
77+
7378
@Override
7479
public ItemStackHandlerNA getEnderStorage(String name) {
7580
return this.enderStorages.computeIfAbsent(name, n -> new ItemStackHandlerNA(27));

Diff for: src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public boolean tryHandle(Level level) {
6161
var chunk = level.getChunk(this.chunkX, this.chunkZ);
6262
if (chunk.isEmpty())
6363
return false;
64-
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(chunk);
64+
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
6565
if (auraChunk == null)
6666
return false;
6767
auraChunk.setSpots(this.drainSpots);

0 commit comments

Comments
 (0)