Java Code Examples for org.spongepowered.asm.mixin.injection.callback.LocalCapture#CAPTURE_FAILHARD

The following examples show how to use org.spongepowered.asm.mixin.injection.callback.LocalCapture#CAPTURE_FAILHARD . 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: ClientPlayNetworkHandler_smoothClientAnimationsMixin.java    From fabric-carpet with MIT License 7 votes vote down vote up
@Inject( method = "onChunkData", locals = LocalCapture.CAPTURE_FAILHARD, require = 0, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/client/world/ClientWorld;getBlockEntity(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/entity/BlockEntity;",
        shift = At.Shift.AFTER
))
private void recreateMovingPistons(ChunkDataS2CPacket packet, CallbackInfo ci,
                                   Iterator var5, CompoundTag tag, BlockPos blockPos)
{
    if (CarpetSettings.smoothClientAnimations)
    {
        BlockEntity blockEntity = world.getBlockEntity(blockPos);
        if (blockEntity == null && "minecraft:piston".equals(tag.getString("id")))
        {
            BlockState blockState = world.getBlockState(blockPos);
            if (blockState.getBlock() == Blocks.MOVING_PISTON) {
                tag.putFloat("progress", Math.min(tag.getFloat("progress") + 0.5F, 1.0F));
                blockEntity = new PistonBlockEntity();
                blockEntity.fromTag(tag);
                world.setBlockEntity(blockPos, blockEntity);
                blockEntity.resetBlock();
            }
        }
    }
}
 
Example 2
Source File: MixinMouse.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(method = "method_1605", at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void preMouseReleased(boolean[] handled, double mouseX, double mouseY, int button, CallbackInfo info) {
	if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseReleasedEvent.Pre(client.currentScreen, mouseX, mouseY, button))) {
		handled[0] = true;
		info.cancel();
	}
}
 
Example 3
Source File: HopperMinecartEntity_cooldownFixMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "canOperate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/HopperBlockEntity;extract(Lnet/minecraft/inventory/Inventory;Lnet/minecraft/entity/ItemEntity;)Z", shift = At.Shift.BEFORE),cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private void extractAndReturnSuccess(CallbackInfoReturnable<Boolean> cir, List list_1) {
    if (CarpetExtraSettings.hopperMinecart8gtCooldown) {
        boolean result = HopperBlockEntity.extract(this, (ItemEntity) list_1.get(0));
        cir.setReturnValue(result);
        cir.cancel();
    }
}
 
Example 4
Source File: MixinMouse.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(method = "method_1611", at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
public void preMouseClicked(boolean[] handled, double mouseX, double mouseY, int button, CallbackInfo info) {
	if (MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseClickedEvent.Pre(client.currentScreen, mouseX, mouseY, button))) {
		handled[0] = true;
		info.cancel();
	}
}
 
Example 5
Source File: ChunkSerializerMixin.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(method = "serialize", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;saveToTag(Lnet/minecraft/nbt/CompoundTag;)Z"), to = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/ProtoChunk;getEntities()Ljava/util/List;")), at = @At(value = "JUMP", opcode = Opcodes.GOTO, ordinal = 2), locals = LocalCapture.CAPTURE_FAILHARD)
private static void serializeCapabilities(ServerWorld serverWorld, Chunk chunk, CallbackInfoReturnable<CompoundTag> callbackInfoReturnable, ChunkPos chunkPos, CompoundTag compoundTag, CompoundTag level) {
	CompoundTag tag = ((CapabilityProviderHolder) chunk).serializeCaps();

	if (tag != null) {
		level.put("ForgeCaps", tag);
	}
}
 
Example 6
Source File: CauldronBlock_stackableSBoxesMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "onUse", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/item/ItemStack;hasTag()Z",
        shift = At.Shift.BEFORE
))
private void setSboxCount(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult arg5, CallbackInfoReturnable<Boolean> cir,
                          ItemStack itemStack, int i, Item item, Block block, ItemStack itemStack5)
{
    if (CarpetSettings.stackableShulkerBoxes)
        itemStack5.setCount(itemStack.getCount());
}
 
Example 7
Source File: ClientPlayerEntityMixin.java    From spark with GNU General Public License v3.0 5 votes vote down vote up
@Inject(method = "sendChatMessage(Ljava/lang/String;)V", at = @At("HEAD"),
        locals = LocalCapture.CAPTURE_FAILHARD,
        cancellable = true)
public void onSendChatMessage(String message, CallbackInfo ci) {
    if (FabricSparkGameHooks.INSTANCE.tryProcessChat(message)) {
        ci.cancel();
    }
}
 
