当前位置: 首页>>代码示例>>Java>>正文


Java Inject类代码示例

本文整理汇总了Java中org.spongepowered.asm.mixin.injection.Inject的典型用法代码示例。如果您正苦于以下问题:Java Inject类的具体用法?Java Inject怎么用?Java Inject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Inject类属于org.spongepowered.asm.mixin.injection包,在下文中一共展示了Inject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDrawScreen

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "drawScreen", at = @At("HEAD"), cancellable = true)
public void onDrawScreen(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
    Minecraft mc = Minecraft.getMinecraft();

    GuiScreen thisScreen = (GuiScreen) (Object) this;

    RenderGuiScreen renderGuiScreen = new RenderGuiScreen(thisScreen);
    EventManager.post(renderGuiScreen);

    if (renderGuiScreen.isCancelled()) {
        if (mc.currentScreen != null && mc.currentScreen != thisScreen) {
            mc.currentScreen.drawScreen(mouseX, mouseY, partialTicks);
        }
        ci.cancel();
    }

}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:18,代码来源:MixinGuiScreen.java

示例2: preUpdateWalkingPlayer

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "onUpdateWalkingPlayer()V", at = @At("HEAD"), cancellable = true)
public void preUpdateWalkingPlayer(CallbackInfo callbackInfo) {
    PlayerWalkingUpdate event = EventManager.post(new PlayerWalkingUpdate(this.rotationYaw, this.rotationPitch));

    _yaw = this.rotationYaw;
    _pitch = this.rotationPitch;

    if (event.isCancelled()) {
        callbackInfo.cancel();
    } else {
        if (event.getYaw() != _yaw || event.getPitch() != _pitch) {
            this.rotationYaw = wrapAngleTo180(event.getYaw());
            this.rotationPitch = wrapAngleTo180(event.getPitch());
        }
    }
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:17,代码来源:MixinEntityPlayerSP.java

示例3: onInitPotions

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "initPotions", at = @At("HEAD"), remap = false)
private static void onInitPotions(CallbackInfo callbackInfo) {
    try {
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "FLUX", PotionFluxTaint.instance);
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "VIS_EXHAUST", PotionVisExhaust.instance);
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "INFECTIOUS_VIS_EXHAUST", PotionInfectiousVisExhaust.instance);
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "UNNATURAL_HUNGER", PotionUnnaturalHunger.instance);
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "WARP_WARD", PotionWarpWard.instance);
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "DEATH_GAZE", PotionDeathGaze.instance);
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "BLURRED_VISION", PotionBlurredVision.instance);
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "SUN_SCORNED", PotionSunScorned.instance);
        RegistryHelper.setFinalStatic(ThaumicPotionEffectTypes.class, "THAUMARHIA", PotionThaumarhia.instance);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:gabizou,项目名称:ThaumicSponge,代码行数:17,代码来源:MixinConfig.java

示例4: init

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(
        method = "<init>(Lnet/minecraft/client/renderer/entity/RenderManager;Z)V",
        at = @At("RETURN"))
private void init(RenderManager renderManager, boolean useSmallArms, CallbackInfo ci) {
    this.playerModel = smallArms ? PMAPI.ponySmall : PMAPI.pony;
    this.mainModel = this.playerModel.getModel();
    this.layerRenderers.clear();

    this.addLayer(new LayerPonyArmor(this));
    this.addLayer(new LayerHeldPonyItem(this));
    this.addLayer(new LayerArrow(this));
    this.addLayer(new LayerPonyCape(this));
    this.addLayer(new LayerPonyCustomHead(this));
    this.addLayer(new LayerPonyElytra(this));
    this.addLayer(new LayerEntityOnPonyShoulder(renderManager, this));

}
 
开发者ID:MineLittlePony,项目名称:MineLittlePony,代码行数:18,代码来源:MixinRenderPlayer.java

示例5: getSkinType

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(
        method = "getSkinType",
        cancellable = true,
        at = @At("RETURN"))
private void getSkinType(CallbackInfoReturnable<String> ci) {
    MinecraftProfileTexture skin = HDSkinManager.INSTANCE.getProfileData(getGameProfile()).get(Type.SKIN);
    if (skin != null) {
        String type = skin.getMetadata("model");
        if (type == null)
            type = "default";
        String type1 = type;
        Optional<ResourceLocation> texture = HDSkinManager.INSTANCE.getSkinLocation(getGameProfile(), Type.SKIN, false);

        texture.ifPresent((res) -> ci.setReturnValue(type1));
    }
}
 
开发者ID:MineLittlePony,项目名称:MineLittlePony,代码行数:17,代码来源:MixinPlayerInfo.java

