diff --git a/src/accessors/java/org/spongepowered/common/MixinTargetHelper.java b/src/accessors/java/org/spongepowered/common/MixinTargetHelper.java deleted file mode 100644 index 92625941b74..00000000000 --- a/src/accessors/java/org/spongepowered/common/MixinTargetHelper.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.common; - -import org.checkerframework.checker.nullness.qual.NonNull; - -public class MixinTargetHelper { - - @SuppressWarnings("unchecked") - public static @NonNull Target cast(@NonNull final Origin o) { - return (Target) (Object) o; - } -} diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/CampfireBlockEntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/CampfireBlockEntityMixin.java index 0447f14ca14..c4b932bcfce 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/CampfireBlockEntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/level/block/entity/CampfireBlockEntityMixin.java @@ -50,7 +50,6 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.spongepowered.common.MixinTargetHelper; import org.spongepowered.common.SpongeCommon; import org.spongepowered.common.bridge.world.level.block.entity.CampfireBlockEntityBridge; import org.spongepowered.common.event.tracking.PhaseTracker; @@ -79,18 +78,18 @@ public abstract class CampfireBlockEntityMixin implements CampfireBlockEntityBri at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/entity/CampfireBlockEntity;cookingProgress:[I", ordinal = 1)) private static void impl$canCook(final Level level, final BlockPos pos, final BlockState state, final CampfireBlockEntity self, final CallbackInfo ci, final boolean hasChanged, final int i, final ItemStack itemStack) { - ((CampfireBlockEntityMixin) (Object) self).impl$currentIndex = i; + final CampfireBlockEntityMixin mixinSelf = (CampfireBlockEntityMixin) (Object) self; + mixinSelf.impl$currentIndex = i; final boolean isEmpty = itemStack.isEmpty(); if (!isEmpty) { final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); - final CampfireBlockEntityMixin mixinSelf = MixinTargetHelper.cast(self); final ItemStackSnapshot stack = ItemStackUtil.snapshotOf(mixinSelf.items.get(i)); final RecipeHolder recipe = mixinSelf.impl$cookingRecipe[i]; final CookingEvent.Tick event = SpongeEventFactory.createCookingEventTick(cause, (Campfire) self, stack, Optional.empty(), Optional.ofNullable(recipe).map(r -> (CookingRecipe) r.value()), Optional.ofNullable(recipe).map(r -> (ResourceKey) (Object) r.id())); SpongeCommon.post(event); if (event.isCancelled()) { - ((CampfireBlockEntityMixin) (Object) self).cookingProgress[i]--; + mixinSelf.cookingProgress[i]--; } } @@ -102,7 +101,7 @@ public abstract class CampfireBlockEntityMixin implements CampfireBlockEntityBri final CampfireBlockEntity self, final CallbackInfo ci, final boolean hasChanged, final int i, final ItemStack itemStack, final SingleRecipeInput recipeInput, final ItemStack itemStack1) { final Cause cause = PhaseTracker.getCauseStackManager().currentCause(); - final CampfireBlockEntityMixin mixinSelf = MixinTargetHelper.cast(self); + final CampfireBlockEntityMixin mixinSelf = (CampfireBlockEntityMixin) (Object) self; final SlotTransaction transaction = new SlotTransaction(((Campfire) self).inventory().slot(i).get(), ItemStackUtil.snapshotOf(itemStack1), ItemStackSnapshot.empty()); final RecipeHolder recipe = mixinSelf.impl$cookingRecipe[i]; final CookingEvent.Finish event = SpongeEventFactory.createCookingEventFinish(cause, (Campfire) self, @@ -114,8 +113,8 @@ public abstract class CampfireBlockEntityMixin implements CampfireBlockEntityBri } @Inject(method = "cookTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;sendBlockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;I)V")) - private static void impl$setCookingEventFinishResult(final Level $$0, final BlockPos $$1, final BlockState $$2, final CampfireBlockEntity $$3, final CallbackInfo ci) { - final CampfireBlockEntityMixin mixinSelf = MixinTargetHelper.cast($$3); + private static void impl$setCookingEventFinishResult(final Level level, final BlockPos pos, final BlockState state, final CampfireBlockEntity entity, final CallbackInfo ci) { + final CampfireBlockEntityMixin mixinSelf = (CampfireBlockEntityMixin) (Object) entity; mixinSelf.impl$pendingSlotTransaction.custom().ifPresent(item -> mixinSelf.items.set(((SlotAdapter) mixinSelf.impl$pendingSlotTransaction.slot()).getOrdinal(), ItemStackUtil.fromSnapshotToNative(item))); mixinSelf.impl$pendingSlotTransaction = null;