Skip to content

Commit

Permalink
fix #23
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Jan 12, 2017
1 parent a231f8f commit 88e66af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/main/java/pl/asie/foamfix/coremod/BlockInfoPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class BlockInfoPatch {

public void updateLightMatrix() {
boolean full = false;

// FOAMFIX: Instead of generating 27 objects, we can really generate
// just one - and we don't save much speed by not doing so either.
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
int xo = blockPos.getX() - 1;
int yo = blockPos.getY() - 1;
Expand Down Expand Up @@ -70,7 +73,8 @@ public void updateLightMatrix() {
skyLight[1][x][y][z] = combine(s[1][y1][1], s[x1][y1][1], s[1][y1][z1], ty ? s[x1][y1][z1] : s[1][y1][1]);
blockLight[1][x][y][z] = combine(b[1][y1][1], b[x1][y1][1], b[1][y1][z1], ty ? b[x1][y1][z1] : b[1][y1][1]);

boolean tz = translucent[x1][1][z1] || translucent[1][y1][z1];
// FOAMFIX: typo fix - should be in Forge soon
boolean tz = translucent[1][y1][z1] || translucent[x1][1][z1];
skyLight[2][x][y][z] = combine(s[1][1][z1], s[1][y1][z1], s[x1][1][z1], tz ? s[x1][y1][z1] : s[1][1][z1]);
blockLight[2][x][y][z] = combine(b[1][1][z1], b[1][y1][z1], b[x1][1][z1], tz ? b[x1][y1][z1] : b[1][1][z1]);
}
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/pl/asie/foamfix/coremod/BlockPosPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package pl.asie.foamfix.coremod;

import net.minecraftforge.fml.common.discovery.ASMDataTable;
import org.objectweb.asm.*;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
Expand All @@ -35,6 +36,7 @@
public class BlockPosPatch {
private static final HashMap<String, String> mutableFieldSwaps = new HashMap<>();
private static final HashSet<String> mutableDeletedMethods = new HashSet<>();
private static final HashSet<String> mutableOwners = new HashSet<>();

static {
mutableFieldSwaps.put("x", "x");
Expand All @@ -52,6 +54,8 @@ public class BlockPosPatch {
mutableDeletedMethods.add("func_177958_n");
mutableDeletedMethods.add("func_177956_o");
mutableDeletedMethods.add("func_177952_p");

mutableOwners.add("net/minecraft/util/math/BlockPos$MutableBlockPos");
}

private static class BlockPosClassVisitor extends ClassVisitor {
Expand All @@ -62,6 +66,15 @@ public BlockPosClassVisitor(int api, ClassVisitor next, boolean isMutable) {
this.isMutable = isMutable;
}

@Override
public void visit(int version, int access, String name, String signature,
String superName, String[] interfaces) {
if (mutableOwners.contains(superName)) {
mutableOwners.add(name);
}
cv.visit(version, access, name, signature, superName, interfaces);
}

@Override
public FieldVisitor visitField(int access, String name, String desc,
String signature, Object value) {
Expand Down Expand Up @@ -91,7 +104,7 @@ public BlockPosMethodVisitor(int api, MethodVisitor mv) {
@Override
public void visitFieldInsn(int opcode, String owner, String name,
String desc) {
if ("net/minecraft/util/math/BlockPos$MutableBlockPos".equals(owner)) {
if (mutableOwners.contains(owner)) {
String dst = mutableFieldSwaps.get(name);
if (dst != null) {
mv.visitFieldInsn(opcode, "net/minecraft/util/math/Vec3i", dst, desc);
Expand Down

0 comments on commit 88e66af

Please sign in to comment.