org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable Java Examples

The following examples show how to use org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractBlockStateMixin.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Inject(at = {@At("HEAD")},
	method = {
		"getOutlineShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;"},
	cancellable = true)
private void onGetOutlineShape(BlockView view, BlockPos pos,
	ShapeContext context, CallbackInfoReturnable<VoxelShape> cir)
{
	if(context == ShapeContext.absent())
		return;
	
	HackList hax = WurstClient.INSTANCE.getHax();
	if(hax == null)
		return;
	
	HandNoClipHack handNoClipHack = hax.handNoClipHack;
	if(!handNoClipHack.isEnabled() || handNoClipHack.isBlockInList(pos))
		return;
	
	cir.setReturnValue(VoxelShapes.empty());
}
 
Example #2
Source File: MixinPlayerControllerMP.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Inject(method = "processRightClick", cancellable = true, at = @At(value = "INVOKE",
        target = "Lnet/minecraft/client/multiplayer/PlayerControllerMP;syncCurrentPlayItem()V"))
private void onProcessRightClickPre(
        net.minecraft.entity.player.EntityPlayer player,
        net.minecraft.world.World world,
        net.minecraft.util.EnumHand hand,
        CallbackInfoReturnable<net.minecraft.util.EnumActionResult> cir)
{
    // Prevent recursion, since the Easy Place mode can call this code again
    if (EasyPlaceUtils.isHandling() == false)
    {
        if (EasyPlaceUtils.shouldDoEasyPlaceActions() &&
            EasyPlaceUtils.handleEasyPlaceWithMessage(this.mc))
        {
            cir.setReturnValue(net.minecraft.util.EnumActionResult.FAIL);
        }
    }
}
 
Example #3
Source File: MixinClientChunkManager.java    From multiconnect with MIT License 6 votes vote down vote up
@Inject(method = "loadChunkFromPacket", at = @At("RETURN"))
private void onLoadChunkFromPacket(int x, int z, BiomeArray biomes, PacketByteBuf buf, CompoundTag heightmaps, int verticalStripBitmask, boolean bl, CallbackInfoReturnable<WorldChunk> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) {
        if (ci.getReturnValue() != null) {
            synchronized (LOCK) {
                UpgradeData upgradeData = ChunkUpgrader.fixChunk(ci.getReturnValue());
                ((IUpgradableChunk) ci.getReturnValue()).multiconnect_setClientUpgradeData(upgradeData);
                for (int dx = -1; dx <= 1; dx++) {
                    for (int dz = -1; dz <= 1; dz++) {
                        WorldChunk chunk = getChunk(x + dx, z + dz, ChunkStatus.FULL, false);
                        if (chunk != null)
                            ((IUpgradableChunk) chunk).multiconnect_onNeighborLoaded();
                    }
                }
            }
        }
    }
}
 
Example #4
Source File: PlayerEntityMixin.java    From the-hallow with MIT License 6 votes vote down vote up
@Inject(at = @At(
	value = "INVOKE",
	target = "Lnet/minecraft/entity/player/HungerManager;eat(Lnet/minecraft/item/Item;Lnet/minecraft/item/ItemStack;)V",
	shift = At.Shift.AFTER
), method = "eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;")
private void addPumpkinRingBonus(World world, ItemStack itemStack, CallbackInfoReturnable<ItemStack> info) {
	PlayerEntity playerEntity = (PlayerEntity) (Object) this;
	TrinketComponent trinketPlayer = TrinketsApi.getTrinketComponent(playerEntity);
	
	ItemStack mainHandStack = trinketPlayer.getStack("hand:ring");
	ItemStack offHandStack = trinketPlayer.getStack("offhand:ring");
	Item item = itemStack.getItem();
	
	if (mainHandStack.getItem().equals(HallowedItems.PUMPKIN_RING) || offHandStack.getItem().equals(HallowedItems.PUMPKIN_RING)) {
		if (item.isFood()) {
			if (item.isIn(HallowedTags.Items.PUMPKIN_FOODS)) {
				FoodComponent foodComponent = item.getFoodComponent();
				int extraHunger = (int) Math.ceil(foodComponent.getHunger() * .25);
				this.hungerManager.add(extraHunger, 1);
			}
		}
	}
}
 
