Skip to content

Commit

Permalink
feat: update to 24w37a
Browse files Browse the repository at this point in the history
  • Loading branch information
gabizou committed Sep 12, 2024
1 parent 4b9d701 commit ff7090a
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 40 deletions.
2 changes: 1 addition & 1 deletion SpongeAPI
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=24w36a
minecraftVersion=24w37a
recommendedVersion=0-SNAPSHOT

org.gradle.dependency.verification.console=verbose
Expand Down
19 changes: 19 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,17 @@
<sha256 value="6c77153dd0b0e8eff8f0bc66aefb1cd8bf66fb77cff46e3854cfa0b9d9bab50c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.mojang" name="jtracy" version="1.0.29">
<artifact name="jtracy-1.0.29-natives-macos.jar">
<sha256 value="9c48e08acc0f3de41c82cbb803ed8da349834682a52f8f24efde0b77ef8e4723" origin="Generated by Gradle"/>
</artifact>
<artifact name="jtracy-1.0.29.jar">
<sha256 value="017dfd1aa6f536cfcb8f643830f6f9f17028e8277417a4741a92c46e47424dda" origin="Generated by Gradle"/>
</artifact>
<artifact name="jtracy-1.0.29.module">
<sha256 value="e6eb75742fc530ca3dcb7b31abde166935e06814e85be77d6e0e93b1ffaf7935" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.mojang" name="logging" version="1.1.1">
<artifact name="logging-1.1.1.jar">
<sha256 value="c1756eaf0685da94142bacc84309bb7ccddf65e004638c3299ab645710b5938c" origin="Generated by Gradle"/>
Expand All @@ -1184,6 +1195,14 @@
<sha256 value="4c06f87d39b934a3cda64db22214d83bc0fcc7e420610545a87f3657f0014694" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.mojang" name="logging" version="1.3.8">
<artifact name="logging-1.3.8.jar">
<sha256 value="f26e4dfebbbcc62c5eac5d20ce1fa12847a6e048a94c185901c028546427bfb2" origin="Generated by Gradle"/>
</artifact>
<artifact name="logging-1.3.8.module">
<sha256 value="9f5250ef35c6e3cda137b4ed3a9241f4bc4392a4eb6568c50bbd23610ea08656" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.mojang" name="patchy" version="2.2.10">
<artifact name="patchy-2.2.10.jar">
<sha256 value="16d70e7968b45caffc81576268eb000f473fb60bf257182d3447dea8ec919d5a" origin="Generated by Gradle"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
import org.spongepowered.common.UntransformedInvokerError;

import java.util.Collection;
import java.util.List;

@Mixin(StateHolder.class)
public interface StateHolderAccessor {

@Invoker("findNextInCollection") static <T> T invoker$findNextInCollection(final Collection<T> collection, final T element) {
@Invoker("findNextInCollection") static <T> T invoker$findNextInCollection(final List<T> $$0, final T $$1) {
throw new UntransformedInvokerError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void register(final DataProviderRegistrator registrator) {
.get(h -> Color.ofRgb(((AreaEffectCloudAccessor) h).accessor$potionContents().getColor()))
.set((h, v) -> {
var contents = ((AreaEffectCloudAccessor) h).accessor$potionContents();
h.setPotionContents(new PotionContents(contents.potion(), Optional.of(v.rgb()), contents.customEffects()));
h.setPotionContents(new PotionContents(contents.potion(), Optional.of(v.rgb()), contents.customEffects(), contents.customName()));
})
.create(Keys.DURATION)
.get(x -> new SpongeTicks(x.getDuration()))
Expand Down Expand Up @@ -97,7 +97,7 @@ public static void register(final DataProviderRegistrator registrator) {
.get(h -> PotionEffectUtil.copyAsPotionEffects(Streams.stream(h.accessor$potionContents().getAllEffects()).toList()))
.set((h, v) -> {
final PotionContents contents = h.accessor$potionContents();
((AreaEffectCloud) h).setPotionContents(new PotionContents(contents.potion(), contents.customColor(), PotionEffectUtil.copyAsEffectInstances(v)));
((AreaEffectCloud) h).setPotionContents(new PotionContents(contents.potion(), contents.customColor(), PotionEffectUtil.copyAsEffectInstances(v), contents.customName()));
})
.create(Keys.REAPPLICATION_DELAY)
.get(h -> new SpongeTicks(h.accessor$reapplicationDelay()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void register(final DataProviderRegistrator registrator) {
.set((h, v) -> {
final PotionContents previousContents = ((ArrowAccessor) h).invoker$getPotionContents();
final List<MobEffectInstance> list = v.stream().map(effect -> ArrowData.clone((MobEffectInstance) effect)).toList();
((ArrowAccessor) h).invoker$setPotionContents(new PotionContents(previousContents.potion(), previousContents.customColor(), list));
((ArrowAccessor) h).invoker$setPotionContents(new PotionContents(previousContents.potion(), previousContents.customColor(), list, previousContents.customName()));
});
}
// @formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void register(final DataProviderRegistrator registrator) {
.get(h -> Streams.of(h.getItem().getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).getAllEffects()).map(PotionEffect.class::cast).toList())
.set((h, v) -> {
final var mcEffects = v.stream().map(MobEffectInstance.class::cast).toList();
h.getItem().update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), contents.customColor(), mcEffects));
h.getItem().update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), contents.customColor(), mcEffects, contents.customName()));
});
}
// @formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.util.StringUtil;
import net.minecraft.util.Unit;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageSources;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUseAnimation;
Expand All @@ -39,6 +44,7 @@
import net.minecraft.world.item.component.ChargedProjectiles;
import net.minecraft.world.item.component.Consumable;
import net.minecraft.world.item.component.CustomModelData;
import net.minecraft.world.item.component.DamageResistant;
import net.minecraft.world.item.component.ItemContainerContents;
import net.minecraft.world.item.component.ItemLore;
import net.minecraft.world.item.component.Unbreakable;
Expand All @@ -49,6 +55,7 @@
import net.minecraft.world.item.consume_effects.PlaySoundConsumeEffect;
import net.minecraft.world.item.consume_effects.RemoveStatusEffectsConsumeEffect;
import net.minecraft.world.item.consume_effects.TeleportRandomlyConsumeEffect;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.Platform;
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.item.ItemRarity;
Expand Down Expand Up @@ -244,18 +251,26 @@ public static void register(final DataProviderRegistrator registrator) {
})
.delete(stack -> stack.remove(DataComponents.CONTAINER))
.create(Keys.FIRE_RESISTANT)

