Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-1.20-lts' into master-1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jun 21, 2024
2 parents efa0820 + 56e2703 commit 8c05380
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 11 deletions.
7 changes: 7 additions & 0 deletions resources/changelog/1.19.2-1.2.31.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.17.0 or higher.

Fixes:
* Fix item IO side mapping of Colossal Blood Chest, Closes #1025
* Catch exceptions when getting vengeance spirit sounds, Closes #1023

6 changes: 6 additions & 0 deletions resources/changelog/1.19.2-1.2.32.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.17.0 or higher.

Fixes:
* Fix Effortless Ring step assist conflicting with other mods, Closes #1026

7 changes: 7 additions & 0 deletions resources/changelog/1.20.1-1.2.38.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.18.4 or higher.

Fixes:
* Fix item IO side mapping of Colossal Blood Chest, Closes #1025
* Catch exceptions when getting vengeance spirit sounds, Closes #1023

6 changes: 6 additions & 0 deletions resources/changelog/1.20.1-1.2.39.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.18.4 or higher.

Fixes:
* Fix Effortless Ring step assist conflicting with other mods, Closes #1026

Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void registerTankInventoryCapabilitiesItem() {
net.neoforged.neoforge.capabilities.Capabilities.ItemHandler.BLOCK,
(blockEntity, direction) -> new ItemHandlerSlotMasked(
blockEntity.getInventory(),
(direction == Direction.UP || direction == Direction.DOWN) ? IntStream.range(0, SLOTS_CHEST).toArray() : new int[]{SLOT_CONTAINER}
direction == Direction.DOWN ? new int[]{SLOTS_CHEST} : IntStream.range(0, SLOTS_CHEST + 1).toArray()
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,11 @@ public static EntityVengeanceSpirit spawnRandom(Level level, BlockPos blockPos,
@Override
public SoundEvent getDeathSound() {
if(getInnerEntity() != null) {
return getInnerEntity().getDeathSound();
try {
return getInnerEntity().getDeathSound();
} catch (RuntimeException e) {
// Catch crashes
}
}
return RegistryEntries.SOUNDEVENT_MOB_VENGEANCESPIRIT_DEATH.get();
}
Expand All @@ -677,7 +681,11 @@ public SoundEvent getDeathSound() {
public SoundEvent getAmbientSound() {
LivingEntity entity = getInnerEntity();
if(entity != null) {
return getInnerEntity().getAmbientSound();
try {
return getInnerEntity().getAmbientSound();
} catch (RuntimeException e) {
// Catch crashes
}
}
return RegistryEntries.SOUNDEVENT_MOB_VENGEANCESPIRIT_AMBIENT.get();
}
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/org/cyclops/evilcraft/item/ItemEffortlessRing.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.cyclops.evilcraft.item;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.common.NeoForgeMod;
import net.neoforged.neoforge.event.entity.living.LivingEvent;
import net.neoforged.neoforge.event.entity.living.LivingFallEvent;
import org.cyclops.cyclopscore.helper.ItemStackHelpers;
Expand All @@ -20,10 +23,9 @@
public class ItemEffortlessRing extends Item {

private static final int TICK_MODULUS = 1;
private static final String PLAYER_NBT_KEY = Reference.MOD_ID + ":" + "lastStepSize";

private static final float SPEED_BONUS = 0.05F;
private static final float STEP_SIZE = 1F;
private static final AttributeModifier STEP_SIZE_MODIFIER = new AttributeModifier(Reference.MOD_ID + ":stepHeightModifier", 1, AttributeModifier.Operation.ADDITION);
private static final float JUMP_DISTANCE_FACTOR = 0.05F;
private static final float JUMP_HEIGHT_FACTOR = 0.3F;
private static final float FALLDISTANCE_REDUCTION = 2F;
Expand All @@ -47,10 +49,10 @@ public void adjustParameters(ItemStack itemStack, Player player) {
}

// Step height
if(!player.getPersistentData().contains(PLAYER_NBT_KEY)) {
player.getPersistentData().putFloat(PLAYER_NBT_KEY, player.maxUpStep());
AttributeInstance attribute = player.getAttribute(NeoForgeMod.STEP_HEIGHT.value());
if (attribute != null && !attribute.hasModifier(STEP_SIZE_MODIFIER)) {
attribute.addTransientModifier(STEP_SIZE_MODIFIER);
}
player.setMaxUpStep(player.isCrouching() ? 0.5F : STEP_SIZE);

// Jump distance
// Not possible anymore due to hardcoded value in LivingEntity#getFrictionInfluencedSpeed
Expand All @@ -72,10 +74,10 @@ public void onPlayerUpdate(LivingEvent.LivingTickEvent event) {
// Reset the step height.
if(event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if(player.getPersistentData().contains(PLAYER_NBT_KEY)) {
AttributeInstance attribute = player.getAttribute(NeoForgeMod.STEP_HEIGHT.value());
if (attribute != null && attribute.hasModifier(STEP_SIZE_MODIFIER)) {
if (!ItemStackHelpers.hasPlayerItem(player, this)) {
player.setMaxUpStep(player.getPersistentData().getFloat(PLAYER_NBT_KEY));
player.getPersistentData().remove(PLAYER_NBT_KEY);
attribute.removeModifier(STEP_SIZE_MODIFIER.getId());
}
}
}
Expand Down

0 comments on commit 8c05380

Please sign in to comment.