Example #5
Source File: MixinNetworkPlayerInfo.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Inject(method = "getSkinType", at = @At("RETURN"), cancellable = true)
private void getSkinType(CallbackInfoReturnable<String> type) {
    NickHider instance = NickHider.instance;

    if (instance != null && instance.getNickHiderConfig().isHideSkins() && instance.getNickHiderConfig().isMasterEnabled()) {
        NickHiderConfig config = instance.getNickHiderConfig();

        if (gameProfile.getId().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) {
            if (config.isUseRealSkinForSelf() && instance.getPlayerSkin() != null) {
                type.setReturnValue(instance.getPlayerRealSkinType());
            }
        } else if (config.isHideOtherSkins()) {
            if (config.isUsePlayerSkinForAll() && instance.getPlayerSkin() != null) {
                type.setReturnValue(instance.getPlayerRealSkinType());
            }
        }
    }
}
 
Example #6
Source File: MixinMinecraft.java    From VanillaFix with MIT License 6 votes vote down vote up
/** @reason Implement F3 + S to toggle between client and integrated server profilers. */
@Inject(method = "processKeyF3", at = @At("HEAD"), cancellable = true)
private void checkF3S(int auxKey, CallbackInfoReturnable<Boolean> cir) {
    if (auxKey == Keyboard.KEY_S) {
        if (integratedServer != null) {
            useIntegratedServerProfiler = !useIntegratedServerProfiler;
            if (useIntegratedServerProfiler) {
                debugFeedbackTranslated("vanillafix.debug.switch_profiler.server");
            } else {
                debugFeedbackTranslated("vanillafix.debug.switch_profiler.client");
            }
        }
        cir.setReturnValue(true);
        cir.cancel();
    }
}
 
Example #7
Source File: MixinNetworkPlayerInfo.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Inject(method = "getLocationSkin", at = @At("HEAD"), cancellable = true)
private void getLocationSkin(CallbackInfoReturnable<ResourceLocation> cir) {
    NickHider instance = NickHider.instance;

    if (instance != null && instance.getNickHiderConfig().isHideSkins() && instance.getNickHiderConfig().isMasterEnabled()) {
        NickHiderConfig config = instance.getNickHiderConfig();

        if (gameProfile.getId().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) {
            cir.setReturnValue(config.isUseRealSkinForSelf() && instance.getPlayerSkin() != null ? instance.getPlayerSkin() :
                DefaultPlayerSkin.getDefaultSkin(gameProfile.getId()));
        } else if (config.isHideOtherSkins()) {
            cir.setReturnValue(config.isUsePlayerSkinForAll() && instance.getPlayerSkin() != null ? instance.getPlayerSkin() :
                DefaultPlayerSkin.getDefaultSkin(gameProfile.getId()));
        }
    }
}
 
Example #8
Source File: MixinNetworkPlayerInfo.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "getLocationSkin", cancellable = true, at = @At("HEAD"))
private void injectSkinProtect(CallbackInfoReturnable<ResourceLocation> cir) {
    NameProtect nameProtect = (NameProtect) LiquidBounce.moduleManager.getModule(NameProtect.class);

    if (nameProtect.getState() && nameProtect.skinProtectValue.get()) {
        if (nameProtect.allPlayersValue.get() || Objects.equals(gameProfile.getId(), Minecraft.getMinecraft().getSession().getProfile().getId())) {
            cir.setReturnValue(DefaultPlayerSkin.getDefaultSkin(this.gameProfile.getId()));
            cir.cancel();
        }
    }

}
 
Example #9
Source File: MixinPropertyHelper.java    From VanillaFix with MIT License 5 votes vote down vote up
/**
 * Fix mods using duplicate property names.
 */
