Skip to content

Commit 0ab192d

Browse files
committed
feat!: update content api to 25w05a
Breaking Changes - Raids no longer have a ServerWorld link Additions - Mainly new type entries and tag entries are updated
1 parent bdfd8fc commit 0ab192d

17 files changed

Lines changed: 113 additions & 77 deletions

File tree

generator/src/main/java/org/spongepowered/vanilla/generator/world/entities/EntityRegistries.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ public static List<Generator> registryEntries(final Context context) {
229229
Registries.PIG_VARIANT,
230230
$ -> true,
231231
RegistryScope.SERVER
232+
),
233+
new RegistryEntriesGenerator<>(
234+
"data.type",
235+
"CowVariants",
236+
"COW_VARIANT",
237+
context.relativeClass("data.type", "CowVariant"),
238+
Registries.COW_VARIANT,
239+
$ -> true,
240+
RegistryScope.SERVER
232241
)
233242
);
234243
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mixinConfigs=mixins.sponge.accessors.json,mixins.sponge.api.json,mixins.sponge.c
1212
mixins.sponge.tracker.json,mixins.sponge.ipforward.json,mixins.sponge.optimization.json
1313
superClassChanges=common.superclasschange
1414

15-
minecraftVersion=25w04a
15+
minecraftVersion=25w05a
1616
recommendedVersion=0-SNAPSHOT
1717

1818
org.gradle.dependency.verification.console=verbose

src/accessors/java/org/spongepowered/common/accessor/world/entity/LivingEntityAccessor.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import net.minecraft.core.BlockPos;
2828
import net.minecraft.core.particles.ParticleOptions;
2929
import net.minecraft.network.syncher.EntityDataAccessor;
30-
import net.minecraft.world.damagesource.DamageSource;
3130
import net.minecraft.world.entity.LivingEntity;
3231
import net.minecraft.world.item.ItemStack;
3332
import org.spongepowered.asm.mixin.Mixin;
@@ -76,8 +75,6 @@ public interface LivingEntityAccessor {
7675
throw new UntransformedAccessorError();
7776
}
7877

79-
@Accessor("dead") boolean accessor$dead();
80-
8178
@Accessor("lastHurt") float accessor$lastHurt();
8279

8380
@Accessor("lastHurt") void accessor$lastHurt(final float lastHurt);
@@ -91,6 +88,4 @@ public interface LivingEntityAccessor {
9188

9289
@Accessor("useItem") void accessor$useItem(final ItemStack useItem);
9390

94-
@Invoker("isDamageSourceBlocked") boolean invoker$isDamageSourceBlocked(final DamageSource source);
95-
9691
}

src/accessors/java/org/spongepowered/common/accessor/world/entity/raid/RaidsAccessor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@
2424
*/
2525
package org.spongepowered.common.accessor.world.entity.raid;
2626

27+
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
2728
import net.minecraft.world.entity.raid.Raid;
2829
import net.minecraft.world.entity.raid.Raids;
2930
import org.spongepowered.asm.mixin.Mixin;
3031
import org.spongepowered.asm.mixin.gen.Accessor;
3132

32-
import java.util.Map;
3333

