mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-22 07:22:13 +00:00
Version 0.8-preview
Add initial modlauncher support Bump ASM version and remove renamed ASM for modlauncher interop Conform static accessor target when transforming accessor, Fixes #342 Detect staticness mismatch on accessors, Fixes #341 Allow Invoker to invoke constructors, Closes #339 Remove commons-io and replace with guava, Fixes #327 Fix refmap generation for non-obfuscated derived classes, Fixes #326 Specify locale for case conversions, Fixes #315 Handle accessor overlap more intelligently, Fixes #307 Add SuppressWarnings support to Annotation Processor, Closes #306 Allow mixins applied to a class to be retrieved easily, Closes #302 Conform refmap entries as they are added to the mapper, fixes #296 Fold in misc lvt generation fixes from fabricmc, closes #295 Fail fast when final method is accidentally hidden by mixin, fixes #293 Fix bug handling 2-slot args in cb injector and args gen, fixes #287 Handle accessor mixin types correctly in mixins, Fixes #305, Fixes #288
This commit is contained in:
1 parent
ab935e061f
commit
fd2f2c79c5
246 files changed
+10899
-3125
No files matched your search
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* This file is part of Mixin, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) SpongePowered <https://www.spongepowered.org>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.asm.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.launch.platform.IMixinPlatformAgent;
|
||||
import org.spongepowered.asm.launch.platform.IMixinPlatformServiceAgent;
|
||||
import org.spongepowered.asm.launch.platform.container.IContainerHandle;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
import org.spongepowered.asm.util.IConsumer;
|
||||
import org.spongepowered.asm.util.ReEntranceLock;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
|
||||
/**
|
||||
* Mixin Service base class
|
||||
*/
|
||||
public abstract class MixinServiceAbstract implements IMixinService {
|
||||
|
||||
// Consts
|
||||
protected static final String LAUNCH_PACKAGE = "org.spongepowered.asm.launch.";
|
||||
protected static final String MIXIN_PACKAGE = "org.spongepowered.asm.mixin.";
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
protected static final Logger logger = LogManager.getLogger("mixin");
|
||||
|
||||
/**
|
||||
* Transformer re-entrance lock, shared between the mixin transformer and
|
||||
* the metadata service
|
||||
*/
|
||||
protected final ReEntranceLock lock = new ReEntranceLock(1);
|
||||
|
||||
/**
|
||||
* Service agent instances
|
||||
*/
|
||||
private List<IMixinPlatformServiceAgent> serviceAgents;
|
||||
|
||||
/**
|
||||
* Detected side name
|
||||
*/
|
||||
private String sideName;
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Phase getInitialPhase() {
|
||||
return Phase.PREINIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginPhase() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkEnv(Object bootSource) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.asm.service.IMixinService#init()
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
for (IMixinPlatformServiceAgent agent : this.getServiceAgents()) {
|
||||
agent.init();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.asm.service.IMixinService#getReEntranceLock()
|
||||
*/
|
||||
@Override
|
||||
public ReEntranceLock getReEntranceLock() {
|
||||
return this.lock;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.asm.service.IMixinService#getMixinContainers()
|
||||
*/
|
||||
@Override
|
||||
public Collection<IContainerHandle> getMixinContainers() {
|
||||
Builder<IContainerHandle> list = ImmutableList.<IContainerHandle>builder();
|
||||
this.getContainersFromAgents(list);
|
||||
return list.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect mixin containers from platform agents
|
||||
*/
|
||||
protected final void getContainersFromAgents(Builder<IContainerHandle> list) {
|
||||
for (IMixinPlatformServiceAgent agent : this.getServiceAgents()) {
|
||||
Collection<IContainerHandle> containers = agent.getMixinContainers();
|
||||
if (containers != null) {
|
||||
list.addAll(containers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.asm.service.IMixinService#getSideName()
|
||||
*/
|
||||
@Override
|
||||
public final String getSideName() {
|
||||
if (this.sideName != null) {
|
||||
return this.sideName;
|
||||
}
|
||||
|
||||
for (IMixinPlatformServiceAgent agent : this.getServiceAgents()) {
|
||||
try {
|
||||
String side = agent.getSideName();
|
||||
if (side != null) {
|
||||
return this.sideName = side;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
MixinServiceAbstract.logger.catching(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return Constants.SIDE_UNKNOWN;
|
||||
}
|
||||
|
||||
private List<IMixinPlatformServiceAgent> getServiceAgents() {
|
||||
if (this.serviceAgents != null) {
|
||||
return this.serviceAgents;
|
||||
}
|
||||
this.serviceAgents = new ArrayList<IMixinPlatformServiceAgent>();
|
||||
for (String agentClassName : this.getPlatformAgents()) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<IMixinPlatformAgent> agentClass = (Class<IMixinPlatformAgent>)this.getClassProvider().findClass(agentClassName, false);
|
||||
IMixinPlatformAgent agent = agentClass.newInstance();
|
||||
if (agent instanceof IMixinPlatformServiceAgent) {
|
||||
this.serviceAgents.add((IMixinPlatformServiceAgent)agent);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Bad?
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return this.serviceAgents;
|
||||
}
|
||||
|
||||
// AMS - TEMP WIRING TO AVOID THE COMPLEXITY OF MERGING MULTIPHASE WITH 0.8
|
||||
|
||||
/**
|
||||
* Temp wiring. Called when the initial phase is spun up in the environment.
|
||||
*
|
||||
* @param phase Initial phase
|
||||
* @param phaseConsumer Delegate for the service (or agents) to trigger
|
||||
* later phases
|
||||
* @deprecated temporary
|
||||
*/
|
||||
@Deprecated
|
||||
public void wire(Phase phase, IConsumer<Phase> phaseConsumer) {
|
||||
for (IMixinPlatformServiceAgent agent : this.getServiceAgents()) {
|
||||
agent.wire(phase, phaseConsumer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Temp wiring. Called when the default phase is started in the environment.
|
||||
* @deprecated temporary
|
||||
*/
|
||||
@Deprecated
|
||||
public void unwire() {
|
||||
for (IMixinPlatformServiceAgent agent : this.getServiceAgents()) {
|
||||
agent.unwire();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user