@Inject(method = "equals", at = @At("RETURN"), cancellable = true)
public void overrideEquals(Object obj, CallbackInfoReturnable<Boolean> cir) {
    if (cir.getReturnValue() && obj instanceof PropertyHelper) {
        if (!getClass().getName().startsWith("net.minecraft") && !getAllowedValues().equals(((PropertyHelper<?>) obj).getAllowedValues())) {
            cir.setReturnValue(false);
        }
    }
}
 
Example #10
Source File: PlayerEntity_antiCheatDisabled.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "method_23668", at = @At("HEAD"), cancellable = true)
private void allowDeploys(CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetSettings.antiCheatDisabled && CarpetServer.minecraft_server != null && CarpetServer.minecraft_server.isDedicated())
    {
        ItemStack itemStack_1 = getEquippedStack(EquipmentSlot.CHEST);
        if (itemStack_1.getItem() == Items.ELYTRA && ElytraItem.isUsable(itemStack_1)) {
            method_23669();
            cir.setReturnValue(true);
        }
    }
}
 
Example #11
Source File: MixinEntity.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Inject(method = "getPositionEyes(F)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
public void getPositionEyesInject(float partialTicks,
    CallbackInfoReturnable<Vec3d> callbackInfo) {
    EntityShipMountData mountData = ValkyrienUtils
        .getMountedShipAndPos(Entity.class.cast(this));

    if (mountData.isMounted()) {
        Vector playerPosition = new Vector(mountData.getMountPos());
        mountData.getMountedShip()
            .getShipTransformationManager()
            .getRenderTransform()
            .transform(playerPosition,
                TransformType.SUBSPACE_TO_GLOBAL);

        Vector playerEyes = new Vector(0, this.getEyeHeight(), 0);
        // Remove the original position added for the player's eyes
        // RotationMatrices.doRotationOnly(wrapper.wrapping.coordTransform.lToWTransform,
        // playerEyes);
        mountData.getMountedShip()
            .getShipTransformationManager()
            .getCurrentTickTransform()
            .rotate(playerEyes, TransformType.SUBSPACE_TO_GLOBAL);
        // Add the new rotate player eyes to the position
        playerPosition.add(playerEyes);
        callbackInfo.setReturnValue(playerPosition.toVec3d());
        callbackInfo.cancel(); // return the value, as opposed to the default one
    }
}
 
Example #12
Source File: MixinWorld.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(at = @At("HEAD"), method = "getHorizonHeight", cancellable = true)
private void getHorizonHeight(CallbackInfoReturnable<Double> info) { // TODO: use IForgeDimension
	LevelGeneratorType generatorType = this.properties.getGeneratorType();

	if (generatorType instanceof PatchworkLevelGeneratorType) {
		info.setReturnValue(((IForgeWorldType) generatorType).getHorizon((World) (Object) this));
	}
}
 
Example #13
Source File: MixinEnchantment.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "isAcceptableItem", at = @At(value = "HEAD"), cancellable = true)
public void isAcceptableItem(ItemStack stack, CallbackInfoReturnable<Boolean> info) {
    EnchantmentEvent.AcceptableItem event = EventDispatcher.publish(new EnchantmentEvent.AcceptableItem((Enchantment) this, WrappingUtil.cast(stack, org.sandboxpowered.sandbox.api.item.ItemStack.class)));
    if (event.getResult() != EventResult.IGNORE) {
        info.setReturnValue(event.getResult() == EventResult.SUCCESS);
    }
}
 
Example #14
Source File: MixinBlock.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "shouldSideBeRendered", at = @At("HEAD"), cancellable = true)
private void shouldSideBeRendered(CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
    final XRay xray = (XRay) LiquidBounce.moduleManager.getModule(XRay.class);

    if(xray.getState())
        callbackInfoReturnable.setReturnValue(xray.getXrayBlocks().contains(this));
}
 
Example #15
Source File: MixinBlock.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true)
private static void isShapeFullCube(VoxelShape voxelShape_1, CallbackInfoReturnable<Boolean> callback) {
    if (ModuleManager.getModule(Xray.class).isToggled()) {
        callback.setReturnValue(false);
        callback.cancel();
    }
}
 