示例6: setWeathers

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "registerDefaults", at = @At("RETURN"), remap = false)
private void setWeathers(CallbackInfo ci) {
    // The weathers
    this.weathers = Maps.newHashMap();
    // Sponge has only a lookup by the name of the weather,
    // we will also add the by identifier
    for (Weather weather : this.weatherMappings.values()) {
        this.weathers.put(weather.getId().toLowerCase(), (WeatherType) weather);
        this.weathers.put(weather.getName().toLowerCase(), (WeatherType) weather);
    }
    // Add some default aliases and command messages
    ((IMixinWeather) Weathers.THUNDER_STORM).setAliases(Lists.newArrayList("storm", "thunder"));
    ((IMixinWeather) Weathers.THUNDER_STORM).setCommandMessage("commands.weather.thunder");
    ((IMixinWeather) Weathers.THUNDER_STORM).setRainStrength(1f);
    ((IMixinWeather) Weathers.THUNDER_STORM).setDarkness(1f);
    // The rate is the chance for every chunk, every tick
    ((IMixinWeather) Weathers.THUNDER_STORM).setLightningRate(0.00001f);
    ((IMixinWeather) Weathers.THUNDER_STORM).setThunderRate(1f);
    ((IMixinWeather) Weathers.CLEAR).setAliases(Lists.newArrayList("sunny"));
    ((IMixinWeather) Weathers.CLEAR).setCommandMessage("commands.weather.clear");
    ((IMixinWeather) Weathers.RAIN).setAliases(Lists.newArrayList("rainy"));
    ((IMixinWeather) Weathers.RAIN).setCommandMessage("commands.weather.rain");
    ((IMixinWeather) Weathers.RAIN).setRainStrength(1f);
    this.addAliases(Weathers.THUNDER_STORM);
    this.addAliases(Weathers.CLEAR);
}
 
开发者ID:Cybermaxke,项目名称:Weathers,代码行数:27,代码来源:MixinWeatherRegistryModule.java

示例7: onUpdate

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "update", at = @At("RETURN"))
private void onUpdate(CallbackInfo callbackInfo) {
    if (!this.world.isRemote) {
        if (this.isBurning()) {
            ItemStack itemStack = this.furnaceItemStacks[0];
            if (itemStack != null) {
                if (itemStack.getItem() instanceof ItemBlock) {
                    Block block = ((ItemBlock) itemStack.getItem()).block;
                    if (block.getMaterial(block.getStateFromMeta(itemStack.getMetadata())) == Material.TNT) {
                        this.doExplosion();
                    }
                } else if (itemStack.getItem() == Items.GUNPOWDER) {
                    this.doExplosion();
                } else if (itemStack.getItem() instanceof ItemFirework || itemStack.getItem()
                        instanceof ItemFireworkCharge) {
                    this.doExplosion();
                }
            }
        }
    }
}
 
开发者ID:GoodTimeStudio,项目名称:Production-Line,代码行数:22,代码来源:MixinTileEntityFurnace.java

示例8: onProcessHandshake

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "processHandshake", at = @At(value = "HEAD"), cancellable = true)
private void onProcessHandshake(C00Handshake packetIn, CallbackInfo ci) {
    if (packetIn.getRequestedState().equals(EnumConnectionState.LOGIN)) {
        final String[] split = packetIn.ip.split("\00");

        if (split.length >= 3) {
            packetIn.ip = split[0];
            ((IMixinNetworkManager_Bungee) this.networkManager).setRemoteAddress(new InetSocketAddress(split[1],
                            ((InetSocketAddress) this.networkManager.getRemoteAddress()).getPort()));
            ((IMixinNetworkManager_Bungee) this.networkManager).setSpoofedUUID(UUIDTypeAdapter.fromString(split[2]));

            if (split.length == 4) {
                ((IMixinNetworkManager_Bungee) this.networkManager).setSpoofedProfile(GSON.fromJson(split[3], Property[].class));
            }
        } else {
            final ChatComponentText chatcomponenttext =
                    new ChatComponentText("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
            this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext));
            this.networkManager.closeChannel(chatcomponenttext);
        }
    }
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:23,代码来源:MixinNetHandlerHandshakeTCP_Bungee.java

示例9: onPopulateEnvironment

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "populateEnvironment", at = @At("RETURN"))
private void onPopulateEnvironment(CallbackInfo ci) {
    if (Canary.pluginManager() != null) {
        this.theReportCategory.addCrashSectionCallable("Canary Plugins", () -> {
            final StringBuilder result = new StringBuilder(64);
            for (final Plugin plugin : Canary.pluginManager().getPlugins()) {
                result.append("\n\t\t")
                        .append(plugin.getName())
                        .append(" v ")
                        .append(plugin.getVersion())
                        .append(" (")
                        .append(plugin.getPath())
                        .append(")");
            }
            return result.toString();
        });
    }
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:19,代码来源:MixinCrashReport.java

示例10: onSetKeyBindState

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method="setKeyBindState", [email protected]("HEAD"), cancellable=true)
private static void onSetKeyBindState(int p_74510_0_, boolean p_74510_1_, CallbackInfo ci) {
	//methodhead

	// mod_controlpack
	// called on every mouse AND keyboard event (mouse button - 100 to avoid colliding numbers)
	if (ControlPackMain.instance.handleInputEvent(p_74510_0_, p_74510_1_)) {
		ci.cancel();
	}
	
	// mod_controlpack
	// ensure the correct keys are in the down state
	if (ControlPackMain.instance != null) {
		ControlPackMain.instance.resetPlayerKeyState();
	}
}
 