3434
@Mixin(Raids.class)
3535
public interface RaidsAccessor {
3636

37-
@Accessor("raidMap") Map<Integer, Raid> accessor$raidMap();
37+
@Accessor("raidMap")
38+
Int2ObjectMap<Raid> accessor$raidMap();
3839

3940
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.common.accessor.world.level.saveddata.maps;
26+
27+
import net.minecraft.world.level.saveddata.maps.MapIndex;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.gen.Accessor;
30+
31+
@Mixin(MapIndex.class)
32+
public interface MapIndexAccessor {
33+
34+
@Accessor("lastMapId") int accessor$getLastIndexID();
35+
36+
}

src/accessors/resources/mixins.sponge.accessors.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
"world.level.levelgen.flat.FlatLevelGeneratorSettingsAccessor",
212212
"world.level.levelgen.structure.pools.StructureTemplatePoolAccessor",
213213
"world.level.portal.TeleportTransitionAccessor",
214+
"world.level.saveddata.maps.MapIndexAccessor",
214215
"world.level.saveddata.maps.MapItemSavedDataAccessor",
215216
"world.level.storage.LevelStorageSource_LevelStorageAccessAccessor",
216217
"world.level.storage.PlayerDataStorageAccessor",

src/main/java/org/spongepowered/common/event/SpongeCommonEventFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ public static Optional<MapInfo> fireCreateMapEvent(final Cause cause, final Set<
743743

744744
final ServerLevel defaultWorld = (ServerLevel) Sponge.server().worldManager().world(DefaultWorldKeys.DEFAULT).get();
745745
final MapIdTrackerBridge mapIdTrackerBridge = (MapIdTrackerBridge) defaultWorld.getDataStorage()
746-
.computeIfAbsent(MapIndex.factory(), Constants.Map.MAP_INDEX_DATA_NAME);
746+
.computeIfAbsent(MapIndex.TYPE);
747747

748748
final MapItemSavedData mapData = MapItemSavedData.createFresh(0, 0, (byte) 0, false, false, Level.END);
749749

src/main/java/org/spongepowered/common/map/SpongeMapStorage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@
3434
import org.spongepowered.api.map.MapStorage;
3535
import org.spongepowered.api.world.DefaultWorldKeys;
3636
import org.spongepowered.common.SpongeCommon;
37-
import org.spongepowered.common.bridge.map.MapIdTrackerBridge;
37+
import org.spongepowered.common.accessor.world.level.saveddata.maps.MapIndexAccessor;
3838
import org.spongepowered.common.bridge.world.level.storage.PrimaryLevelDataBridge;
3939
import org.spongepowered.common.event.SpongeCommonEventFactory;
4040
import org.spongepowered.common.event.tracking.PhaseTracker;
41-
import org.spongepowered.common.util.Constants;
4241

4342
import java.util.Collection;
4443
import java.util.HashMap;
@@ -64,8 +63,7 @@ public Collection<MapInfo> allMapInfos() {
6463
final Set<MapInfo> mapInfos = new HashSet<>();
6564
final ServerLevel defaultWorld = (ServerLevel) Sponge.server().worldManager().world(DefaultWorldKeys.DEFAULT).get();
6665

67-
final int highestId = ((MapIdTrackerBridge) defaultWorld.getDataStorage()
68-
.computeIfAbsent(MapIndex.factory(), Constants.Map.MAP_INDEX_DATA_NAME)).bridge$getHighestMapId().orElse(-1);
66+
final int highestId = ((MapIndexAccessor) defaultWorld.getDataStorage().computeIfAbsent(MapIndex.TYPE)).accessor$getLastIndexID();
6967
for (int i = 0; i <= highestId; i++) {
7068
final @Nullable MapInfo mapInfo = (MapInfo) defaultWorld.getMapData(new MapId(i));
7169
if (mapInfo == null) {

src/main/java/org/spongepowered/common/raid/SpongeRaidWave.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package org.spongepowered.common.raid;
2626

2727

28+
import net.minecraft.server.level.ServerLevel;
2829
import org.spongepowered.api.entity.living.monster.raider.Raider;
2930
import org.spongepowered.api.raid.Raid;
3031
import org.spongepowered.api.raid.RaidWave;
@@ -56,11 +57,7 @@ public boolean isBonus() {
5657
* If the wave is not a final wave, the bonus waves occur after the final wave.
5758
* If our wave was before the final wave, the amount of normal raids (which is set by the difficulty) would be greater than our wave's id.
5859
*/
59-
if (this.isFinal() || this.waveId < ((RaidAccessor) this.raid).accessor$numGroups()) {
60-
return false;
61-
}
62-
63-
return true;
60+
return !this.isFinal() && this.waveId >= ((RaidAccessor) this.raid).accessor$numGroups();
6461
}
6562

6663
@Override
@@ -78,14 +75,18 @@ public Optional<Raider> leader() {
7875
@Override
7976
public boolean addRaider(Raider raider, boolean addToRaidHealth) {
8077
Objects.requireNonNull(raider, "Raider cannot be null.");
81-
return this.raid.addWaveMob(this.waveId, (net.minecraft.world.entity.raid.Raider) raider, addToRaidHealth);
78+
// We only support adding raiders to server worlds
79+
if (raider.world() instanceof ServerLevel sl) {
80+
return this.raid.addWaveMob(sl, this.waveId, (net.minecraft.world.entity.raid.Raider) raider, addToRaidHealth);
81+
}
82+
return false;
8283
}
8384

8485
@Override
8586
public boolean removeRaider(Raider raider) {
8687
Objects.requireNonNull(raider, "Raider cannot be null.");
87-
if (raider.raidWave().isPresent() && this.equals(raider.raidWave().get().get())) {
88-
this.raid.removeFromRaid((net.minecraft.world.entity.raid.Raider) raider, true);
88+
if (raider.raidWave().isPresent() && this.equals(raider.raidWave().get().get()) && raider.world() instanceof ServerLevel sl) {
89+
this.raid.removeFromRaid(sl, (net.minecraft.world.entity.raid.Raider) raider, true);
8990
return true;
9091
}
9192

@@ -94,11 +95,10 @@ public boolean removeRaider(Raider raider) {
9495

9596
@Override
9697
public boolean equals(Object obj) {
97-
if (obj instanceof SpongeRaidWave) {
98-
SpongeRaidWave other = (SpongeRaidWave) obj;
98+
if (obj instanceof SpongeRaidWave other) {
9999
// Minecraft Tracks it's raids via an ID which is handled by the RaidManager.
100100
// Each world has it's own raid manager so we have to verify that the world the raids are in is also equal.
101-
if (this.waveId == other.waveId && this.raid.getLevel() == other.raid.getLevel() && this.raid.getId() == other.raid.getId()) {
101+
if (this.waveId == other.waveId && this.raid == other.raid && this.raid.getCenter() == other.raid.getCenter()) {
102102
return true;
103103
}
104104
}

0 commit comments

Comments
 (0)