Example #16
Source File: MixinBlockModelRenderer.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "renderModelAmbientOcclusion", at = @At("HEAD"), cancellable = true)
private void renderModelAmbientOcclusion(IBlockAccess blockAccessIn, IBakedModel modelIn, Block blockIn, BlockPos blockPosIn, WorldRenderer worldRendererIn, boolean checkSide, final CallbackInfoReturnable<Boolean> booleanCallbackInfoReturnable) {
    final XRay xray = (XRay) LiquidBounce.moduleManager.getModule(XRay.class);

    if (xray.getState() && !xray.getXrayBlocks().contains(blockIn))
        booleanCallbackInfoReturnable.setReturnValue(false);
}
 
Example #17
Source File: MixinParticleManager.java    From multiconnect with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Inject(method = "createParticle", at = @At("HEAD"), cancellable = true)
private <T extends ParticleEffect> void onCreateParticle(T effect, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, CallbackInfoReturnable<Particle> ci) {
    ParticleFactory<T> customFactory = (ParticleFactory<T>) customFactories.get(Registry.PARTICLE_TYPE.getId(effect.getType()));
    if (customFactory != null)
        ci.setReturnValue(customFactory.createParticle(effect, world, x, y, z, xSpeed, ySpeed, zSpeed));
}
 
Example #18
Source File: LivingEntity_creativeFlyMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "getMovementSpeed(F)F", at = @At("HEAD"), cancellable = true)
private void flyingAltSpeed(float slipperiness, CallbackInfoReturnable<Float> cir)
{
    if (CarpetSettings.creativeFlySpeed != 1.0D && (Object)this instanceof PlayerEntity)
    {
        PlayerEntity self = (PlayerEntity)(Object)(this);
        if (self.abilities.flying && !onGround)
            cir.setReturnValue(flyingSpeed* (float)CarpetSettings.creativeFlySpeed);
    }
}
 
Example #19
Source File: MixinSkinManager.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "loadSkinFromCache", cancellable = true, at = @At("HEAD"))
private void injectSkinProtect(GameProfile gameProfile, CallbackInfoReturnable<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>> cir) {
    if (gameProfile == null)
        return;
    
    NameProtect nameProtect = (NameProtect) LiquidBounce.moduleManager.getModule(NameProtect.class);

    if (nameProtect.getState() && nameProtect.skinProtectValue.get()) {
        if (nameProtect.allPlayersValue.get() || Objects.equals(gameProfile.getId(), Minecraft.getMinecraft().getSession().getProfile().getId())) {
            cir.setReturnValue(new HashMap<>());
            cir.cancel();
        }
    }
}
 
Example #20
Source File: MixinFlowerPotBlock.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "onUse", at = @At(value = "FIELD", target = "Lnet/minecraft/block/FlowerPotBlock;content:Lnet/minecraft/block/Block;", ordinal = 0), cancellable = true)
private void cancelEmptyingFlowerPot(CallbackInfoReturnable<ActionResult> ci) {
    // TODO: this doesn't fully work, WTF?!
    if (ConnectionInfo.protocolVersion <= Protocols.V1_10 && content != Blocks.AIR) {
        ci.setReturnValue(ActionResult.CONSUME);
    }
}
 
Example #21
Source File: PistonBlock_qcMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "shouldExtend", cancellable = true, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/util/math/BlockPos;up()Lnet/minecraft/util/math/BlockPos;"
))
private void cancelUpCheck(World world_1, BlockPos blockPos_1, Direction direction_1, CallbackInfoReturnable<Boolean> cir)
{
    if (!CarpetSettings.quasiConnectivity)
    {
        cir.setReturnValue(false);
        cir.cancel();
    }
}
 
Example #22
Source File: MixinPlayerEntity.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "getDimensions", at = @At("HEAD"), cancellable = true)
private void onGetDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_13_2) {
        if (pose == EntityPose.CROUCHING) {
            ci.setReturnValue(SNEAKING_DIMENSIONS_1_13_2);
        }
    }
}
 
