fixups from errorprone
This commit is contained in:
1 parent
c6d48ab485
commit
e7671bd022
52 files changed
+473
-588
No files matched your search
@@ -49,11 +49,11 @@ public abstract class Explosion_scarpetEventMixin
|
||||
}
|
||||
|
||||
@Inject(method = "explode", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerExplosion;hurtEntities()V", shift = At.Shift.AFTER))
|
||||
private void onExplosionDone(CallbackInfoReturnable<Integer> cir, List list)
|
||||
private void onExplosionDone(CallbackInfoReturnable<Integer> cir, List toBlow)
|
||||
{
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !level.isClientSide())
|
||||
{
|
||||
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getIndirectSourceEntity, center, radius, fire, list, affectedEntities, blockInteraction);
|
||||
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getIndirectSourceEntity, center, radius, fire, toBlow, affectedEntities, blockInteraction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,21 +18,28 @@ public abstract class Inventory_scarpetEventMixin
|
||||
{
|
||||
@Shadow @Final public Player player;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
public static int NOT_FOUND_INDEX;
|
||||
|
||||
@Shadow
|
||||
public abstract boolean add(int slot, ItemStack itemStack);
|
||||
|
||||
@Redirect(method = "add(Lnet/minecraft/world/item/ItemStack;)Z", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/entity/player/Inventory;add(ILnet/minecraft/world/item/ItemStack;)Z"
|
||||
))
|
||||
private boolean onItemAcquired(Inventory playerInventory, int slot, ItemStack stack)
|
||||
private boolean onItemAcquired(Inventory playerInventory, int slot, ItemStack itemStack)
|
||||
{
|
||||
if (!PLAYER_PICKS_UP_ITEM.isNeeded() || !(player instanceof ServerPlayer))
|
||||
return playerInventory.add(-1, stack);
|
||||
int count = stack.getCount();
|
||||
ItemStack previous = stack.copy();
|
||||
boolean res = playerInventory.add(-1, stack);
|
||||
if (count != stack.getCount()) // res returns false for larger item adding to a almost full ineventory
|
||||
if (!PLAYER_PICKS_UP_ITEM.isNeeded() || !(player instanceof final ServerPlayer serverPlayer))
|
||||
return add(NOT_FOUND_INDEX, itemStack);
|
||||
int count = itemStack.getCount();
|
||||
ItemStack prevStack = itemStack.copy();
|
||||
boolean res = add(NOT_FOUND_INDEX, itemStack);
|
||||
if (count != itemStack.getCount()) // res returns false for larger item adding to a almost full ineventory
|
||||
{
|
||||
ItemStack diffStack = previous.copyWithCount(count - stack.getCount());
|
||||
PLAYER_PICKS_UP_ITEM.onItemAction((ServerPlayer) player, null, diffStack);
|
||||
ItemStack diffStack = prevStack.copyWithCount(count - itemStack.getCount());
|
||||
PLAYER_PICKS_UP_ITEM.onItemAction(serverPlayer, null, diffStack);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class PersistentEntitySectionManager_scarpetMixin
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetScriptServer.LOG.error("Failed to handle entity type " + entity.getType().getDescriptionId());
|
||||
CarpetScriptServer.LOG.error("Failed to handle entity type {}", entity.getType().getDescriptionId());
|
||||
}
|
||||
|
||||
event = CarpetEventServer.Event.ENTITY_LOAD.get(entity.getType());
|
||||
@@ -43,7 +43,7 @@ public class PersistentEntitySectionManager_scarpetMixin
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetScriptServer.LOG.error("Failed to handle entity type " + entity.getType().getDescriptionId());
|
||||
CarpetScriptServer.LOG.error("Failed to handle entity type {}", entity.getType().getDescriptionId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -152,28 +152,29 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
|
||||
{
|
||||
if (PLAYER_RELEASED_ITEM.isNeeded())
|
||||
{
|
||||
InteractionHand hand = serverPlayerEntity.getUsedItemHand();
|
||||
ItemStack stack = serverPlayerEntity.getUseItem().copy();
|
||||
serverPlayerEntity.releaseUsingItem();
|
||||
InteractionHand hand = player.getUsedItemHand();
|
||||
ItemStack stack = player.getUseItem().copy();
|
||||
player.releaseUsingItem();
|
||||
PLAYER_RELEASED_ITEM.onItemAction(player, hand, stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
serverPlayerEntity.releaseUsingItem();
|
||||
player.releaseUsingItem();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "handleUseItemOn", cancellable = true, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayerGameMode;useItemOn(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;"
|
||||
target = "Lnet/minecraft/server/level/ServerPlayerGameMode;useItemOn(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void onBlockInteracted(ServerboundUseItemOnPacket playerInteractBlockC2SPacket_1, CallbackInfo ci)
|
||||
private void onBlockInteracted(ServerboundUseItemOnPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (PLAYER_RIGHT_CLICKS_BLOCK.isNeeded())
|
||||
{
|
||||
InteractionHand hand = playerInteractBlockC2SPacket_1.hand();
|
||||
BlockHitResult hitRes = playerInteractBlockC2SPacket_1.hitResult();
|
||||
if(PLAYER_RIGHT_CLICKS_BLOCK.onBlockHit(player, hand, hitRes)) {
|
||||
InteractionHand handd = packet.hand();
|
||||
BlockHitResult hitRes = packet.hitResult();
|
||||
if(PLAYER_RIGHT_CLICKS_BLOCK.onBlockHit(player, handd, hitRes)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -183,11 +184,11 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;resetLastActionTime()V"
|
||||
))
|
||||
private void onItemClicked(ServerboundUseItemPacket playerInteractItemC2SPacket_1, CallbackInfo ci)
|
||||
private void onItemClicked(ServerboundUseItemPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (PLAYER_USES_ITEM.isNeeded())
|
||||
{
|
||||
InteractionHand hand = playerInteractItemC2SPacket_1.hand();
|
||||
InteractionHand hand = packet.hand();
|
||||
if(PLAYER_USES_ITEM.onItemAction(player, hand, player.getItemInHand(hand).copy())) {
|
||||
ci.cancel();
|
||||
}
|
||||
@@ -283,10 +284,10 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
|
||||
@Inject(method = "lambda$handleChatCommand$0", // lambda of handleChatCommand(ServerboundChatCommandPacket)
|
||||
at = @At(value = "HEAD")
|
||||
)
|
||||
private void onChatCommandMessage(ServerboundChatCommandPacket serverboundChatCommandPacket, CallbackInfo ci) {
|
||||
private void onChatCommandMessage(ServerboundChatCommandPacket packet, CallbackInfo ci) {
|
||||
if (PLAYER_COMMAND.isNeeded())
|
||||
{
|
||||
PLAYER_COMMAND.onPlayerMessage(player, serverboundChatCommandPacket.command());
|
||||
PLAYER_COMMAND.onPlayerMessage(player, packet.command());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,10 +69,10 @@ public abstract class ServerLevel_scarpetMixin extends Level
|
||||
}
|
||||
|
||||
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
|
||||
private void handleExplosion(Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionDamageCalculator, double x, double y, double z, float g, boolean bl, ExplosionInteraction explosionInteraction, ParticleOptions particleOptions, ParticleOptions particleOptions2, WeightedList<ExplosionParticleInfo> weightedList, Holder<SoundEvent> holder, CallbackInfo ci)
|
||||
private void handleExplosion(Entity source, DamageSource damageSource, ExplosionDamageCalculator damageCalculator, double x, double y, double z, float r, boolean fire, ExplosionInteraction interactionType, ParticleOptions smallExplosionParticles, ParticleOptions largeExplosionParticles, WeightedList<ExplosionParticleInfo> blockParticles, Holder<SoundEvent> explosionSound, CallbackInfo ci)
|
||||
{
|
||||
if (EXPLOSION.isNeeded()) {
|
||||
Explosion.BlockInteraction var10000 = switch (explosionInteraction) {
|
||||
Explosion.BlockInteraction var10000 = switch (interactionType) {
|
||||
case NONE -> Explosion.BlockInteraction.KEEP;
|
||||
case BLOCK -> this.getCMDestroyType(GameRules.BLOCK_EXPLOSION_DROP_DECAY);
|
||||
case MOB -> this.getGameRules().get(GameRules.MOB_GRIEFING) ? this.getCMDestroyType(GameRules.MOB_EXPLOSION_DROP_DECAY) : Explosion.BlockInteraction.KEEP;
|
||||
@@ -80,7 +80,7 @@ public abstract class ServerLevel_scarpetMixin extends Level
|
||||
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
|
||||
};
|
||||
|
||||
boolean cancelled = EXPLOSION.onExplosion((ServerLevel) (Object) this, entity, null, new Vec3(x, y, z), g, bl, null, null, var10000);
|
||||
boolean cancelled = EXPLOSION.onExplosion((ServerLevel) (Object) this, source, null, new Vec3(x, y, z), r, fire, null, null, var10000);
|
||||
if (cancelled) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user