Skip to content

Commit

Permalink
chore(update): update to 24w39a
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
  • Loading branch information
gabizou committed Oct 3, 2024
1 parent 42a6077 commit dac0c11
Show file tree
Hide file tree
Showing 84 changed files with 421 additions and 432 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,6 @@ private static List<Generator> generators(final Context context) {
"getSerializedName",
"sponge"
),
new EnumEntriesValidator<>(
"data.type",
"BoatTypes",
Boat.Type.class,
"getSerializedName",
"sponge"
),
new RegistryEntriesGenerator<>(
"map.decoration",
"MapDecorationTypes",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mixinConfigs=mixins.sponge.accessors.json,mixins.sponge.api.json,mixins.sponge.c
mixins.sponge.tracker.json,mixins.sponge.ipforward.json,mixins.sponge.optimization.json
superClassChanges=common.superclasschange

minecraftVersion=24w38a
minecraftVersion=24w39a
recommendedVersion=0-SNAPSHOT

org.gradle.dependency.verification.console=verbose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ public interface EntityAccessor {

@Invoker("getFireImmuneTicks") int invoker$getFireImmuneTicks();

@Invoker("getPermissionLevel") int invoker$getPermissionLevel();

@Invoker("unsetRemoved") void invoker$unsetRemoved();

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
@Mixin(TargetingConditions.class)
public interface TargetingConditionsAccessor {

@Accessor("selector") Predicate<LivingEntity> accessor$selector();
@Accessor("selector") TargetingConditions.Selector accessor$selector();

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package org.spongepowered.common.accessor.world.entity.decoration;

import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.decoration.ItemFrame;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -32,6 +33,6 @@
@Mixin(ItemFrame.class)
public interface ItemFrameAccessor {

@Invoker("dropItem") void invoker$dropItem(final Entity entity, final boolean drop);
@Invoker("dropItem") void invoker$dropItem(final ServerLevel level, final Entity entity, final boolean drop);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import org.spongepowered.common.UntransformedAccessorError;

@Mixin(Player.class)
Expand Down Expand Up @@ -57,6 +58,7 @@ public interface PlayerAccessor {
@Accessor("DATA_SHOULDER_RIGHT") static EntityDataAccessor<CompoundTag> accessor$DATA_SHOULDER_RIGHT() {
throw new UntransformedAccessorError();
}
@Invoker("getPermissionLevel") int invoker$getPermissionLevel();

@Accessor("sleepCounter") void accessor$sleepCounter(final int sleepCounter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
package org.spongepowered.common.accessor.world.entity.vehicle;

import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.entity.vehicle.AbstractBoat;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(Boat.class)
public interface BoatAccessor {
@Mixin(AbstractBoat.class)
public interface AbstractBoatAccessor {

@Accessor("status") Boat.Status accessor$status();
@Accessor("status") AbstractBoat.Status accessor$status();

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public interface FoodDataAccessor {

@Accessor("exhaustionLevel") void accessor$exhaustionLevel(final float exhaustionLevel);

@Accessor("exhaustionLevel") float accessor$exhaustionLevel();

}
2 changes: 1 addition & 1 deletion src/accessors/resources/mixins.sponge.accessors.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"world.entity.raid.RaidAccessor",
"world.entity.raid.RaiderAccessor",
"world.entity.raid.RaidsAccessor",
"world.entity.vehicle.BoatAccessor",
"world.entity.vehicle.AbstractBoatAccessor",
"world.entity.vehicle.MinecartFurnaceAccessor",
"world.food.FoodDataAccessor",
"world.inventory.AbstractContainerMenuAccessor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package org.spongepowered.common.bridge.world.entity.vehicle;

public interface BoatBridge {
public interface AbstractBoatBridge {

double bridge$getMaxSpeed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ private LockableData() {
public static void register(final DataProviderRegistrator registrator) {
registrator
.asMutable(BaseContainerBlockEntityAccessor.class)
.create(Keys.LOCK_TOKEN)
.get(h -> h.accessor$lockKey().key())
.set((h, v) -> h.accessor$lockKey(v.isEmpty() ? LockCode.NO_LOCK : new LockCode(v)));
.create(Keys.LOCK_TOKEN);// TODO - Implement Item Predicates
// .get(h -> h.accessor$lockKey().key())
// .set((h, v) -> h.accessor$lockKey(v.isEmpty() ? LockCode.NO_LOCK : new LockCode(v)));
}
// @formatter:on
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
package org.spongepowered.common.data.provider.entity;

import net.minecraft.world.entity.vehicle.AbstractBoat;
import net.minecraft.world.entity.vehicle.Boat;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.persistence.DataContentUpdater;
import org.spongepowered.api.data.type.BoatType;
import org.spongepowered.common.accessor.world.entity.vehicle.BoatAccessor;
import org.spongepowered.common.bridge.world.entity.vehicle.BoatBridge;
import org.spongepowered.common.accessor.world.entity.vehicle.AbstractBoatAccessor;
import org.spongepowered.common.bridge.world.entity.vehicle.AbstractBoatBridge;
import org.spongepowered.common.data.ByteToBooleanContentUpdater;
import org.spongepowered.common.data.SpongeDataManager;
import org.spongepowered.common.data.provider.DataProviderRegistrator;
Expand All @@ -46,32 +46,29 @@ private BoatData() {
// @formatter:off
public static void register(final DataProviderRegistrator registrator) {
registrator
.asMutable(Boat.class)
.create(Keys.BOAT_TYPE)
.get(h -> ((BoatType) (Object) h.getVariant()))
.set((h, v) -> h.setVariant((Boat.Type) (Object) v))
.asMutable(BoatAccessor.class)
.asMutable(AbstractBoat.class)
.asMutable(AbstractBoatAccessor.class)
.create(Keys.IS_IN_WATER)
.get(h -> h.accessor$status() == Boat.Status.IN_WATER)
.asMutable(BoatBridge.class)
.asMutable(AbstractBoatBridge.class)
.create(Keys.CAN_MOVE_ON_LAND)
.get(BoatBridge::bridge$getMoveOnLand)
.set(BoatBridge::bridge$setMoveOnLand)
.asMutable(BoatBridge.class)
.get(AbstractBoatBridge::bridge$getMoveOnLand)
.set(AbstractBoatBridge::bridge$setMoveOnLand)
.asMutable(AbstractBoatBridge.class)
.create(Keys.OCCUPIED_DECELERATION)
.get(BoatBridge::bridge$getOccupiedDecelerationSpeed)
.set(BoatBridge::bridge$setOccupiedDecelerationSpeed)
.asMutable(BoatBridge.class)
.get(AbstractBoatBridge::bridge$getOccupiedDecelerationSpeed)
.set(AbstractBoatBridge::bridge$setOccupiedDecelerationSpeed)
.asMutable(AbstractBoatBridge.class)
.create(Keys.MAX_SPEED)
.get(BoatBridge::bridge$getMaxSpeed)
.set(BoatBridge::bridge$setMaxSpeed)
.asMutable(BoatBridge.class)
.get(AbstractBoatBridge::bridge$getMaxSpeed)
.set(AbstractBoatBridge::bridge$setMaxSpeed)
.asMutable(AbstractBoatBridge.class)
.create(Keys.UNOCCUPIED_DECELERATION)
.get(BoatBridge::bridge$getUnoccupiedDecelerationSpeed)
.set(BoatBridge::bridge$setUnoccupiedDecelerationSpeed)
.get(AbstractBoatBridge::bridge$getUnoccupiedDecelerationSpeed)
.set(AbstractBoatBridge::bridge$setUnoccupiedDecelerationSpeed)
;
final ResourceKey boatDataStoreKey = ResourceKey.sponge("boat");
registrator.spongeDataStore(boatDataStoreKey, 2, new DataContentUpdater[]{BoatData.BOAT_UPDATER_BYTE_TO_BOOL_FIX}, BoatBridge.class,
registrator.spongeDataStore(boatDataStoreKey, 2, new DataContentUpdater[]{BoatData.BOAT_UPDATER_BYTE_TO_BOOL_FIX}, AbstractBoatBridge.class,
Keys.MAX_SPEED, Keys.CAN_MOVE_ON_LAND, Keys.OCCUPIED_DECELERATION, Keys.UNOCCUPIED_DECELERATION);
SpongeDataManager.INSTANCE.registerLegacySpongeData(Constants.Entity.Boat.BOAT_MAX_SPEED, boatDataStoreKey, Keys.MAX_SPEED);
SpongeDataManager.INSTANCE.registerLegacySpongeData(Constants.Entity.Boat.BOAT_MOVE_ON_LAND, boatDataStoreKey, Keys.CAN_MOVE_ON_LAND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void register(final DataProviderRegistrator registrator) {
.get(h -> (HandPreference) (Object) h.getMainArm())
.set((h, v) -> h.setMainArm((HumanoidArm) (Object) v))
.create(Keys.EXHAUSTION)
.get(h -> (double) h.getFoodData().getExhaustionLevel())
.get(h -> (double) ((FoodDataAccessor) h.getFoodData()).accessor$exhaustionLevel())
.set((h, v) -> ((FoodDataAccessor) h.getFoodData()).accessor$exhaustionLevel(v.floatValue()))
.create(Keys.EXPERIENCE)
.get(h -> h.totalExperience)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ public static void register(final DataProviderRegistrator registrator) {
return ((DyeColorBlockBridge) block).bridge$getDyeColor().orElse(null);
})
.supports(h -> h.getItem() instanceof BlockItem && !(h.getItem() instanceof BannerItem))
.create(Keys.LOCK_TOKEN)
.get(h -> {
var component = h.getOrDefault(DataComponents.LOCK, LockCode.NO_LOCK);
return component.key().isEmpty() ? null : component.key();
})
.set((h, v) -> {
if (v.isEmpty()) {
h.remove(DataComponents.LOCK);
return;
}
h.set(DataComponents.LOCK, new LockCode(v));
})
.create(Keys.LOCK_TOKEN) // TODO - Implement Item Predicates
// .get(h -> {
// var component = h.getOrDefault(DataComponents.LOCK, LockCode.NO_LOCK);
// return component.key().isEmpty() ? null : component.key();
// })
// .set((h, v) -> {
// if (v.isEmpty()) {
// h.remove(DataComponents.LOCK);
// return;
// }
// h.set(DataComponents.LOCK, new LockCode(v));
// })
.delete(h -> h.remove(DataComponents.LOCK))
.supports(h -> {
if (!(h.getItem() instanceof BlockItem)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import org.spongepowered.api.entity.ai.goal.builtin.creature.AvoidLivingGoal;
import org.spongepowered.api.entity.living.Living;
import org.spongepowered.api.entity.living.PathfinderAgent;
import org.spongepowered.api.world.server.ServerWorld;

import java.util.Objects;
import java.util.function.BiPredicate;
import java.util.function.Predicate;

public final class SpongeAvoidLivingGoalBuilder implements AvoidLivingGoal.Builder {
Expand Down Expand Up @@ -69,7 +71,7 @@ public AvoidLivingGoal.Builder farRangeSpeed(double speed) {

@Override
public AvoidLivingGoal.Builder from(AvoidLivingGoal value) {
return this.targetSelector(value.targetSelector())
return this.targetSelector((e) -> value.targetSelector().test(e, (ServerWorld) e.world()))
.searchDistance(value.searchDistance())
.closeRangeSpeed(value.closeRangeSpeed())
.farRangeSpeed(value.farRangeSpeed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.entity.ai.goal.builtin.creature.target.FindNearestAttackableTargetGoal;
import org.spongepowered.api.entity.living.Living;
Expand All @@ -40,7 +41,7 @@
public final class SpongeFindNearestAttackableTargetGoalBuilder extends SpongeTargetGoalBuilder<FindNearestAttackableTargetGoal, FindNearestAttackableTargetGoal.Builder>
implements FindNearestAttackableTargetGoal.Builder {

private static final Predicate<LivingEntity> ALWAYS_TRUE = e -> true;
private static final TargetingConditions.Selector ALWAYS_TRUE = (e, l) -> true;

private Class<? extends Living> targetClass;
private int chance;
Expand Down Expand Up @@ -94,6 +95,6 @@ public FindNearestAttackableTargetGoal build(PathfinderAgent owner) {
Objects.requireNonNull(this.targetClass);

return (FindNearestAttackableTargetGoal) new NearestAttackableTargetGoal((PathfinderMob) owner, this.targetClass, this.chance,
this.checkSight, this.checkOnlyNearby, this.predicate == null ? SpongeFindNearestAttackableTargetGoalBuilder.ALWAYS_TRUE : this.predicate);
this.checkSight, this.checkOnlyNearby, this.predicate == null ? SpongeFindNearestAttackableTargetGoalBuilder.ALWAYS_TRUE : (e, l) -> ((Predicate) this.predicate).test(l));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public static DestructEntityEvent.Death callDestructEntityEventDeath(final Livin

final DestructEntityEvent.Death event = SpongeEventFactory.createDestructEntityEventDeath(frame.currentCause(),
originalChannel, Optional.of(originalChannel), originalMessage, originalMessage, (Living) entity,
entity.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY), messageCancelled);
((ServerLevel) entity.level()).getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY), messageCancelled);
SpongeCommon.post(event);

return event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.spongepowered.api.util.Tuple;
import org.spongepowered.api.world.BlockChangeFlag;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.server.ServerWorld;
import org.spongepowered.common.block.SpongeBlockSnapshot;
import org.spongepowered.common.bridge.server.TickTaskBridge;
import org.spongepowered.common.bridge.server.level.ServerLevelBridge;
Expand Down Expand Up @@ -160,12 +161,14 @@ default boolean isInteraction() {
/**
* Performs any necessary custom logic after the provided {@link BlockSnapshot}
* {@link Transaction} has taken place.
* @param context The context for information
*
* @param context The context for information
* @param serverWorld
* @param blockChange The block change performed
* @param receipt The transaction of the old and new snapshots
* @param receipt The transaction of the old and new snapshots
*/
default void postBlockTransactionApplication(
final C context, final BlockChange blockChange,
final C context, ServerWorld serverWorld, final BlockChange blockChange,
final BlockTransactionReceipt receipt
) { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.spongepowered.api.item.inventory.transaction.SlotTransaction;
import org.spongepowered.api.util.Tuple;
import org.spongepowered.api.world.BlockChangeFlag;
import org.spongepowered.api.world.server.ServerWorld;
import org.spongepowered.common.block.SpongeBlockSnapshot;
import org.spongepowered.common.bridge.server.TickTaskBridge;
import org.spongepowered.common.bridge.world.TrackedWorldBridge;
Expand Down Expand Up @@ -102,11 +103,13 @@ default boolean isInteraction() {
/**
* Performs any necessary custom logic after the provided {@link BlockSnapshot}
* {@link Transaction} has taken place.
* @param blockChange The block change performed
* @param receipt The transaction of the old and new snapshots
*
* @param serverWorld
* @param blockChange The block change performed
* @param receipt The transaction of the old and new snapshots
*/
default void postBlockTransactionApplication(final BlockChange blockChange, final BlockTransactionReceipt receipt) {
this.getState().postBlockTransactionApplication(this.asContext(), blockChange, receipt);
default void postBlockTransactionApplication(ServerWorld serverWorld, final BlockChange blockChange, final BlockTransactionReceipt receipt) {
this.getState().postBlockTransactionApplication(this.asContext(), serverWorld, blockChange, receipt);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void consumeEventsAndMarker(

eventsByWorld.asMap().forEach((key, events) -> {
final Optional<ServerWorld> serverWorld = ((SpongeServer) SpongeCommon.server()).worldManager().world(key);
if (!serverWorld.isPresent()) {
if (serverWorld.isEmpty()) {
return;
}

Expand All @@ -85,7 +85,7 @@ protected void consumeEventsAndMarker(
final Operation operation = context.getBlockOperation(original, result);
final BlockTransactionReceipt eventTransaction = new BlockTransactionReceipt(original, result, operation);
transactions.add(eventTransaction);
context.postBlockTransactionApplication(original.blockChange, eventTransaction);
context.postBlockTransactionApplication(serverWorld.get(), original.blockChange, eventTransaction);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.spongepowered.api.event.CauseStackManager;
import org.spongepowered.api.event.cause.entity.SpawnType;
import org.spongepowered.api.event.cause.entity.SpawnTypes;
import org.spongepowered.api.world.server.ServerWorld;
import org.spongepowered.common.bridge.world.level.chunk.LevelChunkBridge;
import org.spongepowered.common.entity.PlayerTracker;
import org.spongepowered.common.event.tracking.PhaseTracker;
Expand Down Expand Up @@ -66,7 +67,7 @@ public BiConsumer<CauseStackManager.StackFrame, CommandPhaseContext> getFrameMod

@Override
public void postBlockTransactionApplication(
final CommandPhaseContext context, final BlockChange blockChange,
final CommandPhaseContext context, ServerWorld serverWorld, final BlockChange blockChange,
final BlockTransactionReceipt transaction
) {
// We want to investigate if there is a user on the cause stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.spongepowered.api.event.cause.entity.SpawnTypes;
import org.spongepowered.api.event.entity.SpawnEntityEvent;
import org.spongepowered.api.util.Tuple;
import org.spongepowered.api.world.server.ServerWorld;
import org.spongepowered.common.event.tracking.PhaseTracker;
import org.spongepowered.common.event.tracking.TrackingUtil;
import org.spongepowered.common.event.tracking.context.transaction.GameTransaction;
Expand Down Expand Up @@ -69,7 +70,7 @@ public BiConsumer<CauseStackManager.StackFrame, PlayerCommandPhaseContext> getFr

@Override
public void postBlockTransactionApplication(
final PlayerCommandPhaseContext context, final BlockChange blockChange,
final PlayerCommandPhaseContext context, ServerWorld serverWorld, final BlockChange blockChange,
final BlockTransactionReceipt transaction
) {
// We want to investigate if there is a user on the cause stack
Expand Down
Loading

0 comments on commit dac0c11

Please sign in to comment.