Example 8
Source File: PlayerManager_fakePlayersMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "createPlayer", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
        target = "Ljava/util/Iterator;hasNext()Z"), locals = LocalCapture.CAPTURE_FAILHARD)
private void newWhileLoop(GameProfile gameProfile_1, CallbackInfoReturnable<ServerPlayerEntity> cir, UUID uUID_1,
                          List list_1, Iterator var5)
{
    while (var5.hasNext())
    {
        ServerPlayerEntity serverPlayerEntity_3 = (ServerPlayerEntity) var5.next();
        if(serverPlayerEntity_3 instanceof EntityPlayerMPFake)
        {
            serverPlayerEntity_3.kill();
            continue;
        }
        serverPlayerEntity_3.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login"));
    }
}
 
Example 9
Source File: PistonBlock_movableTEMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
        target = "Ljava/util/List;size()I", ordinal = 4),locals = LocalCapture.CAPTURE_FAILHARD)
private void onMove(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
                    CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1,
                    List<BlockPos> list_1, List<BlockState> list_2, List list_3, int int_2, BlockState[] blockStates_1,
                    Direction direction_2)
{
    //Get the blockEntities and remove them from the world before any magic starts to happen
    if (CarpetSettings.movableBlockEntities)
    {
        list1_BlockEntities.set(Lists.newArrayList());
        for (int i = 0; i < list_1.size(); ++i)
        {
            BlockPos blockpos = list_1.get(i);
            BlockEntity blockEntity = (list_2.get(i).getBlock().hasBlockEntity()) ? world_1.getBlockEntity(blockpos) : null;
            list1_BlockEntities.get().add(blockEntity);
            if (blockEntity != null)
            {
                //hopefully this call won't have any side effects in the future, such as dropping all the BlockEntity's items
                //we want to place this same(!) BlockEntity object into the world later when the movement stops again
                world_1.removeBlockEntity(blockpos);
                blockEntity.markDirty();
            }
        }
    }
}
 
Example 10
Source File: ServerWorld_scarpetEventMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "tickChunk", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;addLightning(Lnet/minecraft/entity/LightningEntity;)V"
))
private void onNaturalLightinig(WorldChunk chunk, int randomTickSpeed, CallbackInfo ci,
                                ChunkPos chunkPos, boolean bl, int i, int j, Profiler profiler, BlockPos blockPos, boolean bl2)
{
    if (LIGHTNING.isNeeded()) LIGHTNING.onWorldEventFlag((ServerWorld) (Object)this, blockPos, bl2?1:0);
}
 
Example 11
Source File: MixinMinecraftServer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Inject(method = "addFaviconToStatusResponse", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ServerStatusResponse;setFavicon(Ljava/lang/String;)V",
    shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
private void releaseByteBuffer(ServerStatusResponse response, CallbackInfo ci, File serverIcon, ByteBuf buffer, BufferedImage image, ByteBuf bytebuf1) {
    bytebuf1.release();
}
 
Example 12
Source File: ServerChunkManagerMixin.java    From fabric-carpet with MIT License 4 votes vote down vote up
@Inject(
        method = "tickChunks",
        locals = LocalCapture.CAPTURE_FAILHARD,
        at = @At(
                value = "INVOKE",
                target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;entryIterator()Ljava/lang/Iterable;",
                shift = At.Shift.AFTER,
                ordinal = 0

))
//this runs once per world spawning cycle. Allows to grab mob counts and count spawn ticks
private void grabMobcaps(CallbackInfo ci,
                         long long_1,
                         long long_2,
                         LevelProperties levelProperties_1,
                         boolean boolean_1,
                         boolean boolean_2,
                         int int_1,
                         BlockPos blockPos_1,
                         boolean boolean_3,
                         int int_2,
                         EntityCategory[] entityCategorys_1,
                         Object2IntMap object2IntMap_1)
{
    DimensionType dim = this.world.dimension.getType();
    //((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs
    SpawnReporter.mobCounts.put(dim, (Object2IntMap<EntityCategory>)object2IntMap_1);
    SpawnReporter.chunkCounts.put(dim, int_2);

    if (SpawnReporter.track_spawns > 0L)
    {
        //local spawns now need to be tracked globally cause each calll is just for chunk
        SpawnReporter.local_spawns = new HashMap<>();
        SpawnReporter.first_chunk_marker = new HashSet<>();
        for (EntityCategory cat : EntityCategory.values())
        {
            Pair key = Pair.of(dim, cat);
            SpawnReporter.overall_spawn_ticks.put(key,
                    SpawnReporter.overall_spawn_ticks.get(key)+
                    SpawnReporter.spawn_tries.get(cat));
        }
    }
}
 
Example 13
Source File: MixinGameRenderer.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(IIF)V", shift = At.Shift.BY, by = 2), locals = LocalCapture.CAPTURE_FAILHARD)
private void afterRenderScreen(float tickDelta, long startTime, boolean fullRender, CallbackInfo info, int mouseX, int mouseY) {
	MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(client.currentScreen, mouseX, mouseY, tickDelta));
}
 
