Java Code Examples for org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable#getReturnValue()

The following examples show how to use org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable#getReturnValue() . 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: 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 2
Source File: MixinEntityTypeBuilder.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Inject(method = "build", at = @At("RETURN"))
private void onBuildReturn(String id, CallbackInfoReturnable<EntityType> cir) {
	PatchworkEntityTypeExtensions type = (PatchworkEntityTypeExtensions) cir.getReturnValue();

	if (updateInterval != null) {
		type.patchwork$setUpdateInterval(updateInterval);
	}

	if (trackingRange != null) {
		type.patchwork$setTrackingRange(trackingRange);
	}

	if (shouldRecieveVelocityUpdates != null) {
		type.patchwork$setShouldReceiveVelocityUpdates(shouldRecieveVelocityUpdates);
	}
}
 
Example 3
Source File: ItemStackMixin.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@SuppressWarnings("RedundantSuppression")
@Inject(method = "getName", at = @At("RETURN"), cancellable = true)
private void getName(CallbackInfoReturnable<Text> returnable) {
    Identifier id = Registry.ITEM.getId(getItem());
    //noinspection ConstantConditions,PointlessBooleanExpression
    if (false && id.getNamespace().equals(Constants.MOD_ID)) {
        Text returnVal = returnable.getReturnValue();
        if (returnVal.getStyle().getColor() == null) {
            returnable.setReturnValue(returnVal.shallowCopy().setStyle(returnVal.getStyle().withColor(Formatting.BLUE)));
        }
    }
}
 
Example 4
Source File: GameRendererMixin.java    From the-hallow with MIT License 5 votes vote down vote up
@Inject(at = @At("RETURN"), method = "getViewDistance()F", cancellable = true)
private void getHallowViewDistance(final CallbackInfoReturnable<Float> info) {
	final MinecraftClient client = MinecraftClient.getInstance();
	final World world = client.world;
	
	if (world.getDimension().getType() == HallowedDimensions.THE_HALLOW) {
		final PlayerEntity player = client.player;
		float totalIntensity = 0;
		int count = 0;
		final int radius = HallowedConfig.HallowedFog.fogSmoothingRadius;
		for (int x = 0; x < radius; x++) {
			for (int z = 0; z < radius; z++) {
				final BlockPos pos = player.getBlockPos().add(x - (radius / 2), 0, z - (radius / 2));
				
				if (world.getBiomeAccess().getBiome(pos) instanceof HallowedBiomeInfo) {
					final HallowedBiomeInfo biomeInfo = (HallowedBiomeInfo) world.getBiomeAccess().getBiome(pos);
					totalIntensity += biomeInfo.getFogIntensity();
					count++;
				}
			}
		}
		
		final float distance = totalIntensity / count;
		if(distance < info.getReturnValue())
		{
			info.setReturnValue(distance);
		}
	}
}
 
Example 5
Source File: MixinClientChunkManager.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "loadChunkFromPacket", at = @At("RETURN"))
private void onLoadChunkFromPacket(int x, int z, BiomeArray biomeArray, PacketByteBuf buf, CompoundTag heightmaps, int verticalStripMask, boolean bl, CallbackInfoReturnable<WorldChunk> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_14_4) {
        if (ci.getReturnValue() != null) {
            Biome[] biomeData = PendingBiomeData.getPendingBiomeData(x, z);
            if (biomeData != null) {
                ((IBiomeStorage_1_14_4) ci.getReturnValue()).multiconnect_setBiomeArray_1_14_4(biomeData);
                PendingBiomeData.setPendingBiomeData(x, z, null);
            }
        }
    }
}
 
Example 6
Source File: MixinEntityTypeBuilder.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Inject(method = "build", at = @At("RETURN"))
private void onBuildReturn(String id, CallbackInfoReturnable<EntityType<T>> callback) {
	ClientEntitySpawner<T> spawner = (ClientEntitySpawner<T>) callback.getReturnValue();

	spawner.patchwork$setCustomClientFactory(this.customClientFactory);
}
 
Example 7
Source File: MixinBlock.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "getPlayerRelativeBlockHardness", at = @At("RETURN"), cancellable = true)
public void modifyBreakSpeed(EntityPlayer playerIn, World worldIn, BlockPos pos, final CallbackInfoReturnable<Float> callbackInfo) {
    float f = callbackInfo.getReturnValue();

    // NoSlowBreak
    final NoSlowBreak noSlowBreak = (NoSlowBreak) LiquidBounce.moduleManager.getModule(NoSlowBreak.class);
    if (noSlowBreak.getState()) {
        if (noSlowBreak.getWaterValue().get() && playerIn.isInsideOfMaterial(Material.water) &&
                !EnchantmentHelper.getAquaAffinityModifier(playerIn)) {
            f *= 5.0F;
        }

        if (noSlowBreak.getAirValue().get() && !playerIn.onGround) {
            f *= 5.0F;
        }
    } else if (playerIn.onGround) { // NoGround
        final NoFall noFall = (NoFall) LiquidBounce.moduleManager.getModule(NoFall.class);
        final Criticals criticals = (Criticals) LiquidBounce.moduleManager.getModule(Criticals.class);

        if (noFall.getState() && noFall.modeValue.get().equalsIgnoreCase("NoGround") ||
                criticals.getState() && criticals.getModeValue().get().equalsIgnoreCase("NoGround")) {
            f /= 5F;
        }
    }

    callbackInfo.setReturnValue(f);
}
 
