-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
274 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/org/mesdag/advjs/mixin/AbstractBlock$AbstractBlockStateMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.mesdag.advjs.mixin; | ||
|
||
import net.minecraft.block.AbstractBlock; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.hit.BlockHitResult; | ||
import net.minecraft.world.World; | ||
import org.mesdag.advjs.util.AdvHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import static org.mesdag.advjs.util.Data.LOCK_BLOCK_INTERACT; | ||
|
||
@Mixin(AbstractBlock.AbstractBlockState.class) | ||
public abstract class AbstractBlock$AbstractBlockStateMixin { | ||
@Shadow public abstract Block getBlock(); | ||
|
||
@Inject(method = "onUse", at = @At("HEAD"), cancellable = true) | ||
private void advJS$pass(World world, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) { | ||
if (world.isClient) return; | ||
if (!AdvHelper.advDone((ServerPlayerEntity) player, LOCK_BLOCK_INTERACT.get(getBlock()))) cir.setReturnValue(ActionResult.PASS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.mesdag.advjs.mixin; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.ItemUsageContext; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.TypedActionResult; | ||
import net.minecraft.world.World; | ||
import org.mesdag.advjs.util.AdvHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import static org.mesdag.advjs.util.Data.LOCK_ITEM_USE; | ||
|
||
@Mixin(ItemStack.class) | ||
public abstract class ItemStackMixin { | ||
@Shadow | ||
public abstract Item getItem(); | ||
|
||
@Inject( | ||
method = "useOnBlock", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemUsageContext;getBlockPos()Lnet/minecraft/util/math/BlockPos;"), | ||
locals = LocalCapture.CAPTURE_FAILSOFT, | ||
cancellable = true) | ||
private void advJS$useOn(ItemUsageContext context, CallbackInfoReturnable<ActionResult> cir, PlayerEntity player) { | ||
if (player instanceof ServerPlayerEntity serverPlayer && !AdvHelper.advDone(serverPlayer, LOCK_ITEM_USE.get(getItem()))) { | ||
cir.setReturnValue(ActionResult.PASS); | ||
} | ||
} | ||
|
||
@Inject(method = "use", at = @At("HEAD"), cancellable = true) | ||
private void advJS$use(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) { | ||
if (world.isClient) { | ||
if (AdvHelper.clientAdvDone(LOCK_ITEM_USE.get(getItem()))) return; | ||
} else if (AdvHelper.advDone((ServerPlayerEntity) user, LOCK_ITEM_USE.get(getItem()))) { | ||
return; | ||
} | ||
cir.setReturnValue(TypedActionResult.pass((ItemStack) (Object) this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/org/mesdag/advjs/mixin/client/ClientAdvancementsAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.mesdag.advjs.mixin.client; | ||
|
||
import net.minecraft.advancement.Advancement; | ||
import net.minecraft.advancement.AdvancementProgress; | ||
import net.minecraft.client.network.ClientAdvancementManager; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
import java.util.Map; | ||
|
||
@Mixin(ClientAdvancementManager.class) | ||
public interface ClientAdvancementsAccessor { | ||
@Accessor | ||
Map<Advancement, AdvancementProgress> getAdvancementProgresses(); | ||
} |
Oops, something went wrong.