Skip to content

Commit

Permalink
特效增加
Browse files Browse the repository at this point in the history
  • Loading branch information
huige233 committed Jun 8, 2023
1 parent 556a352 commit 62af113
Show file tree
Hide file tree
Showing 104 changed files with 3,466 additions and 581 deletions.
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ repositories {
mavenCentral()
mavenLocal()
maven { url = "https://maven.aliyun.com/nexus/content/groups/public/" }

maven {
name 'IC2'
url 'http://maven.ic2.player.to'
}
maven {
name = "buildcraft"
url = "https://mod-buildcraft.com/maven"
Expand Down Expand Up @@ -112,7 +115,6 @@ mixin {

dependencies {
implementation 'org.jetbrains:annotations:23.0.0'
compile 'net.industrial-craft:industrialcraft-2:2.2.650-experimental:api'
deobfCompile "mezz.jei:jei_${mc_version}:${jei_version}"
deobfCompile "com.github.mcjty:mcjtylib:${mc_short}-${mcjtylib_version}"
deobfCompile "vazkii.botania:Botania:${botania_version}"
Expand All @@ -135,7 +137,8 @@ dependencies {
}
//compile fileTree(dir:'libs',includes:['*jar'])
deobfCompile "mods:Baubles:1.12-1.5.2"
deobfCompile "mods:industrialcraft-2:2.8.188-ex112"
runtimeOnly "net.industrial-craft:industrialcraft-2:2.8.221-ex112"
compileOnly "net.industrial-craft:industrialcraft-2:2.8.221-ex112:dev"
deobfCompile "mods:SlashBlade:OHHH"
deobfCompile ("zone.rong:mixinbooter:4.2")
runtime "curse.maven:bwmcore-${bwm_core}"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
dependencies = "required-after:mixinbooter@[0.0,);required-after:baubles@[1.5.2,)",
acceptedMinecraftVersions = "[1.12.2]"
)
public class Main implements ILateMixinLoader {
public class Transcend implements ILateMixinLoader {

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.COMMON_PROXY_CLASS)
public static CommonProxy proxy;

@Mod.Instance("transcend")
public static Main instance;
public static Transcend instance;
/**
* This is the first initialization event. Register tile entities here.
* The registry events below will have fired prior to entry to this method.
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/huige233/transcend/api/BossType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package huige233.transcend.api;

public enum BossType {
TRANSCEND,NORMAL_BOSS;
}
74 changes: 74 additions & 0 deletions src/main/java/huige233/transcend/api/ClientScheduler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package huige233.transcend.api;


import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.util.EnumSet;
import java.util.Iterator;
import java.util.LinkedList;

public class ClientScheduler implements ITickHandler {
private static long clientTick = 0;
private static final Object lock = new Object();

private boolean inTick = false;
private LinkedList<Tuple<Runnable, Counter>> queue = new LinkedList<>();
private LinkedList<Tuple<Runnable, Integer>> waiting = new LinkedList<>();

@Override
public void tick(TickEvent.Type type, Object... context) {
clientTick++;

inTick = true;
synchronized (lock) {
inTick = true;
Iterator<Tuple<Runnable, Counter>> iterator = queue.iterator();
while (iterator.hasNext()) {
Tuple<Runnable, Counter> r = iterator.next();
r.value.decrement();
if(r.value.value <= 0) {
r.key.run();
iterator.remove();
}
}
inTick = false;
for (Tuple<Runnable, Integer> wait : waiting) {
queue.addLast(new Tuple<>(wait.key, new Counter(wait.value)));
}
}
waiting.clear();
}

public static long getClientTick() {
return clientTick;
}

public static long getIndependentClientTick() {
return System.currentTimeMillis() / 50;
}

@Override
public EnumSet<TickEvent.Type> getHandledTypes() {
return EnumSet.of(TickEvent.Type.CLIENT);
}

@Override
public boolean canFire(TickEvent.Phase phase) {
return phase == TickEvent.Phase.END;
}

@Override
public String getName() {
return "Client Scheduler";
}

public void addRunnable(Runnable r, int tickDelay) {
synchronized (lock) {
if(inTick) {
waiting.addLast(new Tuple<>(r, tickDelay));
} else {
queue.addLast(new Tuple<>(r, new Counter(tickDelay)));
}
}
}
}
17 changes: 17 additions & 0 deletions src/main/java/huige233/transcend/api/Counter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package huige233.transcend.api;

public class Counter {
public int value;

public Counter(int value) {
this.value = value;
}

public void decrement() {
value--;
}

public void increment() {
value++;
}
}
29 changes: 29 additions & 0 deletions src/main/java/huige233/transcend/api/IColorEffect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package huige233.transcend.api;

public interface IColorEffect {
public boolean canRemove();

public boolean isRemoved();

public void flagAsRemoved();

public void clearRemoveFlag();

public RenderTarget getRenderTarget();

public void render(float pTicks);

public void tick();
default public int getLayer() {
return 0;
}

public static enum RenderTarget {

OVERLAY_TEXT,
RENDERLOOP

}

public static interface PreventRemoval {}
}
22 changes: 22 additions & 0 deletions src/main/java/huige233/transcend/api/ITickHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package huige233.transcend.api;

import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.util.EnumSet;

public interface ITickHandler {
public void tick(TickEvent.Type type, Object... context);

/**
* WORLD, context: world
* SERVER, context:
* CLIENT, context:
* RENDER, context: pTicks
* PLAYER, context: player, side
*/
public EnumSet<TickEvent.Type> getHandledTypes();

public boolean canFire(TickEvent.Phase phase);

public String getName();
}
10 changes: 10 additions & 0 deletions src/main/java/huige233/transcend/api/ITrBoss.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package huige233.transcend.api;

import java.util.UUID;

public interface ITrBoss {
public UUID getBoosInfoUuid();
public default BossType getBossType(){
return BossType.NORMAL_BOSS;
}
}
80 changes: 80 additions & 0 deletions src/main/java/huige233/transcend/api/TickManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package huige233.transcend.api;


import huige233.transcend.event.ClientInitEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class TickManager {
private static boolean firedFirstTick = false;
private static final TickManager instance = new TickManager();

private Map<TickEvent.Type, List<ITickHandler>> registeredTickHandlers = new HashMap<>();

private TickManager() {
for (TickEvent.Type type : TickEvent.Type.values()) {
registeredTickHandlers.put(type, new LinkedList<>());
}
}

public static TickManager getInstance() {
return instance;
}

public void register(ITickHandler handler) {
for (TickEvent.Type type : handler.getHandledTypes()) {
registeredTickHandlers.get(type).add(handler);
}
}

@SubscribeEvent
public void worldTick(TickEvent.WorldTickEvent event) {
TickEvent.Phase ph = event.phase;
for (ITickHandler handler : registeredTickHandlers.get(TickEvent.Type.WORLD)) {
if(handler.canFire(ph)) handler.tick(TickEvent.Type.WORLD, event.world);
}
}

@SubscribeEvent
public void serverTick(TickEvent.ServerTickEvent event) {
TickEvent.Phase ph = event.phase;
for (ITickHandler handler : registeredTickHandlers.get(TickEvent.Type.SERVER)) {
if(handler.canFire(ph)) handler.tick(TickEvent.Type.SERVER);
}
}

@SubscribeEvent
public void clientTick(TickEvent.ClientTickEvent event) {
TickEvent.Phase ph = event.phase;
for (ITickHandler handler : registeredTickHandlers.get(TickEvent.Type.CLIENT)) {
if(handler.canFire(ph)) handler.tick(TickEvent.Type.CLIENT);
}

if(!firedFirstTick) {
firedFirstTick = true;
MinecraftForge.EVENT_BUS.post(new ClientInitEvent());
}
}

@SubscribeEvent
public void renderTick(TickEvent.RenderTickEvent event) {
TickEvent.Phase ph = event.phase;
for (ITickHandler handler : registeredTickHandlers.get(TickEvent.Type.RENDER)) {
if(handler.canFire(ph)) handler.tick(TickEvent.Type.RENDER, event.renderTickTime);
}
}

@SubscribeEvent
public void playerTick(TickEvent.PlayerTickEvent event) {
TickEvent.Phase ph = event.phase;
for (ITickHandler handler : registeredTickHandlers.get(TickEvent.Type.PLAYER)) {
if(handler.canFire(ph)) handler.tick(TickEvent.Type.PLAYER, event.player, event.side);
}
}
}
44 changes: 44 additions & 0 deletions src/main/java/huige233/transcend/api/Tuple.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package huige233.transcend.api;

public class Tuple<K, V> {

public final K key;
public final V value;

public Tuple(K key, V value) {
this.key = key;
this.value = value;
}

public K getKey() {
return key;
}

public V getValue() {
return value;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

hellfirepvp.astralsorcery.common.util.data.Tuple tuple = (hellfirepvp.astralsorcery.common.util.data.Tuple) o;
return (key == null ? tuple.key == null : key.equals(tuple.key)) && (value == null ? tuple.value == null : value.equals(tuple.value));
}

@Override
public int hashCode() {
int result = key == null ? 0 : key.hashCode();
result = 31 * result + (value == null ? 0 : value.hashCode());
return result;
}

@Override
public String toString() {
return "Tuple{" +
"key=" + key +
", value=" + value +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package huige233.transcend.asm.transformers;

import org.objectweb.asm.*;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.MethodNode;

import java.util.Arrays;
import java.util.Map;

public class ChatAllowedCharactersTransformer implements ITransformer {

@Override
public String targetClass() {
return "net.minecraft.util.ChatAllowedCharacters";
}

@Override
public ClassNode transform(ClassNode cn) {

for (MethodNode method : cn.methods) {
String name = method.name;
String desc = method.desc;
if (name.equals("a") && desc.equals("(C)Z") || name.equals("isAllowedCharacter")) {
Arrays.stream(method.instructions.toArray())
.filter(abstractInsnNode -> abstractInsnNode.getOpcode() == Opcodes.SIPUSH)
.findFirst().ifPresent(abstractInsnNode -> {
method.instructions.set(abstractInsnNode, new AbstractInsnNode(abstractInsnNode.getOpcode()) {
@Override
public int getType() {
return abstractInsnNode.getType();
}

@Override
public void accept(MethodVisitor cv) {
cv.visitIntInsn(Opcodes.SIPUSH, 127);
}

@Override
public AbstractInsnNode clone(Map<LabelNode, LabelNode> labels) {
return abstractInsnNode.clone(labels);
}
});
});
}
}
return cn;
}
}
Loading

0 comments on commit 62af113

Please sign in to comment.