Example 8
Source File: MixinBlock.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "getPlayerRelativeBlockHardness", at = @At("RETURN"), cancellable = true)
public void modifyBreakSpeed(EntityPlayer playerIn, World worldIn, BlockPos pos, final CallbackInfoReturnable<Float> callbackInfo) {
    float f = callbackInfo.getReturnValue();

    // NoSlowBreak
    final NoSlowBreak noSlowBreak = (NoSlowBreak) LiquidBounce.moduleManager.getModule(NoSlowBreak.class);
    if (noSlowBreak.getState()) {
        if (noSlowBreak.getWaterValue().get() && playerIn.isInsideOfMaterial(Material.water) &&
                !EnchantmentHelper.getAquaAffinityModifier(playerIn)) {
            f *= 5.0F;
        }

        if (noSlowBreak.getAirValue().get() && !playerIn.onGround) {
            f *= 5.0F;
        }
    } else if (playerIn.onGround) { // NoGround
        final NoFall noFall = (NoFall) LiquidBounce.moduleManager.getModule(NoFall.class);
        final Criticals criticals = (Criticals) LiquidBounce.moduleManager.getModule(Criticals.class);

        if (noFall.getState() && noFall.modeValue.get().equalsIgnoreCase("NoGround") ||
                criticals.getState() && criticals.getModeValue().get().equalsIgnoreCase("NoGround")) {
            f /= 5F;
        }
    }

    callbackInfo.setReturnValue(f);
}
 
Example 9
Source File: MixinAbstractClientPlayer.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "getLocationCape", at = @At("HEAD"), cancellable = true)
private void getLocationCape(CallbackInfoReturnable<ResourceLocation> locationCallbackInfoReturnable) {
    NickHider instance = NickHider.instance;
    if (locationCallbackInfoReturnable.getReturnValue() != null) return;

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

        if (getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) && config.isUseRealSkinForSelf()) {
            locationCallbackInfoReturnable.setReturnValue(instance.getPlayerCape());
        }
    }
}
 
Example 10
Source File: MixinNetworkPlayerInfo.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "getLocationCape", at = @At("RETURN"), cancellable = true)
private void getLocationCape(CallbackInfoReturnable<ResourceLocation> cir) {
    NickHider instance = NickHider.instance;

    if (cir.getReturnValue() != null) return;

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

        if (gameProfile.getId().equals(Minecraft.getMinecraft().thePlayer.getUniqueID()) && config.isUseRealSkinForSelf()) {
            cir.setReturnValue(instance.getPlayerCape());
        }
    }
}
 
Example 11
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 12
Source File: MixinIdList.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "get", at = @At("RETURN"), cancellable = true)
private void onGet(int id, CallbackInfoReturnable<T> ci) {
    if (ci.getReturnValue() == null) {
        ci.setReturnValue(highIdsMap.get(id));
    }
}
 
Example 13
Source File: MixinChunkDataS2C.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "getReadBuffer", at = @At("RETURN"), cancellable = true)
private void onGetReadBuffer(CallbackInfoReturnable<PacketByteBuf> ci) {
    TransformerByteBuf transformerByteBuf = new TransformerByteBuf(ci.getReturnValue(), null);
    transformerByteBuf.readTopLevelType(ChunkData.class);
    ci.setReturnValue(transformerByteBuf);
}
 
Example 14
Source File: HyperiumChatComponentStyle.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void getFormattedTextReturn(CallbackInfoReturnable<String> string) {
    cache = string.getReturnValue();
}
 
Example 15
Source File: MixinEntityPlayer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Inject(method = "dropItem", at = @At("RETURN"))
private void itemDrop(ItemStack droppedItem, boolean dropAround, boolean traceItem, CallbackInfoReturnable<EntityItem> cir) {
    if (cir.getReturnValue() == null) return;

    new ItemTossEvent((EntityPlayer) (Object) this, cir.getReturnValue()).post();
}
 
Example 16
Source File: MixinItemStack.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Inject(method = "getTooltip", at = @At("RETURN"))
private void injectTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable<List<String>> cir) {
    if (cir.getReturnValue() == null) return;

    new ItemTooltipEvent((ItemStack) (Object) this, cir.getReturnValue());
}