This comment has been minimized.

Copy link
@gabizou

gabizou Sep 12, 2024

Author Member

We can likely change the key to now expose the damage resistance and use damage types to verify it.

.get(h -> h.get(DataComponents.FIRE_RESISTANT) != null)
.get(h -> {
final @Nullable DamageResistant resist = h.get(DataComponents.DAMAGE_RESISTANT);
if (resist == null) {
return false;
}
return resist.types().location().equals(DamageTypes.IN_FIRE.location());
})
.set((h, value) -> {
if (value) {
h.set(DataComponents.FIRE_RESISTANT, Unit.INSTANCE);
h.applyComponents(DataComponentPatch.builder()
.set(DataComponents.DAMAGE_RESISTANT, new DamageResistant(DamageTypeTags.IS_FIRE))
.build());
} else {
h.remove(DataComponents.FIRE_RESISTANT);
h.remove(DataComponents.DAMAGE_RESISTANT);
}
})
.delete(stack -> stack.remove(DataComponents.FIRE_RESISTANT))
.delete(stack -> stack.remove(DataComponents.DAMAGE_RESISTANT))
.create(Keys.ITEM_NAME)
.get(h -> {
final Component component = h.get(DataComponents.ITEM_NAME);
final @Nullable Component component = h.get(DataComponents.ITEM_NAME);
if (component == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public static void register(final DataProviderRegistrator registrator) {
.asMutable(ItemStack.class)
.create(Keys.COLOR)
.get(h -> Color.ofRgb(h.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).getColor()))
.set((h, v) -> h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), Optional.of(v.rgb()), contents.customEffects())))
.delete(h -> h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), Optional.empty(), contents.customEffects())))
.set((h, v) -> h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), Optional.of(v.rgb()), contents.customEffects(), contents.customName())))
.delete(h -> h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), Optional.empty(), contents.customEffects(), contents.customName())))
.supports(h -> h.getItem() == Items.POTION || h.getItem() == Items.SPLASH_POTION || h.getItem() == Items.LINGERING_POTION || h.getItem() == Items.TIPPED_ARROW)
.create(Keys.CUSTOM_POTION_EFFECTS)
.get(h -> {
Expand All @@ -66,17 +66,17 @@ public static void register(final DataProviderRegistrator registrator) {
})
.set((h, v) -> {
final var mcList = v.stream().map(MobEffectInstance.class::cast).toList();
h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), contents.customColor(), mcList));
h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), contents.customColor(), mcList, contents.customName()));
})
.delete(h -> h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), contents.customColor(), Collections.emptyList())))
.delete(h -> h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(contents.potion(), contents.customColor(), Collections.emptyList(), contents.customName())))
.supports(h -> h.getItem() == Items.POTION || h.getItem() == Items.SPLASH_POTION || h.getItem() == Items.LINGERING_POTION || h.getItem() == Items.TIPPED_ARROW)
.create(Keys.POTION_TYPE)
.get(h -> (PotionType) h.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion().map(Holder::value).orElse(null)) // TODO empty POTION gone?
.set((h, v) -> {
final var potion = Optional.ofNullable(v).map(Potion.class::cast).map(BuiltInRegistries.POTION::wrapAsHolder); // TODO set empty POTION? same as delete?
h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(potion, contents.customColor(), contents.customEffects()));
h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(potion, contents.customColor(), contents.customEffects(), contents.customName()));
})
.delete(h -> h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(Optional.empty(), contents.customColor(), contents.customEffects())))
.delete(h -> h.update(DataComponents.POTION_CONTENTS, PotionContents.EMPTY, contents -> new PotionContents(Optional.empty(), contents.customColor(), contents.customEffects(), contents.customName())))
.supports(h -> h.getItem() == Items.POTION || h.getItem() == Items.SPLASH_POTION ||
h.getItem() == Items.LINGERING_POTION || h.getItem() == Items.TIPPED_ARROW)
.create(Keys.POTION_EFFECTS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.lighting.LightEngine;
Expand Down Expand Up @@ -70,7 +72,9 @@ public EffectResult processSideEffect(
// )
// ) {
if (LightEngine.hasDifferentLightProperties(oldState.state(), currentState)) {
serverWorld.getProfiler().push("updateSkyLightSources");
ProfilerFiller filler = Profiler.get();

filler.push("updateSkyLightSources");
// this.skyLightSources.update(this, $$6, $$3, $$8);
final var pos = oldState.pos();
final var x = pos.getX() & 15;
Expand All @@ -81,11 +85,11 @@ public EffectResult processSideEffect(
levelChunk.getSkyLightSources().update(levelChunk, x, y, z);
// serverWorld.getChunkSource().update(this, $$6, $$3, $$8);
// this.profiler.startSection("queueCheckLight");
serverWorld.getProfiler().push("queueCheckLight");
filler.push("queueCheckLight");
// this.getChunkProvider().getLightManager().checkBlock(pos);
serverWorld.getChunkSource().getLightEngine().checkBlock(pos);
// this.profiler.endSection();
serverWorld.getProfiler().pop();
filler.pop();
}
return EffectResult.NULL_PASS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.spongepowered.asm.mixin.Shadow;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;

Expand All @@ -44,7 +45,7 @@ public abstract class PropertyMixin_API<T extends Comparable<T>> implements Stat

// @formatter:off
@Shadow public abstract Class<T> shadow$getValueClass();
@Shadow public abstract Collection<T> shadow$getPossibleValues();
@Shadow public abstract List<T> shadow$getPossibleValues();
@Shadow public abstract String shadow$getName();
// @formatter:on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,4 @@
@Mixin(Boat.Type.class)
public abstract class Boat_TypeMixin_API implements BoatType {

// @formatter:off
@Shadow @Final private Item planks;
// @formatter:on

@Override
public BlockType representedBlock() {
return (BlockType) ((BlockItem) this.planks).getBlock();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.util.Unit;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
Expand Down Expand Up @@ -475,18 +477,19 @@ public boolean teleportTo(final ServerLevel world,
oldLevel.removePlayerImmediately(thisPlayer, Entity.RemovalReason.CHANGED_DIMENSION);
this.shadow$unsetRemoved();

oldLevel.getProfiler().push("moving");
final ProfilerFiller filler = Profiler.get();
filler.push("moving");
if (oldLevel.dimension() == Level.OVERWORLD && newLevel.dimension() == Level.NETHER) {
this.enteredNetherPosition = thisPlayer.position();
}
oldLevel.getProfiler().pop();
filler.pop();

oldLevel.getProfiler().push("placing");
filler.push("placing");
thisPlayer.setServerLevel(newLevel);
this.connection.teleport(transition.position().x, transition.position().y, transition.position().z, transition.yRot(), transition.xRot());
this.connection.resetPosition();
newLevel.addDuringTeleport(thisPlayer);
oldLevel.getProfiler().pop();
filler.pop();

this.shadow$triggerDimensionChangeTriggers(oldLevel); // TODO old sponge EntityUtil#performPostChangePlayerWorldLogic this was only done when using a portal
this.connection.send(new ClientboundPlayerAbilitiesPacket(thisPlayer.getAbilities()));
Expand Down
Loading

0 comments on commit ff7090a

Please sign in to comment.