Skip to content

Commit

Permalink
Fix respawn copy strategies not working on players
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed May 23, 2024
1 parent a98d8c8 commit f3763cc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static <C extends Component> RespawnCopyStrategy<? super C> getRespawnCop
@Nullable RespawnCopyStrategy<?> strat = null;
Class<?> c = entityClass;
while (strat == null && LivingEntity.class.isAssignableFrom(c)) {
strat = respawnCopyStrategies.getOrDefault(type, Map.of()).get(entityClass);
strat = respawnCopyStrategies.getOrDefault(type, Map.of()).get(c);
c = c.getSuperclass();
}
return strat == null ? DEFAULT_COPY_STRATEGY : (RespawnCopyStrategy<? super C>) strat;
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Updated to 1.20.5/1.20.6

This update introduces multiple breaking changes - a migration guide is available on [the Ladysnake website](https://ladysnake.org/wiki/cardinal-components-api/upgrade-instructions/CCA-6-changes).

### Release Candidate 1
**Fixes**
- Fixed respawn copy strategies not being correctly registered for player entities

### Pre-Release 3
**Fixes**
- Missing components (usually caused by removed mods) will no longer trigger a wall of warnings
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fabric_api_version=0.98.0+1.20.6
elmendorf_version=0.12.0-SNAPSHOT

#Publishing
mod_version = 6.0.0-pre3
mod_version = 6.0.0-rc1
curseforge_id = 318449
modrinth_id = K01OU20C
curseforge_versions = 1.20.5; 1.20.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.passive.CowEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import org.ladysnake.cca.api.v3.block.BlockComponentFactoryRegistry;
import org.ladysnake.cca.api.v3.block.BlockComponentInitializer;
import org.ladysnake.cca.api.v3.component.ComponentKey;
import org.ladysnake.cca.api.v3.component.ComponentRegistryV3;
import org.ladysnake.cca.api.v3.entity.EntityComponentFactoryRegistry;
import org.ladysnake.cca.api.v3.entity.EntityComponentInitializer;
import org.ladysnake.cca.api.v3.entity.RespawnCopyStrategy;
import org.ladysnake.cca.api.v3.item.ItemComponentInitializer;
import org.ladysnake.cca.api.v3.item.ItemComponentMigrationRegistry;
import org.ladysnake.cca.api.v3.scoreboard.ScoreboardComponentFactoryRegistry;
Expand All @@ -58,6 +60,7 @@ public final class TestComponents implements
@Override
public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
registry.beginRegistration(HostileEntity.class, ALT_VITA).after(Vita.KEY).end(e -> new BaseVita());
registry.beginRegistration(PlayerEntity.class, ALT_VITA).after(Vita.KEY).respawnStrategy(RespawnCopyStrategy.ALWAYS_COPY).end(e -> new BaseVita());
registry.registerFor(VitalityZombieEntity.class, Vita.KEY, VitalityZombieEntity::createVitaComponent);
registry.beginRegistration(LivingEntity.class, ALT_VITA).filter(CowEntity.class::isAssignableFrom).end(CcaEntityTestMod::createForEntity);
}
Expand Down

0 comments on commit f3763cc

Please sign in to comment.