Fixed various Bugs

This commit is contained in:
Tschipp 2025-07-26 00:39:32 +02:00
parent 1194370405
commit 0dec5bb175
4 changed files with 19 additions and 7 deletions

View File

@ -118,11 +118,6 @@ public class CarryOnCommon
player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd); player.getServer().getCommands().performPrefixedCommand(player.getServer().createCommandSourceStack(), "/execute as " + player.getGameProfile().getName() + " run " + cmd);
} }
if (!Constants.COMMON_CONFIG.settings.slownessInCreative && player.isCreative())
return;
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 1, potionLevel(carry, player.level()), false, false));
Inventory inv = player.getInventory(); Inventory inv = player.getInventory();
inv.setSelectedSlot(carry.getSelected()); inv.setSelectedSlot(carry.getSelected());
} }
@ -180,7 +175,7 @@ public class CarryOnCommon
} }
private static int potionLevel(CarryOnData carry, Level level) public static int potionLevel(CarryOnData carry, Level level)
{ {
if(carry.isCarrying(CarryType.PLAYER)) if(carry.isCarrying(CarryType.PLAYER))
return 1; return 1;

View File

@ -26,6 +26,8 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.Entity.RemovalReason;
@ -38,6 +40,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import tschipp.carryon.CarryOnCommon;
import tschipp.carryon.Constants; import tschipp.carryon.Constants;
import tschipp.carryon.common.config.ListHandler; import tschipp.carryon.common.config.ListHandler;
import tschipp.carryon.common.pickupcondition.PickupCondition; import tschipp.carryon.common.pickupcondition.PickupCondition;
@ -145,6 +148,8 @@ public class PickupHandler {
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
level.playSound(null, pos, state.getSoundType().getHitSound(), SoundSource.BLOCKS, 1.0f, 0.5f); level.playSound(null, pos, state.getSoundType().getHitSound(), SoundSource.BLOCKS, 1.0f, 0.5f);
player.swing(InteractionHand.MAIN_HAND, true); player.swing(InteractionHand.MAIN_HAND, true);
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 1000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
return true; return true;
} }
@ -231,6 +236,8 @@ public class PickupHandler {
player.swing(InteractionHand.MAIN_HAND, true); player.swing(InteractionHand.MAIN_HAND, true);
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f); player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 1000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
return true; return true;
} }
@ -254,6 +261,8 @@ public class PickupHandler {
player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f); player.level().playSound(null, player.getOnPos(), SoundEvents.ARMOR_EQUIP_GENERIC.value(), SoundSource.AMBIENT, 1.0f, 0.5f);
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
player.swing(InteractionHand.MAIN_HAND, true); player.swing(InteractionHand.MAIN_HAND, true);
if (!player.isCreative() || Constants.COMMON_CONFIG.settings.slownessInCreative)
player.addEffect(new MobEffectInstance(MobEffects.SLOWNESS, 1000000, CarryOnCommon.potionLevel(carry, player.level()), false, false));
return true; return true;
} }

View File

@ -27,6 +27,8 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.animal.horse.Horse; import net.minecraft.world.entity.animal.horse.Horse;
@ -42,6 +44,7 @@ import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import tschipp.carryon.CarryOnCommon;
import tschipp.carryon.Constants; import tschipp.carryon.Constants;
import tschipp.carryon.common.carry.CarryOnData.CarryType; import tschipp.carryon.common.carry.CarryOnData.CarryType;
import tschipp.carryon.common.config.ListHandler; import tschipp.carryon.common.config.ListHandler;
@ -111,6 +114,7 @@ public class PlacementHandler
player.playSound(state.getSoundType().getPlaceSound(), 1.0f, 0.5f); player.playSound(state.getSoundType().getPlaceSound(), 1.0f, 0.5f);
level.playSound(null, pos, state.getSoundType().getPlaceSound(), SoundSource.BLOCKS, 1.0f, 0.5f); level.playSound(null, pos, state.getSoundType().getPlaceSound(), SoundSource.BLOCKS, 1.0f, 0.5f);
player.swing(InteractionHand.MAIN_HAND, true); player.swing(InteractionHand.MAIN_HAND, true);
player.removeEffect(MobEffects.SLOWNESS);
return true; return true;
} }
@ -180,6 +184,7 @@ public class PlacementHandler
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
otherPlayer.teleportTo(placementPos.x, placementPos.y, placementPos.z); otherPlayer.teleportTo(placementPos.x, placementPos.y, placementPos.z);
player.swing(InteractionHand.MAIN_HAND, true); player.swing(InteractionHand.MAIN_HAND, true);
player.removeEffect(MobEffects.SLOWNESS);
return true; return true;
} }
@ -204,6 +209,7 @@ public class PlacementHandler
player.swing(InteractionHand.MAIN_HAND, true); player.swing(InteractionHand.MAIN_HAND, true);
carry.clear(); carry.clear();
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
player.removeEffect(MobEffects.SLOWNESS);
return true; return true;
} }
@ -271,6 +277,7 @@ public class PlacementHandler
carry.clear(); carry.clear();
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundSource.PLAYERS, 0.5F, 1.5F); level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.HORSE_SADDLE, SoundSource.PLAYERS, 0.5F, 1.5F);
player.removeEffect(MobEffects.SLOWNESS);
} else { } else {
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.LAVA_POP, SoundSource.PLAYERS, 0.5F, 0.5F); level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.LAVA_POP, SoundSource.PLAYERS, 0.5F, 0.5F);
} }
@ -314,6 +321,7 @@ public class PlacementHandler
} }
carry.clear(); carry.clear();
CarryOnDataManager.setCarryData(player, carry); CarryOnDataManager.setCarryData(player, carry);
player.removeEffect(MobEffects.SLOWNESS);
} }
private static BlockPos getDeathPlacementPos(BlockState state, ServerPlayer player) private static BlockPos getDeathPlacementPos(BlockState state, ServerPlayer player)

View File

@ -51,7 +51,7 @@ public class HumanoidModelMixin {
if(state instanceof ICarryOnRenderState carryOnRenderState && Constants.CLIENT_CONFIG.renderArms) if(state instanceof ICarryOnRenderState carryOnRenderState && Constants.CLIENT_CONFIG.renderArms)
{ {
CarryOnData carry = carryOnRenderState.getCarryOnData(); CarryOnData carry = carryOnRenderState.getCarryOnData();
if(carry.isCarrying() && !state.isVisuallySwimming && !state.isFallFlying) if(carry != null && carry.isCarrying() && !state.isVisuallySwimming && !state.isFallFlying)
{ {
boolean sneaking = state.isCrouching; boolean sneaking = state.isCrouching;