Example #23
Source File: MixinDefaultPlayerSkin.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Inject(method = "getModel(Ljava/util/UUID;)Ljava/lang/String;",
        at = @At("HEAD"),
        cancellable = true)
private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) {
    if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {

        cir.setReturnValue(PlayerModels.forRace(MineLittlePony.getInstance().getManager()
                .getPony(IPonyManager.getDefaultSkin(uuid), uuid)
                .getRace(false))
                .getId(IPonyManager.isSlimSkin(uuid)));
    }
}
 
Example #24
Source File: MixinEntityItem.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "combineItems", at = @At("HEAD"), cancellable = true)
private void stopAttemptingToCombine(EntityItem other, CallbackInfoReturnable<Boolean> cir) {
    ItemStack stack = getEntityItem();
    if (stack.stackSize > stack.getMaxStackSize()) {
        cir.setReturnValue(false);
    }
}
 
Example #25
Source File: MixinPlayerInventory.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "getBlockBreakingSpeed", at = @At("HEAD"), cancellable = true)
public void getBlockBreakingSpeed(BlockState blockState_1, CallbackInfoReturnable<Float> callback) {
    SpeedMine speedMine = (SpeedMine) ModuleManager.getModule(SpeedMine.class);
    if (speedMine.isToggled() && speedMine.getSettings().get(0).toMode().mode == 1) {
        callback.setReturnValue((float) (this.main.get(this.selectedSlot).getMiningSpeedMultiplier(blockState_1) * speedMine.getSettings().get(3).toSlider().getValue()));
        callback.cancel();
    }
}
 
Example #26
Source File: MixinCamera.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Inject(method = "clipToSpace(D)D",
        at = @At("RETURN"),
        cancellable = true)
private void redirectCameraDistance(double initial, CallbackInfoReturnable<Double> info) {
    double value = info.getReturnValueD();

    IPony pony = MineLittlePony.getInstance().getManager().getPony(MinecraftClient.getInstance().player);

    if (!pony.getRace(false).isHuman()) {
        value *= pony.getMetadata().getSize().getEyeDistanceFactor();
    }

    info.setReturnValue(value);
}
 
Example #27
Source File: MixinBlock.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "getRenderLayer", at = @At("HEAD"), cancellable = true)
public void getRenderLayer(CallbackInfoReturnable<BlockRenderLayer> callback) {
    try {
        if (ModuleManager.getModule(Xray.class).isToggled()) {
            callback.setReturnValue(BlockRenderLayer.TRANSLUCENT);
            callback.cancel();
        }
    } catch (Exception ignored) {}
}
 
Example #28
Source File: MixinChunk.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "setBlockState", at = @At("HEAD"))
private void setProphuntBlock(BlockPos pos, IBlockState state, final CallbackInfoReturnable callbackInfo) {
    MiniMapRegister.INSTANCE.updateChunk((Chunk) ((Object) this));

    final ProphuntESP prophuntESP = (ProphuntESP) LiquidBounce.moduleManager.getModule(ProphuntESP.class);

    if (prophuntESP.getState()) {
        synchronized (prophuntESP.blocks) {
            prophuntESP.blocks.put(pos, System.currentTimeMillis());
        }
    }
}
 
Example #29
Source File: MixinDefaultPlayerSkin.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Inject(method = "getTexture(Ljava/util/UUID;)Lnet/minecraft/util/Identifier;",
        at = @At("HEAD"),
        cancellable = true)
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<Identifier> cir) {
    if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
        cir.setReturnValue(IPonyManager.getDefaultSkin(uuid));
    }
}
 
Example #30
Source File: PlayerManager_fakePlayersMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "loadPlayerData", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable<CompoundTag> cir)
{
    if (serverPlayerEntity_1 instanceof EntityPlayerMPFake)
    {
        ((EntityPlayerMPFake) serverPlayerEntity_1).fixStartingPosition.run();
    }
}