org.spongepowered.asm.mixin.injection.At Java Examples
The following examples show how to use
org.spongepowered.asm.mixin.injection.At.
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: MultiplayerScreenMixin.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Inject(at = {@At("TAIL")}, method = {"init()V"}) private void onInit(CallbackInfo ci) { if(!WurstClient.INSTANCE.isEnabled()) return; lastServerButton = addButton(new ButtonWidget(width / 2 - 154, 10, 100, 20, new LiteralText("Last Server"), b -> LastServerRememberer .joinLastServer((MultiplayerScreen)(Object)this))); addButton(new ButtonWidget(width / 2 + 154 + 4, height - 52, 100, 20, new LiteralText("Server Finder"), b -> client.openScreen( new ServerFinderScreen((MultiplayerScreen)(Object)this)))); addButton(new ButtonWidget(width / 2 + 154 + 4, height - 28, 100, 20, new LiteralText("Clean Up"), b -> client.openScreen( new CleanUpScreen((MultiplayerScreen)(Object)this)))); }
Example #2
Source File: ServerWorld_onePlayerSleepingMixin.java From fabric-carpet with MIT License | 6 votes |
@Inject(method = "updatePlayersSleeping", cancellable = true, at = @At("HEAD")) private void updateOnePlayerSleeping(CallbackInfo ci) { if(CarpetSettings.onePlayerSleeping) { allPlayersSleeping = false; for (ServerPlayerEntity p : players) if (!p.isSpectator() && p.isSleeping()) { allPlayersSleeping = true; ci.cancel(); return; } ci.cancel(); } }
Example #3
Source File: TntEntityMixin.java From fabric-carpet with MIT License | 6 votes |
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/TntEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V", ordinal = 2)) private void tryMergeTnt(CallbackInfo ci) { // Merge code for combining tnt into a single entity if they happen to exist in the same spot, same fuse, no motion CARPET-XCOM if(CarpetSettings.mergeTNT){ Vec3d velocity = getVelocity(); if(!world.isClient && mergeBool && velocity.x == 0 && velocity.y == 0 && velocity.z == 0){ mergeBool = false; for(Entity entity : world.getEntities(this, this.getBoundingBox())){ if(entity instanceof TntEntity && !entity.removed){ TntEntity entityTNTPrimed = (TntEntity)entity; Vec3d tntVelocity = entityTNTPrimed.getVelocity(); if(tntVelocity.x == 0 && tntVelocity.y == 0 && tntVelocity.z == 0 && this.getX() == entityTNTPrimed.getX() && this.getZ() == entityTNTPrimed.getZ() && this.getY() == entityTNTPrimed.getY() && this.fuseTimer == entityTNTPrimed.getFuseTimer()){ mergedTNT += ((TntEntityInterface) entityTNTPrimed).getMergedTNT(); entityTNTPrimed.remove(); } } } } } }
Example #4
Source File: LivingEntityMixin.java From the-hallow with MIT License | 6 votes |
@Inject(method = "drop(Lnet/minecraft/entity/damage/DamageSource;)V", at = @At("HEAD")) public void drop(DamageSource damageSource, CallbackInfo info) { LivingEntity livingEntity = (LivingEntity) (Object) this; if (damageSource.getSource() instanceof LivingEntity && livingEntity.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT) && BeheadingEnchantment.hasBeheading((LivingEntity) damageSource.getSource())) { if (BeheadingEnchantment.getHead(damageSource)) { if (livingEntity.getType() == EntityType.WITHER_SKELETON) { livingEntity.dropStack(new ItemStack(Items.WITHER_SKELETON_SKULL)); } else if (livingEntity.getType() == EntityType.SKELETON) { livingEntity.dropStack(new ItemStack(Items.SKELETON_SKULL)); } else if (livingEntity.getType() == EntityType.ZOMBIE) { livingEntity.dropStack(new ItemStack(Items.ZOMBIE_HEAD)); } else if (livingEntity.getType() == EntityType.CREEPER) { livingEntity.dropStack(new ItemStack(Items.CREEPER_HEAD)); } else if (livingEntity.getType() == EntityType.PLAYER) { livingEntity.dropStack(new ItemStack(Items.PLAYER_HEAD)); } } } }
Example #5
Source File: MixinRecipeBookWidget.java From multiconnect with MIT License | 5 votes |
@Inject(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeResultCollection;isCraftable(Lnet/minecraft/recipe/Recipe;)Z"), cancellable = true) private void redirectRecipeBook(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> ci) { if (ConnectionInfo.protocolVersion <= Protocols.V1_12) { handleRecipeClicked(recipeBook112, recipesArea.getLastClickedRecipe(), recipesArea.getLastClickedResults()); if (!isWide()) setOpen(false); ci.setReturnValue(true); } }
Example #6
Source File: MixinMinecraft.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Inject(method = "setWindowIcon", at = @At("HEAD"), cancellable = true) private void setWindowIcon(CallbackInfo callbackInfo) { if(Util.getOSType() != Util.EnumOS.OSX) { final ByteBuffer[] liquidBounceFavicon = IconUtils.getFavicon(); if(liquidBounceFavicon != null) { Display.setIcon(liquidBounceFavicon); callbackInfo.cancel(); } } }
Example #7
Source File: EntityNavigation_pathfindingMixin.java From fabric-carpet with MIT License | 5 votes |
@Redirect(method = "findPathTo(Lnet/minecraft/util/math/BlockPos;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathToAny(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;" )) private Path pathToBlock(EntityNavigation entityNavigation, Set<BlockPos> set_1, int int_1, boolean boolean_1, int int_2) { if (!LoggerRegistry.__pathfinding) return findPathToAny(set_1, int_1, boolean_1, int_2); long start = System.nanoTime(); Path path = findPathToAny(set_1, int_1, boolean_1, int_2); long finish = System.nanoTime(); float duration = (1.0F*((finish - start)/1000))/1000; set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, new Vec3d(b), duration, path != null)); return path; }
Example #8
Source File: MixinBlock.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@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: MixinEntityTypeBuilder.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@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 #10
Source File: MixinServerPlayerEntity.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Inject(method = "onDeath", at = @At("HEAD"), cancellable = true) private void hookDeath(DamageSource source, CallbackInfo callback) { LivingEntity entity = (LivingEntity) (Object) this; if (EntityEvents.onLivingDeath(entity, source)) { callback.cancel(); } }
Example #11
Source File: MixinGuiInGame.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Inject(method = "renderTooltip", at = @At("RETURN")) private void renderTooltipPost(ScaledResolution sr, float partialTicks, CallbackInfo callbackInfo) { if (!ClassUtils.hasClass("net.labymod.api.LabyModAPI")) { LiquidBounce.eventManager.callEvent(new Render2DEvent(partialTicks)); AWTFontRenderer.Companion.garbageCollectionTick(); } }
Example #12
Source File: MinecraftClientMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Inject(at = {@At("HEAD")}, method = {"getSession()Lnet/minecraft/client/util/Session;"}, cancellable = true) private void onGetSession(CallbackInfoReturnable<Session> cir) { if(wurstSession == null) return; cir.setReturnValue(wurstSession); }
Example #13
Source File: MixinClientConnection.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true) public void channelRead0(ChannelHandlerContext channelHandlerContext_1, Packet<?> packet_1, CallbackInfo callback) { if (this.channel.isOpen() && packet_1 != null) { try { EventReadPacket event = new EventReadPacket(packet_1); BleachHack.eventBus.post(event); if (event.isCancelled()) callback.cancel(); } catch (Exception exception) {} } }
Example #14
Source File: MinecraftServer_scarpetMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method = "tick", at = @At( value = "CONSTANT", args = "stringValue=tallying" )) public void tickTasks(BooleanSupplier booleanSupplier_1, CallbackInfo ci) { TICK.onTick(); NETHER_TICK.onTick(); ENDER_TICK.onTick(); }
Example #15
Source File: MixinSimpleRegistry.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "set", at = @At(value = "HEAD"), cancellable = true) public <V extends T> void set(int i, Identifier identifier, V object, CallbackInfoReturnable<V> ci) { if (hasStored) { identifiers.add(identifier); if (object instanceof BlockItem) { ((BlockItem) object).appendBlocks(Item.BLOCK_ITEMS, (BlockItem) object); } if (object instanceof Block) { ((Block) object).getStateManager().getStates().forEach(Block.STATE_IDS::add); //TODO: Also need to reset the state ids } } }
Example #16
Source File: MixinTileEntityRendererDispatcher.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Inject(method = "renderTileEntity", at = @At("HEAD"), cancellable = true) private void renderTileEntity(TileEntity tileentityIn, float partialTicks, int destroyStage, final CallbackInfo callbackInfo) { final XRay xray = (XRay) LiquidBounce.moduleManager.getModule(XRay.class); if (xray.getState() && !xray.getXrayBlocks().contains(tileentityIn.getBlockType())) callbackInfo.cancel(); }
Example #17
Source File: PistonBlock_movableTEMixin.java From fabric-carpet with MIT License | 5 votes |
@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 #18
Source File: SetBlockCommandMixin.java From fabric-carpet with MIT License | 5 votes |
@Redirect(method = "execute", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V" )) private static void conditionalUpdating(ServerWorld serverWorld, BlockPos blockPos_1, Block block_1) { if (CarpetSettings.fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1); }
Example #19
Source File: MixinMinecraft.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@Inject(method = "displayGuiScreen", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;currentScreen:Lnet/minecraft/client/gui/GuiScreen;", shift = At.Shift.AFTER)) private void displayGuiScreen(CallbackInfo callbackInfo) { if(currentScreen instanceof net.minecraft.client.gui.GuiMainMenu || (currentScreen != null && currentScreen.getClass().getName().startsWith("net.labymod") && currentScreen.getClass().getSimpleName().equals("ModGuiMainMenu"))) { currentScreen = new GuiMainMenu(); ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); currentScreen.setWorldAndResolution(Minecraft.getMinecraft(), scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight()); skipRenderWorld = false; } LiquidBounce.eventManager.callEvent(new ScreenEvent(currentScreen)); }
Example #20
Source File: MixinDisconnectedScreen.java From multiconnect with MIT License | 5 votes |
@Inject(method = "render", at = @At("RETURN")) private void onRender(MatrixStack matrixStack, int mouseX, int mouseY, float delta, CallbackInfo ci) { if (isProtocolReason) { textRenderer.drawWithShadow(matrixStack, forceProtocolLabel, width - 85 - textRenderer.getWidth(forceProtocolLabel), 11, 0xFFFFFF); protocolSelector.render(matrixStack, mouseX, mouseY, delta); } }
Example #21
Source File: MixinCreateWorldScreen.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Inject(at = @At(value = "INVOKE", target = "org/apache/commons/lang3/StringUtils.isEmpty(Ljava/lang/CharSequence;)Z"), method = "createLevel") private void onGUICreateWorldPress(CallbackInfo info) { LevelGeneratorType generatorType = LevelGeneratorType.TYPES[this.generatorType]; if (generatorType instanceof PatchworkLevelGeneratorType) { ((IForgeWorldType) generatorType).onGUICreateWorldPress(); } }
Example #22
Source File: RenderTickCounterMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Inject(at = {@At(value = "FIELD", target = "Lnet/minecraft/client/render/RenderTickCounter;prevTimeMillis:J", opcode = Opcodes.PUTFIELD, ordinal = 0)}, method = {"beginRenderTick(J)I"}) public void onBeginRenderTick(long long_1, CallbackInfoReturnable<Integer> cir) { TimerHack timerHack = WurstClient.INSTANCE.getHax().timerHack; lastFrameDuration *= timerHack.getTimerSpeed(); }
Example #23
Source File: PlayerManager_fakePlayersMixin.java From fabric-carpet with MIT License | 5 votes |
@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 #24
Source File: ServerPlayNetworkHandler_scarpetEventsMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method = "onPlayerInteractBlock", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;interactBlock(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;Lnet/minecraft/util/hit/BlockHitResult;)Lnet/minecraft/util/ActionResult;" )) private void onBlockInteracted(PlayerInteractBlockC2SPacket playerInteractBlockC2SPacket_1, CallbackInfo ci) { if (PLAYER_RIGHT_CLICKS_BLOCK.isNeeded()) { Hand hand = playerInteractBlockC2SPacket_1.getHand(); BlockHitResult hitRes = playerInteractBlockC2SPacket_1.getHitY(); PLAYER_RIGHT_CLICKS_BLOCK.onBlockHit(player, hand, hitRes); } }
Example #25
Source File: ServerChunkManager_tickMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method = "tickChunks", at = @At("RETURN")) private void stopSpawningSection(CallbackInfo ci) { if (currentSection != null) { CarpetProfiler.end_current_section(currentSection); } }
Example #26
Source File: MixinLivingEntity.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Inject(method = "handleFallDamage", at = @At("HEAD"), cancellable = true) private void hookHandleFallDamageCancel(float distance, float damageMultiplier, CallbackInfo info) { LivingEntity entity = (LivingEntity) (Object) this; fallData = EntityEvents.onLivingFall(entity, distance, damageMultiplier); if (fallData == null) { info.cancel(); } }
Example #27
Source File: MixinBlockModelRenderer.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "render", at = @At("HEAD"), cancellable = true) private void render(BlockRenderView blockRenderView_1, BakedModel bakedModel_1, BlockState blockState_1, BlockPos blockPos_1, MatrixStack matrixStack_1, VertexConsumer vertexConsumer_1, boolean boolean_1, Random random_1, long long_1, int int_1, CallbackInfoReturnable<Boolean> ci) { try { Xray xray = (Xray) ModuleManager.getModule(Xray.class); if (!xray.isVisible(blockState_1.getBlock())) { ci.setReturnValue(false); ci.cancel(); } } catch (Exception ignored) {} }
Example #28
Source File: GameMenuScreenMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Inject(at = {@At("TAIL")}, method = {"render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V"}) private void onRender(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { if(!WurstClient.INSTANCE.isEnabled()) return; GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1, 1, 1, 1); client.getTextureManager().bindTexture(wurstTexture); int x = wurstOptionsButton.x + 34; int y = wurstOptionsButton.y + 2; int w = 63; int h = 16; int fw = 63; int fh = 16; float u = 0; float v = 0; drawTexture(matrixStack, x, y, u, v, w, h, fw, fh); }
Example #29
Source File: ServerPlayNetworkHandler_interactionUpdatesMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method = "onPlayerInteractItem", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;interactItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;)Lnet/minecraft/util/ActionResult;", shift = At.Shift.BEFORE )) private void beforeItemInteracted(PlayerInteractItemC2SPacket packet, CallbackInfo ci) { if (!CarpetSettings.interactionUpdates) CarpetSettings.impendingFillSkipUpdates = true; }
Example #30
Source File: FillCommandMixin.java From fabric-carpet with MIT License | 5 votes |
@Redirect(method = "execute", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V" )) private static void conditionalUpdating(ServerWorld serverWorld, BlockPos blockPos_1, Block block_1) { if (CarpetSettings.fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1); }