Example 14
Source File: MixinClientPlayNetworkHandler.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "onGuiActionConfirm", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ConfirmGuiActionS2CPacket;wasAccepted()Z"), locals = LocalCapture.CAPTURE_FAILHARD)
private void onOnGuiActionConfirm(ConfirmGuiActionS2CPacket packet, CallbackInfo ci, ScreenHandler screenHandler) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_11_2) {
        ((IScreenHandler) screenHandler).multiconnect_getRecipeBookEmulator().onConfirmTransaction(packet);
    }
}
 
Example 15
Source File: MixinSpriteAtlasTexture.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "stitch", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/SpriteAtlasTexture;loadSprites(Lnet/minecraft/resource/ResourceManager;Ljava/util/Set;)Ljava/util/Collection;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
private void onStitch(ResourceManager resourceManager, Iterable<Identifier> iterable, Profiler profiler, CallbackInfoReturnable<SpriteAtlasTexture.Data> cir, Set<Identifier> set) {
	RenderEvents.onTextureStitchPre((SpriteAtlasTexture) (Object) this, set);
}
 
Example 16
Source File: MixinFishingBobberEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "method_6957(Lnet/minecraft/item/ItemStack;)I", at = @At(value = "INVOKE", target = LOOT_CONTEXT_BUILD_TARGET), locals = LocalCapture.CAPTURE_FAILHARD)
private void patchwork_addFishingParameters(ItemStack stack, CallbackInfoReturnable<Integer> callback, int rodDamage, LootContext.Builder builder, LootTable supplier) {
	builder.put(LootContextParameters.KILLER_ENTITY, this.owner);
	builder.put(LootContextParameters.THIS_ENTITY, (Entity) (Object) this);
}
 
Example 17
Source File: MixinMinecraft.java    From VanillaFix with MIT License 4 votes vote down vote up
/** @reason Add the F3 + S help message to the F3 + Q debug help menu. */
@Inject(method = "processKeyF3", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;printChatMessage(Lnet/minecraft/util/text/ITextComponent;)V", ordinal = 9), locals = LocalCapture.CAPTURE_FAILHARD)
private void addF3SHelpMessage(int auxKey, CallbackInfoReturnable<Boolean> cir, GuiNewChat chatGui) {
    chatGui.printChatMessage(new TextComponentTranslation("vanillafix.debug.switch_profiler.help"));
}
 
Example 18
Source File: MixinMouse.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "onMouseScroll", at = @At(value = "INVOKE",
				target = "Lnet/minecraft/client/gui/screen/Screen;mouseScrolled(DDD)Z",
				ordinal = 0, shift = At.Shift.BY, by = 2), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void postMouseScrolled(long window, double xOffset, double yOffset, CallbackInfo info, double amount, double mouseX, double mouseY) {
	MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseScrollEvent.Post(client.currentScreen, mouseX, mouseY, amount));
}
 
Example 19
Source File: MixinTranslationStorage.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "load(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;)Lnet/minecraft/client/resource/language/TranslationStorage;",
        at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;", remap = false),
        locals = LocalCapture.CAPTURE_FAILHARD)
private static void onLoad(ResourceManager resourceManager, List<LanguageDefinition> languages, CallbackInfoReturnable<TranslationStorage> ci, Map<String, String> translations) {
    OldLanguageManager.addExtraTranslations(languages.get(languages.size() - 1).getCode(), translations::put);
}
 
Example 20
Source File: MixinDecoderHandler.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "decode", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/Packet;read(Lnet/minecraft/network/PacketByteBuf;)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
private void postDecode(ChannelHandlerContext context, ByteBuf buf, List<Object> output, CallbackInfo ci, PacketByteBuf packetBuf, int packetId, Packet<?> packet) {
    if (!((TransformerByteBuf) packetBuf).canDecodeAsync(packet.getClass())) {
        ConnectionInfo.resourceReloadLock.readLock().unlock();
    }
}