开发者ID:uyjulian,项目名称:ControlPack,代码行数:17,代码来源:MixinKeyBinding.java

示例11: onInitialization

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "<init>*", at = @At("RETURN"))
private void onInitialization(CallbackInfo ci) {

    this.chatGui = tc.getChatGui();
    this.sentHistoryCursor = chatGui.getSentMessages().size();
    this.chat = chatGui.getChatManager();
    this.textBox = chat.getChatBox().getChatInput().getTextField();

    Channel chan = chat.getActiveChannel();
    if (this.defaultInputFieldText.isEmpty()
            && !chan.isPrefixHidden()
            && !chan.getPrefix().isEmpty()) {
        defaultInputFieldText = chan.getPrefix() + " ";
    }

    this.componentList.add(chat.getChatBox());
}
 
开发者ID:killjoy1221,项目名称:TabbyChat-2,代码行数:18,代码来源:MixinGuiChat.java

示例12: onShouldSideBeRendered

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method="shouldSideBeRendered(Lnet/minecraft/world/IBlockAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;)Z", [email protected]("HEAD"), cancellable=true)
private void onShouldSideBeRendered(IBlockAccess blockAccess, BlockPos pos, EnumFacing facing, CallbackInfoReturnable<Boolean> ci) {
    if (UyjuliansXrayModMain.xrayEnabled()) {
        ci.setReturnValue((!UyjuliansXrayModMain.checkBlockList(this.getBlock())) && UyjuliansXrayModMain.checkBlockList(blockAccess.getBlockState(pos.offset(facing)).getBlock()));
    }
    else if (UyjuliansXrayModMain.caveFinderEnabled()) {
        ci.setReturnValue((!UyjuliansXrayModMain.checkBlockList(this.getBlock())) && blockAccess.isAirBlock(pos.offset(facing)));
    }
    else if (UyjuliansXrayModMain.specialMode1Enabled()) {
        if (!UyjuliansXrayModMain.checkBlockList(this.getBlock())) {
            boolean shouldRender = true;
            for (EnumFacing facing1 : new EnumFacing[]{EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST}) {
                if (blockAccess.isAirBlock(pos.offset(facing1))) {
                    shouldRender = true;
                }
                else {
                    shouldRender = false;
                    break;
                }
            }
            ci.setReturnValue(shouldRender);
        } else {
            ci.setReturnValue(false);
        }
    }
}
 
开发者ID:uyjulian,项目名称:MinecraftX-RAY,代码行数:27,代码来源:MixinStateImplementation.java

示例13: initSplashText

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "initGui()V", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILSOFT)
private void initSplashText(CallbackInfo callbackInfo, Calendar calendar) {
    if (calendar.get(Calendar.MONTH) == Calendar.JUNE && calendar.get(Calendar.DAY_OF_MONTH) == 21)
        this.splashText = "Happy Birthday Gogume1er!";
}
 
开发者ID:Gogume1er,项目名称:Past-Client,代码行数:6,代码来源:MixinGuiMainMenu.java

示例14: loadFovModifierInCache

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "getFovModifier",
        at = {
                @At(value = "INVOKE",
                        target = "Lnet/minecraft/client/entity/AbstractClientPlayer;getEntityAttribute(Lnet/minecraft/entity/ai/attributes/IAttribute;)Lnet/minecraft/entity/ai/attributes/IAttributeInstance;",
                        shift = Shift.AFTER),
                @At(value = "INVOKE",
                        target = "Lnet/minecraft/client/entity/AbstractClientPlayer;getItemInUseDuration()I",
                        shift = Shift.AFTER)
        },
        locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void loadFovModifierInCache(CallbackInfoReturnable<Float> callbackInfo, float f) {
    this.cache = f;
}
 
开发者ID:Gogume1er,项目名称:Past-Client,代码行数:14,代码来源:MixinAbstractClientPlayer.java

示例15: loadCurrentPosition

import org.spongepowered.asm.mixin.injection.Inject; //导入依赖的package包/类
@Inject(method = "renderItemInFirstPerson",
        at = @At(value = "INVOKE",
                target = "Lnet/minecraft/item/ItemStack;getItemUseAction()Lnet/minecraft/item/EnumAction;"),
        locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void loadCurrentPosition(float partialTicks, CallbackInfo callbackInfo, float f,
        AbstractClientPlayer abstractClientPlayer, float f1) {
    this.currentPosition = PastOption.OLD_BLOCKHIT.getValue() ? f1 : 0.0f;
}
 
开发者ID:Gogume1er,项目名称:Past-Client,代码行数:9,代码来源:MixinItemRenderer.java


注:本文中的org.spongepowered.asm.mixin.injection.Inject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。