Skip to content

Commit

Permalink
FoamFix 0.6.0-beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Feb 20, 2017
1 parent f86ae4a commit 7aa2f0c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.github.johnrengelman.shadow'

version = "0.5.4"
version = "0.6.0-beta1"
group= "pl.asie.foamfix" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "foamfix"

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/pl/asie/foamfix/client/FoamyItemLayerModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class FoamyItemLayerModel implements IRetexturableModel {
private static final ResourceLocation MISSINGNO = new ResourceLocation("missingno");
Expand All @@ -51,14 +50,17 @@ public class FoamyItemLayerModel implements IRetexturableModel {
float.class, float.class,float.class,float.class,float.class,
float.class, float.class,float.class,float.class,float.class));
} catch (Exception e) {
// We don't need this (there's a slow fallback route), so just warn the user.
e.printStackTrace();
}
BUILD_QUAD = handle;

handle = null;
try {
handle = MethodHandleHelper.findFieldGetter(ItemLayerModel.class, "overrides");
} catch (Exception e) {
e.printStackTrace();
// We DO need THIS, so throw a runtime exception if we can't have it.
throw new RuntimeException(e);
}
OVERRIDES_GET = handle;
}
Expand Down Expand Up @@ -233,6 +235,7 @@ public static IBakedModel bake(ItemLayerModel parent, final IModelState state, f
ImmutableList.Builder<TextureAtlasSprite> textureAtlas = new ImmutableList.Builder<>();

if (BUILD_QUAD != null) {
// Fast route!
for (int i = 0; i < textures.size(); i++) {
TextureAtlasSprite sprite = bakedTextureGetter.apply(textures.get(i));
textureAtlas.add(sprite);
Expand All @@ -248,6 +251,7 @@ public static IBakedModel bake(ItemLayerModel parent, final IModelState state, f
}
}
} else {
// Slow fallback route :-(
for (int i = 0; i < textures.size(); i++) {
TextureAtlasSprite sprite = bakedTextureGetter.apply(textures.get(i));
for (BakedQuad quad : ItemLayerModel.getQuadsForSprite(i, sprite, format, transform)) {
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/pl/asie/foamfix/coremod/blockinfo/ChunkInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ public boolean fill(IBlockAccess access, BlockPos blockPos, boolean[][][] transl
int zo = blockPos.getZ() - 1 - pos.getZ();

for(int x = 0; x <= 2; x++) {
int xb = xo+x;
int xb = xo + x;
for (int y = 0; y <= 2; y++) {
int yb = yo+y;
int offset = (xb*18*18) + (yb*18) + zo;
int zb = zo;
int offset = (xb*18*18) + (yb*18) + zb;

for (int z = 0; z <= 2; z++) {
int zb = zo+z;

if (!initialized[offset])
initialize(access,offset,xb,yb,zb);
Expand All @@ -40,7 +41,7 @@ public boolean fill(IBlockAccess access, BlockPos blockPos, boolean[][][] transl
b[x][y][z] = this.b[offset];
ao[x][y][z] = this.ao[offset];

offset++;
offset++; zb++;
}
}
}
Expand All @@ -51,12 +52,12 @@ public boolean fill(IBlockAccess access, BlockPos blockPos, boolean[][][] transl
private void initialize(IBlockAccess access, int offset, int x, int y, int z) {
BlockPos pos = this.pos.add(x, y, z);
IBlockState state = access.getBlockState(pos);
fullCube[x][y][z] = state.isFullCube();
translucent[offset] = state.isTranslucent();
int brightness = state.getPackedLightmapCoords(access, pos);
ao[offset] = state.getAmbientOcclusionLightValue();
s[offset] = (brightness >> 0x14) & 0xF;
b[offset] = (brightness >> 0x04) & 0xF;
ao[offset] = state.getAmbientOcclusionLightValue();
fullCube[x][y][z] = state.isFullCube();
initialized[offset] = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import java.util.WeakHashMap;

public class ChunkInfoProvider {
private static final WeakHashMap<ChunkCache, ChunkInfo> infoMap = new WeakHashMap<>();
private static final WeakHashMap<IBlockAccess, ChunkInfo> infoMap = new WeakHashMap<>();

@Nullable
public static ChunkInfo getChunkInfo(IBlockAccess access, BlockPos pos) {
if (access instanceof ChunkCache) {
ChunkInfo info = infoMap.get(access);
if (info == null) {
info = new ChunkInfo(new BlockPos(pos.getX() & (~15), pos.getY() & (~15), pos.getZ() & (~15)));
infoMap.put((ChunkCache) access, info);
infoMap.put(access, info);
}
return info;
} else {
Expand Down

0 comments on commit 7aa2f0c

Please sign in to comment.