本文整理汇总了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();
}
}
示例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());
}
}
}
示例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();
}
}
示例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));
}
示例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));
}
}
示例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);
}
示例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();
}
}
}
}
}
示例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);
}
}
}
示例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();
});
}
}
示例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();
}
}
示例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());
}
示例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);
}
}
}
示例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!";
}
示例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;
}
示例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;
}