Skip to content

Commit

Permalink
Merged 7.0.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz authored Feb 6, 2024
2 parents 75e8e7a + 6d795ab commit e8bdc83
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
- fixed compatibility crash with Chrysalis (reported by @Paxx3, @ZacGames)
- fixed random crashes when starting the game (reported by @Kazuya)
- fixed bug with spawn point features not working properly with Respawn Anchors
- fixed bug with item damage modifications not working properly (reported by @Camawama)
- fixed compatibility issue that caused 1 item to be taken from the stack when hitting mobs (reported by @Camawama)
- optimized spawn point features
18 changes: 8 additions & 10 deletions common/src/main/java/com/majruszlibrary/level/LevelHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,14 @@ public static boolean isMobGriefingEnabled( Level level ) {
public static Optional< SpawnPoint > getSpawnPoint( ServerPlayer player ) {
BlockPos respawnPosition = player.getRespawnPosition();
ServerLevel level = player.server.getLevel( player.getRespawnDimension() );
Vec3 position = null;
if( level == null ) {
return Optional.empty();
}

Vec3 position;
if( respawnPosition != null ) {
float angle = player.getRespawnAngle();
Optional< Vec3 > spawnPosition = Player.findRespawnPositionAndUseSpawnBlock( level, respawnPosition, angle, true, true );
if( spawnPosition.isPresent() ) {
position = spawnPosition.get();
}
}

if( position == null ) {
position = AnyPos.from( respawnPosition ).vec3();
} else {
level = player.server.getLevel( Level.OVERWORLD );
position = AnyPos.from( level.getSharedSpawnPos() ).vec3();
}
Expand Down Expand Up @@ -219,7 +213,11 @@ public SpawnPoint( ServerLevel level, Vec3 position ) {
}

public void teleport( ServerPlayer player ) {
player.teleportTo( this.level, this.position.x, this.position.y, this.position.z, player.getYRot(), player.getXRot() );
float angle = player.getRespawnAngle();
Optional< Vec3 > spawnPosition = Player.findRespawnPositionAndUseSpawnBlock( this.level, AnyPos.from( this.position ).block(), angle, true, true );
Vec3 position = spawnPosition.orElse( this.position );

player.teleportTo( this.level, position.x, position.y, position.z, player.getYRot(), player.getXRot() );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ public abstract class MixinItemStack {
)
private void hurt( int damage, RandomSource source, ServerPlayer player, CallbackInfoReturnable< Boolean > callback ) {
ItemStack itemStack = ( ItemStack )( Object )this;
itemStack.setDamageValue( itemStack.getDamageValue() + Events.dispatch( new OnItemDamaged( player, itemStack, damage ) ).getExtraDamage() );
if( !itemStack.isDamageableItem() ) {
return;
}

callback.setReturnValue( itemStack.getDamageValue() >= itemStack.getMaxDamage() );
int extraDamage = Events.dispatch( new OnItemDamaged( player, itemStack, damage ) ).getExtraDamage();
if( extraDamage != 0 ) {
itemStack.setDamageValue( itemStack.getDamageValue() + extraDamage );
callback.setReturnValue( itemStack.getDamageValue() >= itemStack.getMaxDamage() );
}
}

@Inject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public < Type > void register( RegistryObject< Type > object ) {
@Override
public void register( RegistryCallbacks callbacks ) {
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
eventBus.addListener( ( FMLCommonSetupEvent event )->{
eventBus.addListener( ( FMLCommonSetupEvent event )->event.enqueueWork( ()->{
callbacks.execute( Custom.Advancements.class, IMixinCriteriaTriggers::register );
callbacks.execute( Custom.PotionRecipe.class, new Custom.PotionRecipe() {
@Override
Expand All @@ -86,7 +86,7 @@ public ItemStack getOutput( ItemStack input, ItemStack ingredient ) {
} );
}
} );
} );
} ) );
eventBus.addListener( ( EntityAttributeCreationEvent event )->{
callbacks.execute( Custom.Attributes.class, event::put );
} );
Expand All @@ -102,11 +102,11 @@ public < Type extends Mob > void register( EntityType< Type > entityType, SpawnP
} );

Side.runOnClient( ()->()->{
eventBus.addListener( ( final FMLClientSetupEvent event )->{
eventBus.addListener( ( final FMLClientSetupEvent event )->event.enqueueWork( ()->{
callbacks.execute( Custom.ItemProperties.class, ItemProperties::register );
callbacks.execute( Custom.ModelLayers.class, ForgeHooksClient::registerLayerDefinition );
callbacks.execute( Custom.Renderers.class, EntityRenderers::register );
} );
} ) );
eventBus.addListener( ( final RegisterParticleProvidersEvent event )->{
callbacks.execute( Custom.Particles.class, new CustomParticles( event ) );
} );
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.20.1
# Mod
mod_id=majruszlibrary
mod_archives_name=majrusz-library
mod_version=7.0.4
mod_version=7.0.5
mod_display_name=Majrusz Library
mod_description=Library with common code for my other modifications.
mod_authors=Majrusz
Expand Down

0 comments on commit e8bdc83

Please sign in to comment.