Skip to content

Commit

Permalink
Remove MixinTargetHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Sep 30, 2024
1 parent a8b1529 commit ccad6b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
35 changes: 0 additions & 35 deletions src/accessors/java/org/spongepowered/common/MixinTargetHelper.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]--;
}
}

Expand All @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit ccad6b6

Please sign in to comment.