mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 22:44:32 +00:00
Regenerate patches with relative headers. This should lower conflicts in future PRs.
Convert Forge to use Official mappings. Mojang released their obfuscation mappings but we have not used them up until now due to wanting to get their license to be more explicitly permissive. It is clear that their intent is to allow us to use their names for developing mods like this. See the full wording, and our interpretation here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
This commit is contained in:
1 parent
802298d99d
commit
a95b968c13
832 files changed
+4464
-4373
No files matched your search
@@ -61,11 +61,11 @@ public class BakedItemModel implements IBakedModel
|
||||
return guiTransform == null || guiTransform.isIdentity();
|
||||
}
|
||||
|
||||
@Override public boolean isAmbientOcclusion() { return true; }
|
||||
@Override public boolean useAmbientOcclusion() { return true; }
|
||||
@Override public boolean isGui3d() { return false; }
|
||||
@Override public boolean isSideLit() { return isSideLit; }
|
||||
@Override public boolean isBuiltInRenderer() { return false; }
|
||||
@Override public TextureAtlasSprite getParticleTexture() { return particle; }
|
||||
@Override public boolean usesBlockLight() { return isSideLit; }
|
||||
@Override public boolean isCustomRenderer() { return false; }
|
||||
@Override public TextureAtlasSprite getParticleIcon() { return particle; }
|
||||
@Override public ItemOverrideList getOverrides() { return overrides; }
|
||||
|
||||
@Override
|
||||
@@ -98,7 +98,7 @@ public class BakedItemModel implements IBakedModel
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
for (BakedQuad quad : originalModel.quads)
|
||||
{
|
||||
if (quad.getFace() == Direction.SOUTH)
|
||||
if (quad.getDirection() == Direction.SOUTH)
|
||||
{
|
||||
builder.add(quad);
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
public boolean useAmbientOcclusion()
|
||||
{
|
||||
return originalModel.isAmbientOcclusion();
|
||||
return originalModel.useAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,27 +70,27 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit()
|
||||
public boolean usesBlockLight()
|
||||
{
|
||||
return originalModel.isSideLit();
|
||||
return originalModel.usesBlockLight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
public boolean isCustomRenderer()
|
||||
{
|
||||
return originalModel.isBuiltInRenderer();
|
||||
return originalModel.isCustomRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
public TextureAtlasSprite getParticleIcon()
|
||||
{
|
||||
return originalModel.getParticleTexture();
|
||||
return originalModel.getParticleIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
public ItemCameraTransforms getTransforms()
|
||||
{
|
||||
return originalModel.getItemCameraTransforms();
|
||||
return originalModel.getTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -95,13 +95,13 @@ public class BlockModelConfiguration implements IModelConfiguration
|
||||
@Override
|
||||
public boolean isTexturePresent(String name)
|
||||
{
|
||||
return owner.isTexturePresent(name);
|
||||
return owner.hasTexture(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderMaterial resolveTexture(String name)
|
||||
{
|
||||
return owner.resolveTextureName(name);
|
||||
return owner.getMaterial(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,19 +112,19 @@ public class BlockModelConfiguration implements IModelConfiguration
|
||||
@Override
|
||||
public boolean isSideLit()
|
||||
{
|
||||
return owner.getGuiLight().isSideLit();
|
||||
return owner.getGuiLight().lightLikeBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSmoothLighting()
|
||||
{
|
||||
return owner.isAmbientOcclusion();
|
||||
return owner.hasAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getCameraTransforms()
|
||||
{
|
||||
return owner.getAllTransforms();
|
||||
return owner.getTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -88,7 +88,7 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
public boolean useAmbientOcclusion()
|
||||
{
|
||||
return isAmbientOcclusion;
|
||||
}
|
||||
@@ -100,19 +100,19 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit()
|
||||
public boolean usesBlockLight()
|
||||
{
|
||||
return isSideLit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
public boolean isCustomRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
public TextureAtlasSprite getParticleIcon()
|
||||
{
|
||||
return particle;
|
||||
}
|
||||
@@ -168,14 +168,14 @@ public class CompositeModel implements IDynamicBakedModel
|
||||
|
||||
public IBakedModel bakeModel(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
return model.bakeModel(bakery, spriteGetter, new ModelTransformComposition(this.modelTransform, modelTransform,
|
||||
this.modelTransform.isUvLock() || modelTransform.isUvLock()), modelLocation);
|
||||
return model.bake(bakery, spriteGetter, new ModelTransformComposition(this.modelTransform, modelTransform,
|
||||
this.modelTransform.isUvLocked() || modelTransform.isUvLocked()), modelLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
return model.getTextures(modelGetter, missingTextureErrors);
|
||||
return model.getMaterials(modelGetter, missingTextureErrors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
if (flipGas && fluid != Fluids.EMPTY && fluid.getAttributes().isLighterThanAir())
|
||||
{
|
||||
modelTransform = new SimpleModelTransform(
|
||||
modelTransform.getRotation().blockCornerToCenter().composeVanilla(
|
||||
modelTransform.getRotation().blockCornerToCenter().compose(
|
||||
new TransformationMatrix(null, new Quaternion(0, 0, 1, 0), null, null)).blockCenterToCorner());
|
||||
}
|
||||
|
||||
@@ -259,9 +259,9 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel getOverrideModel(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
|
||||
public IBakedModel resolve(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
|
||||
{
|
||||
IBakedModel overriden = nested.getOverrideModel(originalModel, stack, world, entity);
|
||||
IBakedModel overriden = nested.resolve(originalModel, stack, world, entity);
|
||||
if (overriden != originalModel) return overriden;
|
||||
return FluidUtil.getFluidContained(stack)
|
||||
.map(fluidStack -> {
|
||||
|
||||
@@ -320,8 +320,8 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
// sides
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Direction side = Direction.byHorizontalIndex((5 - i) % 4); // [W, S, E, N]
|
||||
boolean useOverlay = overlay.isPresent() && sideOverlays[side.getHorizontalIndex()];
|
||||
Direction side = Direction.from2DDataValue((5 - i) % 4); // [W, S, E, N]
|
||||
boolean useOverlay = overlay.isPresent() && sideOverlays[side.get2DDataValue()];
|
||||
int si = i; // local var for lambda capture
|
||||
|
||||
VertexParameter sideX = j -> x[(si + x[j]) % 4];
|
||||
@@ -377,8 +377,8 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
putVertex(
|
||||
consumer, side, offset,
|
||||
x.get(vertex), y.get(vertex), z.get(vertex),
|
||||
texture.getInterpolatedU(u.get(vertex)),
|
||||
texture.getInterpolatedV(v.get(vertex))
|
||||
texture.getU(u.get(vertex)),
|
||||
texture.getV(v.get(vertex))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -394,9 +394,9 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
switch(elements.get(e).getUsage())
|
||||
{
|
||||
case POSITION:
|
||||
float dx = offset ? side.getDirectionVec().getX() * eps : 0f;
|
||||
float dy = offset ? side.getDirectionVec().getY() * eps : 0f;
|
||||
float dz = offset ? side.getDirectionVec().getZ() * eps : 0f;
|
||||
float dx = offset ? side.getNormal().getX() * eps : 0f;
|
||||
float dy = offset ? side.getNormal().getY() * eps : 0f;
|
||||
float dz = offset ? side.getNormal().getZ() * eps : 0f;
|
||||
consumer.put(e, x - dx, y - dy, z - dz, 1f);
|
||||
break;
|
||||
case COLOR:
|
||||
@@ -407,9 +407,9 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
consumer.put(e, r, g, b, a);
|
||||
break;
|
||||
case NORMAL:
|
||||
float offX = (float) side.getXOffset();
|
||||
float offY = (float) side.getYOffset();
|
||||
float offZ = (float) side.getZOffset();
|
||||
float offX = (float) side.getStepX();
|
||||
float offY = (float) side.getStepY();
|
||||
float offZ = (float) side.getStepZ();
|
||||
consumer.put(e, offX, offY, offZ, 0f);
|
||||
break;
|
||||
case UV:
|
||||
@@ -427,7 +427,7 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
public boolean useAmbientOcclusion()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -439,19 +439,19 @@ public final class FluidModel implements IModelGeometry<FluidModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit()
|
||||
public boolean usesBlockLight()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
public boolean isCustomRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
public TextureAtlasSprite getParticleIcon()
|
||||
{
|
||||
return still;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
{
|
||||
static IModelBuilder<?> of(IModelConfiguration owner, ItemOverrideList overrides, TextureAtlasSprite particle)
|
||||
{
|
||||
return new Simple(new SimpleBakedModel.Builder(owner, overrides).setTexture(particle));
|
||||
return new Simple(new SimpleBakedModel.Builder(owner, overrides).particle(particle));
|
||||
}
|
||||
|
||||
T addFaceQuad(Direction facing, BakedQuad quad);
|
||||
@@ -49,14 +49,14 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
@Override
|
||||
public Simple addFaceQuad(Direction facing, BakedQuad quad)
|
||||
{
|
||||
builder.addFaceQuad(facing, quad);
|
||||
builder.addCulledFace(facing, quad);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Simple addGeneralQuad(BakedQuad quad)
|
||||
{
|
||||
builder.addGeneralQuad(quad);
|
||||
builder.addUnculledFace(quad);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -296,17 +296,17 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
|
||||
// front
|
||||
builder.add(buildQuad(transform, Direction.NORTH, sprite, tint, fullbright,
|
||||
0, 0, 7.5f / 16f, sprite.getMinU(), sprite.getMaxV(),
|
||||
0, 1, 7.5f / 16f, sprite.getMinU(), sprite.getMinV(),
|
||||
1, 1, 7.5f / 16f, sprite.getMaxU(), sprite.getMinV(),
|
||||
1, 0, 7.5f / 16f, sprite.getMaxU(), sprite.getMaxV()
|
||||
0, 0, 7.5f / 16f, sprite.getU0(), sprite.getV1(),
|
||||
0, 1, 7.5f / 16f, sprite.getU0(), sprite.getV0(),
|
||||
1, 1, 7.5f / 16f, sprite.getU1(), sprite.getV0(),
|
||||
1, 0, 7.5f / 16f, sprite.getU1(), sprite.getV1()
|
||||
));
|
||||
// back
|
||||
builder.add(buildQuad(transform, Direction.SOUTH, sprite, tint, fullbright,
|
||||
0, 0, 8.5f / 16f, sprite.getMinU(), sprite.getMaxV(),
|
||||
1, 0, 8.5f / 16f, sprite.getMaxU(), sprite.getMaxV(),
|
||||
1, 1, 8.5f / 16f, sprite.getMaxU(), sprite.getMinV(),
|
||||
0, 1, 8.5f / 16f, sprite.getMinU(), sprite.getMinV()
|
||||
0, 0, 8.5f / 16f, sprite.getU0(), sprite.getV1(),
|
||||
1, 0, 8.5f / 16f, sprite.getU1(), sprite.getV1(),
|
||||
1, 1, 8.5f / 16f, sprite.getU1(), sprite.getV0(),
|
||||
0, 1, 8.5f / 16f, sprite.getU0(), sprite.getV0()
|
||||
));
|
||||
|
||||
return builder.build();
|
||||
@@ -381,8 +381,8 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
throw new IllegalArgumentException("can't handle z-oriented side");
|
||||
}
|
||||
|
||||
float dx = side.getDirectionVec().getX() * eps / width;
|
||||
float dy = side.getDirectionVec().getY() * eps / height;
|
||||
float dx = side.getNormal().getX() * eps / width;
|
||||
float dy = side.getNormal().getY() * eps / height;
|
||||
|
||||
float u0 = 16f * (x0 - dx);
|
||||
float u1 = 16f * (x1 - dx);
|
||||
@@ -391,10 +391,10 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
|
||||
return buildQuad(
|
||||
transform, remap(side), sprite, tint, fullbright,
|
||||
x0, y0, z0, sprite.getInterpolatedU(u0), sprite.getInterpolatedV(v0),
|
||||
x1, y1, z0, sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1),
|
||||
x1, y1, z1, sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1),
|
||||
x0, y0, z1, sprite.getInterpolatedU(u0), sprite.getInterpolatedV(v0)
|
||||
x0, y0, z0, sprite.getU(u0), sprite.getV(v0),
|
||||
x1, y1, z0, sprite.getU(u1), sprite.getV(v1),
|
||||
x1, y1, z1, sprite.getU(u1), sprite.getV(v1),
|
||||
x0, y0, z1, sprite.getU(u0), sprite.getV(v0)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -445,9 +445,9 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
consumer.put(e, 1f, 1f, 1f, 1f);
|
||||
break;
|
||||
case NORMAL:
|
||||
float offX = (float) side.getXOffset();
|
||||
float offY = (float) side.getYOffset();
|
||||
float offZ = (float) side.getZOffset();
|
||||
float offX = (float) side.getStepX();
|
||||
float offY = (float) side.getStepY();
|
||||
float offZ = (float) side.getStepZ();
|
||||
consumer.put(e, offX, offY, offZ, 0f);
|
||||
break;
|
||||
case UV:
|
||||
@@ -484,7 +484,7 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
|
||||
ImmutableSet.Builder<Integer> fullbrightLayers = ImmutableSet.builder();
|
||||
if (modelContents.has("fullbright_layers"))
|
||||
{
|
||||
JsonArray arr = JSONUtils.getJsonArray(modelContents, "fullbright_layers");
|
||||
JsonArray arr = JSONUtils.getAsJsonArray(modelContents, "fullbright_layers");
|
||||
for(int i=0;i<arr.size();i++)
|
||||
{
|
||||
fullbrightLayers.add(arr.get(i).getAsInt());
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
public boolean useAmbientOcclusion()
|
||||
{
|
||||
return smoothLighting;
|
||||
}
|
||||
@@ -88,19 +88,19 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit()
|
||||
public boolean usesBlockLight()
|
||||
{
|
||||
return sideLit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
public boolean isCustomRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
public TextureAtlasSprite getParticleIcon()
|
||||
{
|
||||
return particle;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public final class ItemTextureQuadConverter
|
||||
boolean sameRow = true;
|
||||
for (int x = 0; x < w; x++)
|
||||
{
|
||||
if (template.isPixelTransparent(0, x, y) != template.isPixelTransparent(0, x, startY))
|
||||
if (template.isTransparent(0, x, y) != template.isTransparent(0, x, startY))
|
||||
{
|
||||
sameRow = false;
|
||||
break;
|
||||
@@ -111,7 +111,7 @@ public final class ItemTextureQuadConverter
|
||||
if (x < w)
|
||||
{
|
||||
// current pixel
|
||||
boolean isVisible = !template.isPixelTransparent(0, x, startY);
|
||||
boolean isVisible = !template.isTransparent(0, x, startY);
|
||||
|
||||
// no current quad but found a new one
|
||||
if (startX < 0 && isVisible)
|
||||
@@ -173,7 +173,7 @@ public final class ItemTextureQuadConverter
|
||||
boolean sameColumn = true;
|
||||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
if (template.isPixelTransparent(0, x, y) != template.isPixelTransparent(0, startX, y))
|
||||
if (template.isTransparent(0, x, y) != template.isTransparent(0, startX, y))
|
||||
{
|
||||
sameColumn = false;
|
||||
break;
|
||||
@@ -193,7 +193,7 @@ public final class ItemTextureQuadConverter
|
||||
if (y < h)
|
||||
{
|
||||
// current pixel
|
||||
boolean isVisible = !template.isPixelTransparent(0, startX, y);
|
||||
boolean isVisible = !template.isTransparent(0, startX, y);
|
||||
|
||||
// no current quad but found a new one
|
||||
if (startY < 0 && isVisible)
|
||||
@@ -243,10 +243,10 @@ public final class ItemTextureQuadConverter
|
||||
}
|
||||
public static BakedQuad genQuad(TransformationMatrix transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint, int luminosity)
|
||||
{
|
||||
float u1 = sprite.getInterpolatedU(x1);
|
||||
float v1 = sprite.getInterpolatedV(y1);
|
||||
float u2 = sprite.getInterpolatedU(x2);
|
||||
float v2 = sprite.getInterpolatedV(y2);
|
||||
float u1 = sprite.getU(x1);
|
||||
float v1 = sprite.getV(y1);
|
||||
float u2 = sprite.getU(x2);
|
||||
float v2 = sprite.getV(y2);
|
||||
|
||||
x1 /= 16f;
|
||||
y1 /= 16f;
|
||||
@@ -311,9 +311,9 @@ public final class ItemTextureQuadConverter
|
||||
consumer.put(e, r, g, b, a);
|
||||
break;
|
||||
case NORMAL:
|
||||
float offX = (float) side.getXOffset();
|
||||
float offY = (float) side.getYOffset();
|
||||
float offZ = (float) side.getZOffset();
|
||||
float offX = (float) side.getStepX();
|
||||
float offY = (float) side.getStepY();
|
||||
float offZ = (float) side.getStepZ();
|
||||
consumer.put(e, offX, offY, offZ, 0f);
|
||||
break;
|
||||
case UV:
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ModelDataManager
|
||||
private static void cleanCaches(World world)
|
||||
{
|
||||
Preconditions.checkNotNull(world, "World must not be null");
|
||||
Preconditions.checkArgument(world == Minecraft.getInstance().world, "Cannot use model data for a world other than the current client world");
|
||||
Preconditions.checkArgument(world == Minecraft.getInstance().level, "Cannot use model data for a world other than the current client world");
|
||||
if (world != currentWorld.get())
|
||||
{
|
||||
currentWorld = new WeakReference<>(world);
|
||||
@@ -66,11 +66,11 @@ public class ModelDataManager
|
||||
public static void requestModelDataRefresh(TileEntity te)
|
||||
{
|
||||
Preconditions.checkNotNull(te, "Tile entity must not be null");
|
||||
World world = te.getWorld();
|
||||
World world = te.getLevel();
|
||||
|
||||
cleanCaches(world);
|
||||
needModelDataRefresh.computeIfAbsent(new ChunkPos(te.getPos()), $ -> Collections.synchronizedSet(new HashSet<>()))
|
||||
.add(te.getPos());
|
||||
needModelDataRefresh.computeIfAbsent(new ChunkPos(te.getBlockPos()), $ -> Collections.synchronizedSet(new HashSet<>()))
|
||||
.add(te.getBlockPos());
|
||||
}
|
||||
|
||||
private static void refreshModelData(World world, ChunkPos chunk)
|
||||
@@ -83,7 +83,7 @@ public class ModelDataManager
|
||||
Map<BlockPos, IModelData> data = modelDataCache.computeIfAbsent(chunk, $ -> new ConcurrentHashMap<>());
|
||||
for (BlockPos pos : needUpdate)
|
||||
{
|
||||
TileEntity toUpdate = world.getTileEntity(pos);
|
||||
TileEntity toUpdate = world.getBlockEntity(pos);
|
||||
if (toUpdate != null && !toUpdate.isRemoved())
|
||||
{
|
||||
data.put(pos, toUpdate.getModelData());
|
||||
@@ -99,7 +99,7 @@ public class ModelDataManager
|
||||
@SubscribeEvent
|
||||
public static void onChunkUnload(ChunkEvent.Unload event)
|
||||
{
|
||||
if (!event.getChunk().getWorldForge().isRemote()) return;
|
||||
if (!event.getChunk().getWorldForge().isClientSide()) return;
|
||||
|
||||
ChunkPos chunk = event.getChunk().getPos();
|
||||
needModelDataRefresh.remove(chunk);
|
||||
@@ -113,7 +113,7 @@ public class ModelDataManager
|
||||
|
||||
public static Map<BlockPos, IModelData> getModelData(World world, ChunkPos pos)
|
||||
{
|
||||
Preconditions.checkArgument(world.isRemote, "Cannot request model data for server world");
|
||||
Preconditions.checkArgument(world.isClientSide, "Cannot request model data for server world");
|
||||
refreshModelData(world, pos);
|
||||
return modelDataCache.getOrDefault(pos, Collections.emptyMap());
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
try
|
||||
{
|
||||
missingModel = getUnbakedModel(MODEL_MISSING);
|
||||
missingModel = getModel(MISSING_MODEL_LOCATION);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -130,7 +130,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
try
|
||||
{
|
||||
return getUnbakedModel(location);
|
||||
return getModel(location);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
try
|
||||
{
|
||||
return getUnbakedModel(location);
|
||||
return getModel(location);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -163,7 +163,7 @@ public final class ModelLoader extends ModelBakery
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, LOCATION).getSprite();
|
||||
instance = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, LOCATION).sprite();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
@@ -230,7 +230,7 @@ public final class ModelLoader extends ModelBakery
|
||||
*/
|
||||
public void onPostBakeEvent(Map<ResourceLocation, IBakedModel> modelRegistry)
|
||||
{
|
||||
IBakedModel missingModel = modelRegistry.get(MODEL_MISSING);
|
||||
IBakedModel missingModel = modelRegistry.get(MISSING_MODEL_LOCATION);
|
||||
for(Map.Entry<ResourceLocation, Exception> entry : loadingExceptions.entrySet())
|
||||
{
|
||||
// ignoring pure ResourceLocation arguments, all things we care about pass ModelResourceLocation
|
||||
@@ -265,7 +265,7 @@ public final class ModelLoader extends ModelBakery
|
||||
*/
|
||||
public static Function<RenderMaterial, TextureAtlasSprite> defaultTextureGetter()
|
||||
{
|
||||
return RenderMaterial::getSprite;
|
||||
return RenderMaterial::sprite;
|
||||
}
|
||||
|
||||
public static Function<ResourceLocation, IUnbakedModel> defaultModelGetter()
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ModelLoaderRegistry
|
||||
synchronized(loaders)
|
||||
{
|
||||
loaders.put(id, loader);
|
||||
((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).addReloadListener(loader);
|
||||
((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(loader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ModelLoaderRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
ResourceLocation loader = new ResourceLocation(JSONUtils.getString(object,"loader"));
|
||||
ResourceLocation loader = new ResourceLocation(JSONUtils.getAsString(object,"loader"));
|
||||
return getModel(loader, deserializationContext, object);
|
||||
}
|
||||
|
||||
@@ -178,13 +178,13 @@ public class ModelLoaderRegistry
|
||||
@SuppressWarnings("deprecation")
|
||||
public static RenderMaterial blockMaterial(String location)
|
||||
{
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(location));
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(location));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static RenderMaterial blockMaterial(ResourceLocation location)
|
||||
{
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, location);
|
||||
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, location);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -264,15 +264,15 @@ public class ModelLoaderRegistry
|
||||
IModelGeometry<?> customModel = blockModel.customData.getCustomGeometry();
|
||||
IModelTransform customModelState = blockModel.customData.getCustomModelState();
|
||||
if (customModelState != null)
|
||||
modelTransform = new ModelTransformComposition(modelTransform, customModelState, modelTransform.isUvLock());
|
||||
modelTransform = new ModelTransformComposition(modelTransform, customModelState, modelTransform.isUvLocked());
|
||||
|
||||
if (customModel != null)
|
||||
model = customModel.bake(blockModel.customData, modelBakery, spriteGetter, modelTransform, blockModel.getOverrides(modelBakery, otherModel, spriteGetter), modelLocation);
|
||||
else
|
||||
{
|
||||
// handle vanilla item models here, since vanilla has a shortcut for them
|
||||
if (blockModel.getRootModel() == ModelBakery.MODEL_GENERATED) {
|
||||
model = ITEM_MODEL_GENERATOR.makeItemModel(spriteGetter, blockModel).bakeModel(modelBakery, blockModel, spriteGetter, modelTransform, modelLocation, guiLight3d);
|
||||
if (blockModel.getRootModel() == ModelBakery.GENERATION_MARKER) {
|
||||
model = ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, blockModel).bake(modelBakery, blockModel, spriteGetter, modelTransform, modelLocation, guiLight3d);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -299,14 +299,14 @@ public class ModelLoaderRegistry
|
||||
public void addQuads(IModelConfiguration owner, IModelBuilder<?> modelBuilder, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
for(BlockPart blockpart : elements) {
|
||||
for(Direction direction : blockpart.mapFaces.keySet()) {
|
||||
BlockPartFace blockpartface = blockpart.mapFaces.get(direction);
|
||||
for(Direction direction : blockpart.faces.keySet()) {
|
||||
BlockPartFace blockpartface = blockpart.faces.get(direction);
|
||||
TextureAtlasSprite textureatlassprite1 = spriteGetter.apply(owner.resolveTexture(blockpartface.texture));
|
||||
if (blockpartface.cullFace == null) {
|
||||
if (blockpartface.cullForDirection == null) {
|
||||
modelBuilder.addGeneralQuad(BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction, modelTransform, modelLocation));
|
||||
} else {
|
||||
modelBuilder.addFaceQuad(
|
||||
modelTransform.getRotation().rotateTransform(blockpartface.cullFace),
|
||||
modelTransform.getRotation().rotateTransform(blockpartface.cullForDirection),
|
||||
BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction, modelTransform, modelLocation));
|
||||
}
|
||||
}
|
||||
@@ -319,7 +319,7 @@ public class ModelLoaderRegistry
|
||||
Set<RenderMaterial> textures = Sets.newHashSet();
|
||||
|
||||
for(BlockPart part : elements) {
|
||||
for(BlockPartFace face : part.mapFaces.values()) {
|
||||
for(BlockPartFace face : part.faces.values()) {
|
||||
RenderMaterial texture = owner.resolveTexture(face.texture);
|
||||
if (Objects.equals(texture, MissingTextureSprite.getLocation().toString())) {
|
||||
missingTextureErrors.add(Pair.of(face.texture, owner.getModelName()));
|
||||
@@ -356,7 +356,7 @@ public class ModelLoaderRegistry
|
||||
private List<BlockPart> getModelElements(JsonDeserializationContext deserializationContext, JsonObject object) {
|
||||
List<BlockPart> list = Lists.newArrayList();
|
||||
if (object.has("elements")) {
|
||||
for(JsonElement jsonelement : JSONUtils.getJsonArray(object, "elements")) {
|
||||
for(JsonElement jsonelement : JSONUtils.getAsJsonArray(object, "elements")) {
|
||||
list.add(deserializationContext.deserialize(jsonelement, BlockPart.class));
|
||||
}
|
||||
}
|
||||
@@ -398,7 +398,7 @@ public class ModelLoaderRegistry
|
||||
|
||||
if (jsonobject.has("visibility"))
|
||||
{
|
||||
JsonObject visibility = JSONUtils.getJsonObject(jsonobject, "visibility");
|
||||
JsonObject visibility = JSONUtils.getAsJsonObject(jsonobject, "visibility");
|
||||
for(Map.Entry<String, JsonElement> part : visibility.entrySet())
|
||||
{
|
||||
model.customData.visibilityData.setVisibilityState(part.getKey(), part.getValue().getAsBoolean());
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ModelTransformComposition implements IModelTransform
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUvLock()
|
||||
public boolean isUvLocked()
|
||||
{
|
||||
return uvLock;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
Set<RenderMaterial> materials = Sets.newHashSet();
|
||||
materials.add(owner.resolveTexture("particle"));
|
||||
for (Pair<RenderType, IUnbakedModel> m : models)
|
||||
materials.addAll(m.getSecond().getTextures(modelGetter, missingTextureErrors));
|
||||
materials.addAll(m.getSecond().getMaterials(modelGetter, missingTextureErrors));
|
||||
return materials;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
ImmutableList.Builder<Pair<RenderType, IBakedModel>> builder = ImmutableList.builder();
|
||||
for(Pair<RenderType, IUnbakedModel> entry : models)
|
||||
{
|
||||
builder.add(Pair.of(entry.getFirst(), entry.getSecond().bakeModel(bakery, spriteGetter, modelTransform, modelLocation)));
|
||||
builder.add(Pair.of(entry.getFirst(), entry.getSecond().bake(bakery, spriteGetter, modelTransform, modelLocation)));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
return new MultiLayerBakedModel(
|
||||
owner.useSmoothLighting(), owner.isShadedInGui(), owner.isSideLit(),
|
||||
spriteGetter.apply(owner.resolveTexture("particle")), overrides, convertRenderTypes,
|
||||
missing.bakeModel(bakery, spriteGetter, modelTransform, modelLocation),
|
||||
missing.bake(bakery, spriteGetter, modelTransform, modelLocation),
|
||||
buildModels(models, modelTransform, bakery, spriteGetter, modelLocation),
|
||||
PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(owner.getCombinedTransform(), modelTransform))
|
||||
);
|
||||
@@ -164,7 +164,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
public boolean useAmbientOcclusion()
|
||||
{
|
||||
return ambientOcclusion;
|
||||
}
|
||||
@@ -182,19 +182,19 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit()
|
||||
public boolean usesBlockLight()
|
||||
{
|
||||
return isSideLit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
public boolean isCustomRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
public TextureAtlasSprite getParticleIcon()
|
||||
{
|
||||
return particle;
|
||||
}
|
||||
@@ -231,21 +231,21 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
|
||||
public static BiMap<RenderType, RenderType> ITEM_RENDER_TYPE_MAPPING = HashBiMap.create();
|
||||
static {
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.getSolid(), ForgeRenderTypes.ITEM_LAYERED_SOLID.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.getCutout(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.getCutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.getTranslucent(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.solid(), ForgeRenderTypes.ITEM_LAYERED_SOLID.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.cutout(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.cutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get());
|
||||
ITEM_RENDER_TYPE_MAPPING.put(RenderType.translucent(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get());
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Loader implements IModelLoader<MultiLayerModel>
|
||||
{
|
||||
public static final ImmutableBiMap<String, RenderType> BLOCK_LAYERS = ImmutableBiMap.<String, RenderType>builder()
|
||||
.put("solid", RenderType.getSolid())
|
||||
.put("cutout", RenderType.getCutout())
|
||||
.put("cutout_mipped", RenderType.getCutoutMipped())
|
||||
.put("translucent", RenderType.getTranslucent())
|
||||
.put("tripwire", RenderType.getTripwire())
|
||||
.put("solid", RenderType.solid())
|
||||
.put("cutout", RenderType.cutout())
|
||||
.put("cutout_mipped", RenderType.cutoutMipped())
|
||||
.put("translucent", RenderType.translucent())
|
||||
.put("tripwire", RenderType.tripwire())
|
||||
.build();
|
||||
|
||||
public static final Loader INSTANCE = new Loader();
|
||||
@@ -262,16 +262,16 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
|
||||
public MultiLayerModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents)
|
||||
{
|
||||
ImmutableList.Builder<Pair<RenderType, IUnbakedModel>> builder = ImmutableList.builder();
|
||||
JsonObject layersObject = JSONUtils.getJsonObject(modelContents, "layers");
|
||||
JsonObject layersObject = JSONUtils.getAsJsonObject(modelContents, "layers");
|
||||
for(Map.Entry<String, RenderType> layer : BLOCK_LAYERS.entrySet()) // block layers
|
||||
{
|
||||
String layerName = layer.getKey(); // mc overrides toString to return the ID for the layer
|
||||
if(layersObject.has(layerName))
|
||||
{
|
||||
builder.add(Pair.of(layer.getValue(), deserializationContext.deserialize(JSONUtils.getJsonObject(layersObject, layerName), BlockModel.class)));
|
||||
builder.add(Pair.of(layer.getValue(), deserializationContext.deserialize(JSONUtils.getAsJsonObject(layersObject, layerName), BlockModel.class)));
|
||||
}
|
||||
}
|
||||
boolean convertRenderTypes = JSONUtils.getBoolean(modelContents, "convert_render_types", true);
|
||||
boolean convertRenderTypes = JSONUtils.getAsBoolean(modelContents, "convert_render_types", true);
|
||||
return new MultiLayerModel(builder.build(), convertRenderTypes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
EnumMap<ItemCameraTransforms.TransformType, TransformationMatrix> map = new EnumMap<>(ItemCameraTransforms.TransformType.class);
|
||||
for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values())
|
||||
{
|
||||
if (transforms.hasCustomTransform(type))
|
||||
if (transforms.hasTransform(type))
|
||||
{
|
||||
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)));
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
{
|
||||
map.put(type, tr);
|
||||
}
|
||||
else if (transforms.hasCustomTransform(type))
|
||||
else if (transforms.hasTransform(type))
|
||||
{
|
||||
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)));
|
||||
}
|
||||
@@ -125,14 +125,14 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override public boolean isAmbientOcclusion() { return parent.isAmbientOcclusion(); }
|
||||
@Override public boolean useAmbientOcclusion() { return parent.useAmbientOcclusion(); }
|
||||
@Override public boolean isAmbientOcclusion(BlockState state) { return parent.isAmbientOcclusion(state); }
|
||||
@Override public boolean isGui3d() { return parent.isGui3d(); }
|
||||
@Override public boolean isSideLit() { return parent.isSideLit(); }
|
||||
@Override public boolean isBuiltInRenderer() { return parent.isBuiltInRenderer(); }
|
||||
@Override public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); }
|
||||
@Override public boolean usesBlockLight() { return parent.usesBlockLight(); }
|
||||
@Override public boolean isCustomRenderer() { return parent.isCustomRenderer(); }
|
||||
@Override public TextureAtlasSprite getParticleIcon() { return parent.getParticleIcon(); }
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); }
|
||||
@Override public ItemCameraTransforms getTransforms() { return parent.getTransforms(); }
|
||||
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData)
|
||||
{
|
||||
return parent.getQuads(state, side, rand, extraData);
|
||||
@@ -165,9 +165,9 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel getOverrideModel(IBakedModel model, ItemStack stack, @Nullable ClientWorld worldIn, @Nullable LivingEntity entityIn)
|
||||
public IBakedModel resolve(IBakedModel model, ItemStack stack, @Nullable ClientWorld worldIn, @Nullable LivingEntity entityIn)
|
||||
{
|
||||
model = parent.getOverrides().getOverrideModel(parent, stack, worldIn, entityIn);
|
||||
model = parent.getOverrides().resolve(parent, stack, worldIn, entityIn);
|
||||
return new PerspectiveMapWrapper(model, transforms);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class QuadTransformer
|
||||
|
||||
private void processVertices(int[] inData, int[] outData)
|
||||
{
|
||||
int stride = DefaultVertexFormats.BLOCK.getSize();
|
||||
int stride = DefaultVertexFormats.BLOCK.getVertexSize();
|
||||
int count = (inData.length * 4) / stride;
|
||||
for (int i=0;i<count;i++)
|
||||
{
|
||||
@@ -59,9 +59,9 @@ public class QuadTransformer
|
||||
transform.transformPosition(pos);
|
||||
pos.perspectiveDivide();
|
||||
|
||||
putAtByteOffset(outData, offset, Float.floatToRawIntBits(pos.getX()));
|
||||
putAtByteOffset(outData,offset + 4, Float.floatToRawIntBits(pos.getY()));
|
||||
putAtByteOffset(outData,offset + 8, Float.floatToRawIntBits(pos.getZ()));
|
||||
putAtByteOffset(outData, offset, Float.floatToRawIntBits(pos.x()));
|
||||
putAtByteOffset(outData,offset + 4, Float.floatToRawIntBits(pos.y()));
|
||||
putAtByteOffset(outData,offset + 8, Float.floatToRawIntBits(pos.z()));
|
||||
}
|
||||
|
||||
for (int i=0;i<count;i++)
|
||||
@@ -138,7 +138,7 @@ public class QuadTransformer
|
||||
throw new RuntimeException("Expected vertex format to have a POSITION attribute");
|
||||
if (element.getType() != VertexFormatElement.Type.FLOAT)
|
||||
throw new RuntimeException("Expected POSITION attribute to have data type FLOAT");
|
||||
if (element.getSize() < 3)
|
||||
if (element.getByteSize() < 3)
|
||||
throw new RuntimeException("Expected POSITION attribute to have at least 3 dimensions");
|
||||
return fmt.getOffset(index);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class QuadTransformer
|
||||
throw new IllegalStateException("BLOCK format does not have normals?");
|
||||
if (element.getType() != VertexFormatElement.Type.BYTE)
|
||||
throw new RuntimeException("Expected NORMAL attribute to have data type BYTE");
|
||||
if (element.getSize() < 3)
|
||||
if (element.getByteSize() < 3)
|
||||
throw new RuntimeException("Expected NORMAL attribute to have at least 3 dimensions");
|
||||
return fmt.getOffset(index);
|
||||
}
|
||||
@@ -172,11 +172,11 @@ public class QuadTransformer
|
||||
*/
|
||||
public BakedQuad processOne(BakedQuad input)
|
||||
{
|
||||
int[] inData = input.getVertexData();
|
||||
int[] inData = input.getVertices();
|
||||
int[] outData = Arrays.copyOf(inData, inData.length);
|
||||
processVertices(inData, outData);
|
||||
|
||||
return new BakedQuad(outData, input.getTintIndex(), input.getFace(), input.getSprite(), input.applyDiffuseLighting());
|
||||
return new BakedQuad(outData, input.getTintIndex(), input.getDirection(), input.getSprite(), input.isShade());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ public class QuadTransformer
|
||||
*/
|
||||
public BakedQuad processOneInPlace(BakedQuad input)
|
||||
{
|
||||
int[] data = input.getVertexData();
|
||||
int[] data = input.getVertices();
|
||||
processVertices(data, data);
|
||||
return input;
|
||||
}
|
||||
@@ -204,11 +204,11 @@ public class QuadTransformer
|
||||
List<BakedQuad> outputs = Lists.newArrayList();
|
||||
for(BakedQuad input : inputs)
|
||||
{
|
||||
int[] inData = input.getVertexData();
|
||||
int[] inData = input.getVertices();
|
||||
int[] outData = Arrays.copyOf(inData, inData.length);
|
||||
processVertices(inData, outData);
|
||||
|
||||
outputs.add(new BakedQuad(outData, input.getTintIndex(), input.getFace(), input.getSprite(), input.applyDiffuseLighting()));
|
||||
outputs.add(new BakedQuad(outData, input.getTintIndex(), input.getDirection(), input.getSprite(), input.isShade()));
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ public class QuadTransformer
|
||||
|
||||
for(BakedQuad input : inputs)
|
||||
{
|
||||
int[] data = input.getVertexData();
|
||||
int[] data = input.getVertices();
|
||||
processVertices(data, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
return new BakedModel(
|
||||
owner.useSmoothLighting(), owner.isShadedInGui(), owner.isSideLit(),
|
||||
spriteGetter.apply(owner.resolveTexture("particle")), overrides,
|
||||
baseModel.bakeModel(bakery, baseModel, spriteGetter, modelTransform, modelLocation, owner.isSideLit()),
|
||||
baseModel.bake(bakery, baseModel, spriteGetter, modelTransform, modelLocation, owner.isSideLit()),
|
||||
ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> {
|
||||
return value.bakeModel(bakery, value, spriteGetter, modelTransform, modelLocation, owner.isSideLit());
|
||||
return value.bake(bakery, value, spriteGetter, modelTransform, modelLocation, owner.isSideLit());
|
||||
}))
|
||||
);
|
||||
}
|
||||
@@ -68,9 +68,9 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
Set<RenderMaterial> textures = Sets.newHashSet();
|
||||
textures.addAll(baseModel.getTextures(modelGetter, missingTextureErrors));
|
||||
textures.addAll(baseModel.getMaterials(modelGetter, missingTextureErrors));
|
||||
for(BlockModel model : perspectives.values())
|
||||
textures.addAll(model.getTextures(modelGetter, missingTextureErrors));
|
||||
textures.addAll(model.getMaterials(modelGetter, missingTextureErrors));
|
||||
return textures;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
public boolean useAmbientOcclusion()
|
||||
{
|
||||
return isAmbientOcclusion;
|
||||
}
|
||||
@@ -114,19 +114,19 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit()
|
||||
public boolean usesBlockLight()
|
||||
{
|
||||
return isSideLit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
public boolean isCustomRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
public TextureAtlasSprite getParticleIcon()
|
||||
{
|
||||
return particle;
|
||||
}
|
||||
@@ -144,9 +144,9 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
public ItemCameraTransforms getTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
return ItemCameraTransforms.NO_TRANSFORMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,16 +186,16 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
|
||||
@Override
|
||||
public SeparatePerspectiveModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents)
|
||||
{
|
||||
BlockModel baseModel = deserializationContext.deserialize(JSONUtils.getJsonObject(modelContents, "base"), BlockModel.class);
|
||||
BlockModel baseModel = deserializationContext.deserialize(JSONUtils.getAsJsonObject(modelContents, "base"), BlockModel.class);
|
||||
|
||||
JsonObject perspectiveData = JSONUtils.getJsonObject(modelContents, "perspectives");
|
||||
JsonObject perspectiveData = JSONUtils.getAsJsonObject(modelContents, "perspectives");
|
||||
|
||||
ImmutableMap.Builder<ItemCameraTransforms.TransformType, BlockModel> perspectives = ImmutableMap.builder();
|
||||
for(Map.Entry<String, ItemCameraTransforms.TransformType> perspective : PERSPECTIVES.entrySet())
|
||||
{
|
||||
if (perspectiveData.has(perspective.getKey()))
|
||||
{
|
||||
BlockModel perspectiveModel = deserializationContext.deserialize(JSONUtils.getJsonObject(perspectiveData, perspective.getKey()), BlockModel.class);
|
||||
BlockModel perspectiveModel = deserializationContext.deserialize(JSONUtils.getAsJsonObject(perspectiveData, perspective.getKey()), BlockModel.class);
|
||||
perspectives.put(perspective.getValue(), perspectiveModel);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -63,7 +63,7 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public IBakedModel getOverrideModel(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
|
||||
public IBakedModel resolve(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
|
||||
{
|
||||
return stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)
|
||||
.map(asm ->
|
||||
@@ -72,16 +72,16 @@ public final class AnimationItemOverrideList extends ItemOverrideList
|
||||
// TODO caching?
|
||||
if(w == null && entity != null)
|
||||
{
|
||||
w = entity.world;
|
||||
w = entity.level;
|
||||
}
|
||||
if(world == null)
|
||||
{
|
||||
w = Minecraft.getInstance().world;
|
||||
w = Minecraft.getInstance().level;
|
||||
}
|
||||
return asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft();
|
||||
})
|
||||
// TODO where should uvlock data come from?
|
||||
.map(state -> model.bakeModel(bakery, bakedTextureGetter, new ModelTransformComposition(state, this.state), modelLoc))
|
||||
.orElseGet(() -> super.getOverrideModel(originalModel, stack, world, entity));
|
||||
.map(state -> model.bake(bakery, bakedTextureGetter, new ModelTransformComposition(state, this.state), modelLoc))
|
||||
.orElseGet(() -> super.resolve(originalModel, stack, world, entity));
|
||||
}
|
||||
}
|
||||
@@ -540,7 +540,7 @@ public class ModelBlockAnimation
|
||||
{
|
||||
float w = info.getWeights().get(i)[0];
|
||||
tmp = trOp.getMatrix();
|
||||
tmp.mul(w);
|
||||
tmp.multiply(w);
|
||||
m.add(tmp);
|
||||
weight += w;
|
||||
}
|
||||
@@ -548,7 +548,7 @@ public class ModelBlockAnimation
|
||||
}
|
||||
if(weight > 1e-5)
|
||||
{
|
||||
m.mul(1f / weight);
|
||||
m.multiply(1f / weight);
|
||||
return new TransformationMatrix(m);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -64,17 +64,17 @@ public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntit
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
BlockPos pos = te.getPos();
|
||||
IBlockDisplayReader world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getWorld(), pos)
|
||||
.map(IBlockDisplayReader.class::cast).orElseGet(() -> te.getWorld());
|
||||
if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRenderer();
|
||||
BlockPos pos = te.getBlockPos();
|
||||
IBlockDisplayReader world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getLevel(), pos)
|
||||
.map(IBlockDisplayReader.class::cast).orElseGet(() -> te.getLevel());
|
||||
BlockState state = world.getBlockState(pos);
|
||||
IBakedModel model = blockRenderer.getBlockModelShapes().getModel(state);
|
||||
IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getWorld(), pos));
|
||||
IBakedModel model = blockRenderer.getBlockModelShaper().getBlockModel(state);
|
||||
IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getLevel(), pos));
|
||||
if (data.hasProperty(Properties.AnimationProperty))
|
||||
{
|
||||
@SuppressWarnings("resource")
|
||||
float time = Animation.getWorldTime(Minecraft.getInstance().world, partialTick);
|
||||
float time = Animation.getWorldTime(Minecraft.getInstance().level, partialTick);
|
||||
cap
|
||||
.map(asm -> asm.apply(time))
|
||||
.ifPresent(pair -> {
|
||||
@@ -82,7 +82,7 @@ public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntit
|
||||
|
||||
// TODO: caching?
|
||||
data.setData(Properties.AnimationProperty, pair.getLeft());
|
||||
blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, mat, renderer.getBuffer(Atlases.getSolidBlockType()), false, new Random(), 42, light, data);
|
||||
blockRenderer.getModelRenderer().renderModel(world, model, state, pos, mat, renderer.getBuffer(Atlases.solidBlockSheet()), false, new Random(), 42, light, data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,10 +447,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Collection<RenderMaterial> getTextures(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors)
|
||||
public Collection<RenderMaterial> getMaterials(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
return textures.values().stream().filter(loc -> !loc.startsWith("#"))
|
||||
.map(t -> new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(t)))
|
||||
.map(t -> new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(t)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -463,10 +463,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
@SuppressWarnings("deprecation")
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bakeModel(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
|
||||
public IBakedModel bake(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
|
||||
TextureAtlasSprite missing = spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, MissingTextureSprite.getLocation()));
|
||||
TextureAtlasSprite missing = spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, MissingTextureSprite.getLocation()));
|
||||
for(Map.Entry<String, String> e : textures.entrySet())
|
||||
{
|
||||
if(e.getValue().startsWith("#"))
|
||||
@@ -476,7 +476,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.put(e.getKey(), spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(e.getValue()))));
|
||||
builder.put(e.getKey(), spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(e.getValue()))));
|
||||
}
|
||||
}
|
||||
builder.put("missingno", missing);
|
||||
@@ -724,7 +724,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
else sprite = this.textures.get(textures.get(0).getPath());
|
||||
BakedQuadBuilder quadBuilder = new BakedQuadBuilder(sprite);
|
||||
quadBuilder.setContractUVs(true);
|
||||
quadBuilder.setQuadOrientation(Direction.getFacingFromVector(f.getNormal().getX(), f.getNormal().getY(), f.getNormal().getZ()));
|
||||
quadBuilder.setQuadOrientation(Direction.getNearest(f.getNormal().x(), f.getNormal().y(), f.getNormal().z()));
|
||||
putVertexData(quadBuilder, f.getV1(), f.getNormal(), sprite);
|
||||
putVertexData(quadBuilder, f.getV2(), f.getNormal(), sprite);
|
||||
putVertexData(quadBuilder, f.getV3(), f.getNormal(), sprite);
|
||||
@@ -743,12 +743,12 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
switch(vertexFormatElements.get(e).getUsage())
|
||||
{
|
||||
case POSITION:
|
||||
consumer.put(e, v.getPos().getX(), v.getPos().getY(), v.getPos().getZ(), 1);
|
||||
consumer.put(e, v.getPos().x(), v.getPos().y(), v.getPos().z(), 1);
|
||||
break;
|
||||
case COLOR:
|
||||
if(v.getColor() != null)
|
||||
{
|
||||
consumer.put(e, v.getColor().getX(), v.getColor().getY(), v.getColor().getZ(), v.getColor().getW());
|
||||
consumer.put(e, v.getColor().x(), v.getColor().y(), v.getColor().z(), v.getColor().w());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -760,8 +760,8 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
if(vertexFormatElements.get(e).getIndex() < v.getTexCoords().length)
|
||||
{
|
||||
consumer.put(e,
|
||||
sprite.getInterpolatedU(v.getTexCoords()[0].getX() * 16),
|
||||
sprite.getInterpolatedV(v.getTexCoords()[0].getY() * 16),
|
||||
sprite.getU(v.getTexCoords()[0].x() * 16),
|
||||
sprite.getV(v.getTexCoords()[0].y() * 16),
|
||||
0,
|
||||
1
|
||||
);
|
||||
@@ -774,11 +774,11 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
case NORMAL:
|
||||
if(v.getNormal() != null)
|
||||
{
|
||||
consumer.put(e, v.getNormal().getX(), v.getNormal().getY(), v.getNormal().getZ(), 0);
|
||||
consumer.put(e, v.getNormal().x(), v.getNormal().y(), v.getNormal().z(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
consumer.put(e, faceNormal.getX(), faceNormal.getY(), faceNormal.getZ(), 0);
|
||||
consumer.put(e, faceNormal.x(), faceNormal.y(), faceNormal.z(), 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -788,7 +788,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
public boolean useAmbientOcclusion()
|
||||
{
|
||||
return smooth;
|
||||
}
|
||||
@@ -800,19 +800,19 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit()
|
||||
public boolean usesBlockLight()
|
||||
{
|
||||
return isSideLit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
public boolean isCustomRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
public TextureAtlasSprite getParticleIcon()
|
||||
{
|
||||
// FIXME somehow specify particle texture in the model
|
||||
return textures.values().asList().get(0);
|
||||
|
||||
@@ -670,10 +670,10 @@ public class B3DModel
|
||||
{
|
||||
totalWeight += bone.getLeft();
|
||||
Matrix4f bm = animator.apply(bone.getRight());
|
||||
bm.mul(bone.getLeft());
|
||||
bm.multiply(bone.getLeft());
|
||||
t.add(bm);
|
||||
}
|
||||
if(Math.abs(totalWeight) > 1e-4) t.mul(1f / totalWeight);
|
||||
if(Math.abs(totalWeight) > 1e-4) t.multiply(1f / totalWeight);
|
||||
else t.setIdentity();
|
||||
}
|
||||
|
||||
@@ -684,7 +684,7 @@ public class B3DModel
|
||||
pos.setW(1);
|
||||
trsr.transformPosition(pos);
|
||||
pos.normalize();
|
||||
Vector3f rPos = new Vector3f(pos.getX(), pos.getY(), pos.getZ());
|
||||
Vector3f rPos = new Vector3f(pos.x(), pos.y(), pos.z());
|
||||
|
||||
// normal
|
||||
Vector3f rNormal = null;
|
||||
|
||||
@@ -101,7 +101,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(DirectoryCache cache) throws IOException {
|
||||
public void run(DirectoryCache cache) throws IOException {
|
||||
models().clear();
|
||||
itemModels().clear();
|
||||
registeredBlocks.clear();
|
||||
@@ -241,7 +241,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
getVariantBuilder(block)
|
||||
.forAllStates(state -> ConfiguredModel.builder()
|
||||
.modelFile(modelFunc.apply(state))
|
||||
.rotationY(((int) state.get(BlockStateProperties.HORIZONTAL_FACING).getHorizontalAngle() + angleOffset) % 360)
|
||||
.rotationY(((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + angleOffset) % 360)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
@@ -262,8 +262,8 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
getVariantBuilder(block)
|
||||
.forAllStates(state -> ConfiguredModel.builder()
|
||||
.modelFile(modelFunc.apply(state))
|
||||
.rotationX(state.get(BlockStateProperties.FACE).ordinal() * 90)
|
||||
.rotationY((((int) state.get(BlockStateProperties.HORIZONTAL_FACING).getHorizontalAngle() + angleOffset) + (state.get(BlockStateProperties.FACE) == AttachFace.CEILING ? 180 : 0)) % 360)
|
||||
.rotationX(state.getValue(BlockStateProperties.ATTACH_FACE).ordinal() * 90)
|
||||
.rotationY((((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + angleOffset) + (state.getValue(BlockStateProperties.ATTACH_FACE) == AttachFace.CEILING ? 180 : 0)) % 360)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
@@ -283,11 +283,11 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
public void directionalBlock(Block block, Function<BlockState, ModelFile> modelFunc, int angleOffset) {
|
||||
getVariantBuilder(block)
|
||||
.forAllStates(state -> {
|
||||
Direction dir = state.get(BlockStateProperties.FACING);
|
||||
Direction dir = state.getValue(BlockStateProperties.FACING);
|
||||
return ConfiguredModel.builder()
|
||||
.modelFile(modelFunc.apply(state))
|
||||
.rotationX(dir == Direction.DOWN ? 180 : dir.getAxis().isHorizontal() ? 90 : 0)
|
||||
.rotationY(dir.getAxis().isVertical() ? 0 : (((int) dir.getHorizontalAngle()) + angleOffset) % 360)
|
||||
.rotationY(dir.getAxis().isVertical() ? 0 : (((int) dir.toYRot()) + angleOffset) % 360)
|
||||
.build();
|
||||
});
|
||||
}
|
||||
@@ -318,10 +318,10 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
public void stairsBlock(StairsBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) {
|
||||
getVariantBuilder(block)
|
||||
.forAllStatesExcept(state -> {
|
||||
Direction facing = state.get(StairsBlock.FACING);
|
||||
Half half = state.get(StairsBlock.HALF);
|
||||
StairsShape shape = state.get(StairsBlock.SHAPE);
|
||||
int yRot = (int) facing.rotateY().getHorizontalAngle(); // Stairs model is rotated 90 degrees clockwise for some reason
|
||||
Direction facing = state.getValue(StairsBlock.FACING);
|
||||
Half half = state.getValue(StairsBlock.HALF);
|
||||
StairsShape shape = state.getValue(StairsBlock.SHAPE);
|
||||
int yRot = (int) facing.getClockWise().toYRot(); // Stairs model is rotated 90 degrees clockwise for some reason
|
||||
if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) {
|
||||
yRot += 270; // Left facing stairs are rotated 90 degrees clockwise
|
||||
}
|
||||
@@ -361,10 +361,10 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
public void fourWayMultipart(MultiPartBlockStateBuilder builder, ModelFile side) {
|
||||
SixWayBlock.FACING_TO_PROPERTY_MAP.entrySet().forEach(e -> {
|
||||
SixWayBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> {
|
||||
Direction dir = e.getKey();
|
||||
if (dir.getAxis().isHorizontal()) {
|
||||
builder.part().modelFile(side).rotationY((((int) dir.getHorizontalAngle()) + 180) % 360).uvLock(true).addModel()
|
||||
builder.part().modelFile(side).rotationY((((int) dir.toYRot()) + 180) % 360).uvLock(true).addModel()
|
||||
.condition(e.getValue(), true);
|
||||
}
|
||||
});
|
||||
@@ -398,15 +398,15 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
public void fenceGateBlock(FenceGateBlock block, ModelFile gate, ModelFile gateOpen, ModelFile gateWall, ModelFile gateWallOpen) {
|
||||
getVariantBuilder(block).forAllStatesExcept(state -> {
|
||||
ModelFile model = gate;
|
||||
if (state.get(FenceGateBlock.IN_WALL)) {
|
||||
if (state.getValue(FenceGateBlock.IN_WALL)) {
|
||||
model = gateWall;
|
||||
}
|
||||
if (state.get(FenceGateBlock.OPEN)) {
|
||||
if (state.getValue(FenceGateBlock.OPEN)) {
|
||||
model = model == gateWall ? gateWallOpen : gateOpen;
|
||||
}
|
||||
return ConfiguredModel.builder()
|
||||
.modelFile(model)
|
||||
.rotationY((int) state.get(FenceGateBlock.HORIZONTAL_FACING).getHorizontalAngle())
|
||||
.rotationY((int) state.getValue(FenceGateBlock.FACING).toYRot())
|
||||
.uvLock(true)
|
||||
.build();
|
||||
}, FenceGateBlock.POWERED);
|
||||
@@ -425,10 +425,10 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
public static final ImmutableMap<Direction, Property<WallHeight>> WALL_PROPS = ImmutableMap.<Direction, Property<WallHeight>>builder()
|
||||
.put(Direction.EAST, BlockStateProperties.WALL_HEIGHT_EAST)
|
||||
.put(Direction.NORTH, BlockStateProperties.WALL_HEIGHT_NORTH)
|
||||
.put(Direction.SOUTH, BlockStateProperties.WALL_HEIGHT_SOUTH)
|
||||
.put(Direction.WEST, BlockStateProperties.WALL_HEIGHT_WEST)
|
||||
.put(Direction.EAST, BlockStateProperties.EAST_WALL)
|
||||
.put(Direction.NORTH, BlockStateProperties.NORTH_WALL)
|
||||
.put(Direction.SOUTH, BlockStateProperties.SOUTH_WALL)
|
||||
.put(Direction.WEST, BlockStateProperties.WEST_WALL)
|
||||
.build();
|
||||
|
||||
public void wallBlock(WallBlock block, ModelFile post, ModelFile side, ModelFile sideTall) {
|
||||
@@ -446,7 +446,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
private void wallSidePart(MultiPartBlockStateBuilder builder, ModelFile model, Map.Entry<Direction, Property<WallHeight>> entry, WallHeight height) {
|
||||
builder.part()
|
||||
.modelFile(model)
|
||||
.rotationY((((int) entry.getKey().getHorizontalAngle()) + 180) % 360)
|
||||
.rotationY((((int) entry.getKey().toYRot()) + 180) % 360)
|
||||
.uvLock(true)
|
||||
.addModel()
|
||||
.condition(entry.getValue(), height);
|
||||
@@ -472,7 +472,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
public void paneBlock(PaneBlock block, ModelFile post, ModelFile side, ModelFile sideAlt, ModelFile noSide, ModelFile noSideAlt) {
|
||||
MultiPartBlockStateBuilder builder = getMultipartBuilder(block)
|
||||
.part().modelFile(post).addModel().end();
|
||||
SixWayBlock.FACING_TO_PROPERTY_MAP.entrySet().forEach(e -> {
|
||||
SixWayBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> {
|
||||
Direction dir = e.getKey();
|
||||
if (dir.getAxis().isHorizontal()) {
|
||||
boolean alt = dir == Direction.SOUTH;
|
||||
@@ -502,9 +502,9 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
|
||||
public void doorBlock(DoorBlock block, ModelFile bottomLeft, ModelFile bottomRight, ModelFile topLeft, ModelFile topRight) {
|
||||
getVariantBuilder(block).forAllStatesExcept(state -> {
|
||||
int yRot = ((int) state.get(DoorBlock.FACING).getHorizontalAngle()) + 90;
|
||||
boolean rh = state.get(DoorBlock.HINGE) == DoorHingeSide.RIGHT;
|
||||
boolean open = state.get(DoorBlock.OPEN);
|
||||
int yRot = ((int) state.getValue(DoorBlock.FACING).toYRot()) + 90;
|
||||
boolean rh = state.getValue(DoorBlock.HINGE) == DoorHingeSide.RIGHT;
|
||||
boolean open = state.getValue(DoorBlock.OPEN);
|
||||
boolean right = rh ^ open;
|
||||
if (open) {
|
||||
yRot += 90;
|
||||
@@ -513,7 +513,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
yRot += 180;
|
||||
}
|
||||
yRot %= 360;
|
||||
return ConfiguredModel.builder().modelFile(state.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? (right ? bottomRight : bottomLeft) : (right ? topRight : topLeft))
|
||||
return ConfiguredModel.builder().modelFile(state.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? (right ? bottomRight : bottomLeft) : (right ? topRight : topLeft))
|
||||
.rotationY(yRot)
|
||||
.build();
|
||||
}, DoorBlock.POWERED);
|
||||
@@ -537,9 +537,9 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
public void trapdoorBlock(TrapDoorBlock block, ModelFile bottom, ModelFile top, ModelFile open, boolean orientable) {
|
||||
getVariantBuilder(block).forAllStatesExcept(state -> {
|
||||
int xRot = 0;
|
||||
int yRot = ((int) state.get(TrapDoorBlock.HORIZONTAL_FACING).getHorizontalAngle()) + 180;
|
||||
boolean isOpen = state.get(TrapDoorBlock.OPEN);
|
||||
if (orientable && isOpen && state.get(TrapDoorBlock.HALF) == Half.TOP) {
|
||||
int yRot = ((int) state.getValue(TrapDoorBlock.FACING).toYRot()) + 180;
|
||||
boolean isOpen = state.getValue(TrapDoorBlock.OPEN);
|
||||
if (orientable && isOpen && state.getValue(TrapDoorBlock.HALF) == Half.TOP) {
|
||||
xRot += 180;
|
||||
yRot += 180;
|
||||
}
|
||||
@@ -547,7 +547,7 @@ public abstract class BlockStateProvider implements IDataProvider {
|
||||
yRot = 0;
|
||||
}
|
||||
yRot %= 360;
|
||||
return ConfiguredModel.builder().modelFile(isOpen ? open : state.get(TrapDoorBlock.HALF) == Half.TOP ? top : bottom)
|
||||
return ConfiguredModel.builder().modelFile(isOpen ? open : state.getValue(TrapDoorBlock.HALF) == Half.TOP ? top : bottom)
|
||||
.rotationX(xRot)
|
||||
.rotationY(yRot)
|
||||
.build();
|
||||
|
||||
@@ -135,7 +135,7 @@ public final class ConfiguredModel {
|
||||
}
|
||||
|
||||
static void checkRotation(int rotationX, int rotationY) {
|
||||
Preconditions.checkArgument(ModelRotation.getModelRotation(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY);
|
||||
Preconditions.checkArgument(ModelRotation.by(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY);
|
||||
}
|
||||
|
||||
static void checkWeight(int weight) {
|
||||
|
||||
@@ -235,14 +235,14 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
for (Entry<Perspective, ItemTransformVec3f> e : transforms.entrySet()) {
|
||||
JsonObject transform = new JsonObject();
|
||||
ItemTransformVec3f vec = e.getValue();
|
||||
if (vec.equals(ItemTransformVec3f.DEFAULT)) continue;
|
||||
if (!vec.rotation.equals(ItemTransformVec3f.Deserializer.ROTATION_DEFAULT)) {
|
||||
if (vec.equals(ItemTransformVec3f.NO_TRANSFORM)) continue;
|
||||
if (!vec.rotation.equals(ItemTransformVec3f.Deserializer.DEFAULT_ROTATION)) {
|
||||
transform.add("rotation", serializeVector3f(vec.rotation));
|
||||
}
|
||||
if (!vec.translation.equals(ItemTransformVec3f.Deserializer.TRANSLATION_DEFAULT)) {
|
||||
if (!vec.translation.equals(ItemTransformVec3f.Deserializer.DEFAULT_TRANSLATION)) {
|
||||
transform.add("translation", serializeVector3f(e.getValue().translation));
|
||||
}
|
||||
if (!vec.scale.equals(ItemTransformVec3f.Deserializer.SCALE_DEFAULT)) {
|
||||
if (!vec.scale.equals(ItemTransformVec3f.Deserializer.DEFAULT_SCALE)) {
|
||||
transform.add("scale", serializeVector3f(e.getValue().scale));
|
||||
}
|
||||
display.add(e.getKey().name, transform);
|
||||
@@ -262,16 +262,16 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
JsonArray elements = new JsonArray();
|
||||
this.elements.stream().map(ElementBuilder::build).forEach(part -> {
|
||||
JsonObject partObj = new JsonObject();
|
||||
partObj.add("from", serializeVector3f(part.positionFrom));
|
||||
partObj.add("to", serializeVector3f(part.positionTo));
|
||||
partObj.add("from", serializeVector3f(part.from));
|
||||
partObj.add("to", serializeVector3f(part.to));
|
||||
|
||||
if (part.partRotation != null) {
|
||||
if (part.rotation != null) {
|
||||
JsonObject rotation = new JsonObject();
|
||||
rotation.add("origin", serializeVector3f(part.partRotation.origin));
|
||||
rotation.addProperty("axis", part.partRotation.axis.getString());
|
||||
rotation.addProperty("angle", part.partRotation.angle);
|
||||
if (part.partRotation.rescale) {
|
||||
rotation.addProperty("rescale", part.partRotation.rescale);
|
||||
rotation.add("origin", serializeVector3f(part.rotation.origin));
|
||||
rotation.addProperty("axis", part.rotation.axis.getSerializedName());
|
||||
rotation.addProperty("angle", part.rotation.angle);
|
||||
if (part.rotation.rescale) {
|
||||
rotation.addProperty("rescale", part.rotation.rescale);
|
||||
}
|
||||
partObj.add("rotation", rotation);
|
||||
}
|
||||
@@ -282,26 +282,26 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
|
||||
JsonObject faces = new JsonObject();
|
||||
for (Direction dir : Direction.values()) {
|
||||
BlockPartFace face = part.mapFaces.get(dir);
|
||||
BlockPartFace face = part.faces.get(dir);
|
||||
if (face == null) continue;
|
||||
|
||||
JsonObject faceObj = new JsonObject();
|
||||
faceObj.addProperty("texture", serializeLocOrKey(face.texture));
|
||||
if (!Arrays.equals(face.blockFaceUV.uvs, part.getFaceUvs(dir))) {
|
||||
faceObj.add("uv", new Gson().toJsonTree(face.blockFaceUV.uvs));
|
||||
if (!Arrays.equals(face.uv.uvs, part.uvsByFace(dir))) {
|
||||
faceObj.add("uv", new Gson().toJsonTree(face.uv.uvs));
|
||||
}
|
||||
if (face.cullFace != null) {
|
||||
faceObj.addProperty("cullface", face.cullFace.getString());
|
||||
if (face.cullForDirection != null) {
|
||||
faceObj.addProperty("cullface", face.cullForDirection.getSerializedName());
|
||||
}
|
||||
if (face.blockFaceUV.rotation != 0) {
|
||||
faceObj.addProperty("rotation", face.blockFaceUV.rotation);
|
||||
if (face.uv.rotation != 0) {
|
||||
faceObj.addProperty("rotation", face.uv.rotation);
|
||||
}
|
||||
if (face.tintIndex != -1) {
|
||||
faceObj.addProperty("tintindex", face.tintIndex);
|
||||
}
|
||||
faces.add(dir.getString(), faceObj);
|
||||
faces.add(dir.getSerializedName(), faceObj);
|
||||
}
|
||||
if (!part.mapFaces.isEmpty()) {
|
||||
if (!part.faces.isEmpty()) {
|
||||
partObj.add("faces", faces);
|
||||
}
|
||||
elements.add(partObj);
|
||||
@@ -324,9 +324,9 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
|
||||
private JsonArray serializeVector3f(Vector3f vec) {
|
||||
JsonArray ret = new JsonArray();
|
||||
ret.add(serializeFloat(vec.getX()));
|
||||
ret.add(serializeFloat(vec.getY()));
|
||||
ret.add(serializeFloat(vec.getZ()));
|
||||
ret.add(serializeFloat(vec.x()));
|
||||
ret.add(serializeFloat(vec.y()));
|
||||
ret.add(serializeFloat(vec.z()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -350,9 +350,9 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
}
|
||||
|
||||
private void validatePosition(Vector3f pos) {
|
||||
validateCoordinate(pos.getX(), 'x');
|
||||
validateCoordinate(pos.getY(), 'y');
|
||||
validateCoordinate(pos.getZ(), 'z');
|
||||
validateCoordinate(pos.x(), 'x');
|
||||
validateCoordinate(pos.y(), 'y');
|
||||
validateCoordinate(pos.z(), 'z');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -363,7 +363,7 @@ public abstract class ModelProvider<T extends ModelBuilder<T>> implements IDataP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(DirectoryCache cache) throws IOException {
|
||||
public void run(DirectoryCache cache) throws IOException {
|
||||
clear();
|
||||
registerModels();
|
||||
generateAll(cache);
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockstate {
|
||||
}
|
||||
|
||||
public boolean canApplyTo(Block b) {
|
||||
return b.getStateContainer().getProperties().containsAll(conditions.keySet());
|
||||
return b.getStateDefinition().getProperties().containsAll(conditions.keySet());
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -86,7 +86,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
|
||||
|
||||
@Override
|
||||
public JsonObject toJson() {
|
||||
List<BlockState> missingStates = Lists.newArrayList(owner.getStateContainer().getValidStates());
|
||||
List<BlockState> missingStates = Lists.newArrayList(owner.getStateDefinition().getPossibleStates());
|
||||
missingStates.removeAll(coveredStates);
|
||||
Preconditions.checkState(missingStates.isEmpty(), "Blockstate for block %s does not cover all states. Missing: %s", owner, missingStates);
|
||||
JsonObject variants = new JsonObject();
|
||||
@@ -119,7 +119,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
|
||||
if (!this.models.containsKey(state)) {
|
||||
Preconditions.checkArgument(disjointToAll(state), "Cannot set models for a state for which a partial match has already been configured");
|
||||
this.models.put(state, new ConfiguredModelList(models));
|
||||
for (BlockState fullState : owner.getStateContainer().getValidStates()) {
|
||||
for (BlockState fullState : owner.getStateDefinition().getPossibleStates()) {
|
||||
if (state.test(fullState)) {
|
||||
coveredStates.add(fullState);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
|
||||
|
||||
public VariantBlockStateBuilder forAllStatesExcept(Function<BlockState, ConfiguredModel[]> mapper, Property<?>... ignored) {
|
||||
Set<PartialBlockstate> seen = new HashSet<>();
|
||||
for (BlockState fullState : owner.getStateContainer().getValidStates()) {
|
||||
for (BlockState fullState : owner.getStateDefinition().getPossibleStates()) {
|
||||
Map<Property<?>, Comparable<?>> propertyValues = Maps.newLinkedHashMap(fullState.getValues());
|
||||
for (Property<?> p : ignored) {
|
||||
propertyValues.remove(p);
|
||||
@@ -191,8 +191,8 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
|
||||
for (Map.Entry<Property<?>, Comparable<?>> entry : setStates.entrySet()) {
|
||||
Property<?> prop = entry.getKey();
|
||||
Comparable<?> value = entry.getValue();
|
||||
Preconditions.checkArgument(owner.getStateContainer().getProperties().contains(prop), "Property %s not found on block %s", entry, this.owner);
|
||||
Preconditions.checkArgument(prop.getAllowedValues().contains(value), "%s is not a valid value for %s", value, prop);
|
||||
Preconditions.checkArgument(owner.getStateDefinition().getProperties().contains(prop), "Property %s not found on block %s", entry, this.owner);
|
||||
Preconditions.checkArgument(prop.getPossibleValues().contains(value), "%s is not a valid value for %s", value, prop);
|
||||
}
|
||||
this.setStates = Maps.newTreeMap(Comparator.comparing(Property::getName));
|
||||
this.setStates.putAll(setStates);
|
||||
@@ -291,7 +291,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
|
||||
return false;
|
||||
}
|
||||
for (Map.Entry<Property<?>, Comparable<?>> entry : setStates.entrySet()) {
|
||||
if (blockState.get(entry.getKey()) != entry.getValue()) {
|
||||
if (blockState.getValue(entry.getKey()) != entry.getValue()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ public class OBJLoader implements IModelLoader<OBJModel>
|
||||
|
||||
String modelLocation = modelContents.get("model").getAsString();
|
||||
|
||||
boolean detectCullableFaces = JSONUtils.getBoolean(modelContents, "detectCullableFaces", true);
|
||||
boolean diffuseLighting = JSONUtils.getBoolean(modelContents, "diffuseLighting", false);
|
||||
boolean flipV = JSONUtils.getBoolean(modelContents, "flip-v", false);
|
||||
boolean ambientToFullbright = JSONUtils.getBoolean(modelContents, "ambientToFullbright", true);
|
||||
boolean detectCullableFaces = JSONUtils.getAsBoolean(modelContents, "detectCullableFaces", true);
|
||||
boolean diffuseLighting = JSONUtils.getAsBoolean(modelContents, "diffuseLighting", false);
|
||||
boolean flipV = JSONUtils.getAsBoolean(modelContents, "flip-v", false);
|
||||
boolean ambientToFullbright = JSONUtils.getAsBoolean(modelContents, "ambientToFullbright", true);
|
||||
@Nullable
|
||||
String materialLibraryOverrideLocation = modelContents.has("materialLibraryOverride") ? JSONUtils.getString(modelContents, "materialLibraryOverride") : null;
|
||||
String materialLibraryOverrideLocation = modelContents.has("materialLibraryOverride") ? JSONUtils.getAsString(modelContents, "materialLibraryOverride") : null;
|
||||
|
||||
return loadModel(new OBJModel.ModelSettings(new ResourceLocation(modelLocation), detectCullableFaces, diffuseLighting, flipV, ambientToFullbright, materialLibraryOverrideLocation));
|
||||
}
|
||||
|
||||
@@ -287,9 +287,9 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
{
|
||||
Vector4f vec4 = parseVector4(line);
|
||||
return new Vector3f(
|
||||
vec4.getX() / vec4.getW(),
|
||||
vec4.getY() / vec4.getW(),
|
||||
vec4.getZ() / vec4.getW()
|
||||
vec4.x() / vec4.w(),
|
||||
vec4.y() / vec4.w(),
|
||||
vec4.z() / vec4.w()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -368,7 +368,7 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
Vector2f uv2 = new Vector2f(0, 0);
|
||||
if (ambientToFullbright)
|
||||
{
|
||||
int fakeLight = (int) ((ambientColor.getX() + ambientColor.getY() + ambientColor.getZ()) * 15 / 3.0f);
|
||||
int fakeLight = (int) ((ambientColor.x() + ambientColor.y() + ambientColor.z()) * 15 / 3.0f);
|
||||
uv2 = new Vector2f((fakeLight << 4) / 32767.0f, (fakeLight << 4) / 32767.0f);
|
||||
builder.setApplyDiffuseLighting(fakeLight == 0);
|
||||
}
|
||||
@@ -397,65 +397,65 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
transformation.transformNormal(normal);
|
||||
};
|
||||
Vector4f tintedColor = new Vector4f(
|
||||
color.getX() * colorTint.getX(),
|
||||
color.getY() * colorTint.getY(),
|
||||
color.getZ() * colorTint.getZ(),
|
||||
color.getW() * colorTint.getW());
|
||||
color.x() * colorTint.x(),
|
||||
color.y() * colorTint.y(),
|
||||
color.z() * colorTint.z(),
|
||||
color.w() * colorTint.w());
|
||||
putVertexData(builder, position, texCoord, normal, tintedColor, uv2, texture);
|
||||
pos[i] = position;
|
||||
norm[i] = normal;
|
||||
}
|
||||
|
||||
builder.setQuadOrientation(Direction.getFacingFromVector(norm[0].getX(), norm[0].getY(),norm[0].getZ()));
|
||||
builder.setQuadOrientation(Direction.getNearest(norm[0].x(), norm[0].y(),norm[0].z()));
|
||||
|
||||
Direction cull = null;
|
||||
if (detectCullableFaces)
|
||||
{
|
||||
if (MathHelper.epsilonEquals(pos[0].getX(), 0) && // vertex.position.x
|
||||
MathHelper.epsilonEquals(pos[1].getX(), 0) &&
|
||||
MathHelper.epsilonEquals(pos[2].getX(), 0) &&
|
||||
MathHelper.epsilonEquals(pos[3].getX(), 0) &&
|
||||
norm[0].getX() < 0) // vertex.normal.x
|
||||
if (MathHelper.equal(pos[0].x(), 0) && // vertex.position.x
|
||||
MathHelper.equal(pos[1].x(), 0) &&
|
||||
MathHelper.equal(pos[2].x(), 0) &&
|
||||
MathHelper.equal(pos[3].x(), 0) &&
|
||||
norm[0].x() < 0) // vertex.normal.x
|
||||
{
|
||||
cull = Direction.WEST;
|
||||
}
|
||||
else if (MathHelper.epsilonEquals(pos[0].getX(), 1) && // vertex.position.x
|
||||
MathHelper.epsilonEquals(pos[1].getX(), 1) &&
|
||||
MathHelper.epsilonEquals(pos[2].getX(), 1) &&
|
||||
MathHelper.epsilonEquals(pos[3].getX(), 1) &&
|
||||
norm[0].getX() > 0) // vertex.normal.x
|
||||
else if (MathHelper.equal(pos[0].x(), 1) && // vertex.position.x
|
||||
MathHelper.equal(pos[1].x(), 1) &&
|
||||
MathHelper.equal(pos[2].x(), 1) &&
|
||||
MathHelper.equal(pos[3].x(), 1) &&
|
||||
norm[0].x() > 0) // vertex.normal.x
|
||||
{
|
||||
cull = Direction.EAST;
|
||||
}
|
||||
else if (MathHelper.epsilonEquals(pos[0].getZ(), 0) && // vertex.position.z
|
||||
MathHelper.epsilonEquals(pos[1].getZ(), 0) &&
|
||||
MathHelper.epsilonEquals(pos[2].getZ(), 0) &&
|
||||
MathHelper.epsilonEquals(pos[3].getZ(), 0) &&
|
||||
norm[0].getZ() < 0) // vertex.normal.z
|
||||
else if (MathHelper.equal(pos[0].z(), 0) && // vertex.position.z
|
||||
MathHelper.equal(pos[1].z(), 0) &&
|
||||
MathHelper.equal(pos[2].z(), 0) &&
|
||||
MathHelper.equal(pos[3].z(), 0) &&
|
||||
norm[0].z() < 0) // vertex.normal.z
|
||||
{
|
||||
cull = Direction.NORTH; // can never remember
|
||||
}
|
||||
else if (MathHelper.epsilonEquals(pos[0].getZ(), 1) && // vertex.position.z
|
||||
MathHelper.epsilonEquals(pos[1].getZ(), 1) &&
|
||||
MathHelper.epsilonEquals(pos[2].getZ(), 1) &&
|
||||
MathHelper.epsilonEquals(pos[3].getZ(), 1) &&
|
||||
norm[0].getZ() > 0) // vertex.normal.z
|
||||
else if (MathHelper.equal(pos[0].z(), 1) && // vertex.position.z
|
||||
MathHelper.equal(pos[1].z(), 1) &&
|
||||
MathHelper.equal(pos[2].z(), 1) &&
|
||||
MathHelper.equal(pos[3].z(), 1) &&
|
||||
norm[0].z() > 0) // vertex.normal.z
|
||||
{
|
||||
cull = Direction.SOUTH;
|
||||
}
|
||||
else if (MathHelper.epsilonEquals(pos[0].getY(), 0) && // vertex.position.y
|
||||
MathHelper.epsilonEquals(pos[1].getY(), 0) &&
|
||||
MathHelper.epsilonEquals(pos[2].getY(), 0) &&
|
||||
MathHelper.epsilonEquals(pos[3].getY(), 0) &&
|
||||
norm[0].getY() < 0) // vertex.normal.z
|
||||
else if (MathHelper.equal(pos[0].y(), 0) && // vertex.position.y
|
||||
MathHelper.equal(pos[1].y(), 0) &&
|
||||
MathHelper.equal(pos[2].y(), 0) &&
|
||||
MathHelper.equal(pos[3].y(), 0) &&
|
||||
norm[0].y() < 0) // vertex.normal.z
|
||||
{
|
||||
cull = Direction.DOWN; // can never remember
|
||||
}
|
||||
else if (MathHelper.epsilonEquals(pos[0].getY(), 1) && // vertex.position.y
|
||||
MathHelper.epsilonEquals(pos[1].getY(), 1) &&
|
||||
MathHelper.epsilonEquals(pos[2].getY(), 1) &&
|
||||
MathHelper.epsilonEquals(pos[3].getY(), 1) &&
|
||||
norm[0].getY() > 0) // vertex.normal.y
|
||||
else if (MathHelper.equal(pos[0].y(), 1) && // vertex.position.y
|
||||
MathHelper.equal(pos[1].y(), 1) &&
|
||||
MathHelper.equal(pos[2].y(), 1) &&
|
||||
MathHelper.equal(pos[3].y(), 1) &&
|
||||
norm[0].y() > 0) // vertex.normal.y
|
||||
{
|
||||
cull = Direction.UP;
|
||||
}
|
||||
@@ -473,18 +473,18 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
switch(e.getUsage())
|
||||
{
|
||||
case POSITION:
|
||||
consumer.put(j, position0.getX(), position0.getY(), position0.getZ(), position0.getW());
|
||||
consumer.put(j, position0.x(), position0.y(), position0.z(), position0.w());
|
||||
break;
|
||||
case COLOR:
|
||||
consumer.put(j, color0.getX(), color0.getY(), color0.getZ(), color0.getW());
|
||||
consumer.put(j, color0.x(), color0.y(), color0.z(), color0.w());
|
||||
break;
|
||||
case UV:
|
||||
switch (e.getIndex())
|
||||
{
|
||||
case 0:
|
||||
consumer.put(j,
|
||||
texture.getInterpolatedU(texCoord0.x * 16),
|
||||
texture.getInterpolatedV((flipV ? (1 - texCoord0.y) : texCoord0.y) * 16)
|
||||
texture.getU(texCoord0.x * 16),
|
||||
texture.getV((flipV ? (1 - texCoord0.y) : texCoord0.y) * 16)
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
@@ -496,7 +496,7 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
}
|
||||
break;
|
||||
case NORMAL:
|
||||
consumer.put(j, normal0.getX(), normal0.getY(), normal0.getZ());
|
||||
consumer.put(j, normal0.x(), normal0.y(), normal0.z());
|
||||
break;
|
||||
default:
|
||||
consumer.put(j);
|
||||
|
||||
@@ -129,8 +129,8 @@ public class BakedQuadBuilder implements IVertexConsumer
|
||||
}
|
||||
if(contractUVs)
|
||||
{
|
||||
float tX = texture.getWidth() / (texture.getMaxU() - texture.getMinU());
|
||||
float tY = texture.getHeight() / (texture.getMaxV() - texture.getMinV());
|
||||
float tX = texture.getWidth() / (texture.getU1() - texture.getU0());
|
||||
float tY = texture.getHeight() / (texture.getV1() - texture.getV0());
|
||||
float tS = tX > tY ? tX : tY;
|
||||
float ep = 1f / (tS * 0x100);
|
||||
int uve = 0;
|
||||
|
||||
@@ -119,29 +119,29 @@ public class BlockInfo
|
||||
{
|
||||
for(int z = 0; z <= 2; z++)
|
||||
{
|
||||
BlockPos pos = blockPos.add(x - 1, y - 1, z - 1);
|
||||
BlockPos pos = blockPos.offset(x - 1, y - 1, z - 1);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
t[x][y][z] = state.getOpacity(world, pos) < 15;
|
||||
int brightness = WorldRenderer.getCombinedLight(world, pos);
|
||||
s[x][y][z] = LightTexture.getLightSky(brightness);
|
||||
b[x][y][z] = LightTexture.getLightBlock(brightness);
|
||||
ao[x][y][z] = state.getAmbientOcclusionLightValue(world, pos);
|
||||
t[x][y][z] = state.getLightBlock(world, pos) < 15;
|
||||
int brightness = WorldRenderer.getLightColor(world, pos);
|
||||
s[x][y][z] = LightTexture.sky(brightness);
|
||||
b[x][y][z] = LightTexture.block(brightness);
|
||||
ao[x][y][z] = state.getShadeBrightness(world, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Direction side : SIDES)
|
||||
{
|
||||
BlockPos pos = blockPos.offset(side);
|
||||
BlockPos pos = blockPos.relative(side);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
BlockState thisStateShape = this.state.isSolid() && this.state.isTransparent() ? this.state : Blocks.AIR.getDefaultState();
|
||||
BlockState otherStateShape = state.isSolid() && state.isTransparent() ? state : Blocks.AIR.getDefaultState();
|
||||
BlockState thisStateShape = this.state.canOcclude() && this.state.useShapeForLightOcclusion() ? this.state : Blocks.AIR.defaultBlockState();
|
||||
BlockState otherStateShape = state.canOcclude() && state.useShapeForLightOcclusion() ? state : Blocks.AIR.defaultBlockState();
|
||||
|
||||
if(state.getOpacity(world, pos) == 15 || VoxelShapes.faceShapeCovers(thisStateShape.getFaceOcclusionShape(world, blockPos, side), otherStateShape.getFaceOcclusionShape(world, pos, side.getOpposite())))
|
||||
if(state.getLightBlock(world, pos) == 15 || VoxelShapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(world, blockPos, side), otherStateShape.getFaceOcclusionShape(world, pos, side.getOpposite())))
|
||||
{
|
||||
int x = side.getXOffset() + 1;
|
||||
int y = side.getYOffset() + 1;
|
||||
int z = side.getZOffset() + 1;
|
||||
int x = side.getStepX() + 1;
|
||||
int y = side.getStepY() + 1;
|
||||
int z = side.getStepZ() + 1;
|
||||
s[x][y][z] = Math.max(s[1][1][1] - 1, s[x][y][z]);
|
||||
b[x][y][z] = Math.max(b[1][1][1] - 1, b[x][y][z]);
|
||||
}
|
||||
@@ -189,13 +189,13 @@ public class BlockInfo
|
||||
|
||||
public void updateFlatLighting()
|
||||
{
|
||||
full = Block.isOpaque(state.getCollisionShape(world, blockPos));
|
||||
packed[0] = WorldRenderer.getCombinedLight(world, blockPos);
|
||||
full = Block.isShapeFullBlock(state.getCollisionShape(world, blockPos));
|
||||
packed[0] = WorldRenderer.getLightColor(world, blockPos);
|
||||
|
||||
for (Direction side : SIDES)
|
||||
{
|
||||
int i = side.ordinal() + 1;
|
||||
packed[i] = WorldRenderer.getCombinedLight(world, blockPos.offset(side));
|
||||
packed[i] = WorldRenderer.getLightColor(world, blockPos.relative(side));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
|
||||
VertexLighterFlat lighter = lighterFlat.get();
|
||||
lighter.setParent(consumer);
|
||||
lighter.setTransform(matrixStack.getLast());
|
||||
lighter.setTransform(matrixStack.last());
|
||||
|
||||
return render(lighter, world, model, state, pos, matrixStack, checkSides, rand, seed, modelData);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
|
||||
VertexLighterSmoothAo lighter = lighterSmooth.get();
|
||||
lighter.setParent(consumer);
|
||||
lighter.setTransform(matrixStack.getLast());
|
||||
lighter.setTransform(matrixStack.last());
|
||||
|
||||
return render(lighter, world, model, state, pos, matrixStack, checkSides, rand, seed, modelData);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
||||
quads = model.getQuads(state, side, rand, modelData);
|
||||
if(!quads.isEmpty())
|
||||
{
|
||||
if(!checkSides || Block.shouldSideBeRendered(state, world, pos, side))
|
||||
if(!checkSides || Block.shouldRenderFace(state, world, pos, side))
|
||||
{
|
||||
if(empty) lighter.updateBlockInfo();
|
||||
empty = false;
|
||||
|
||||
@@ -88,12 +88,12 @@ public class LightUtil
|
||||
public static void putBakedQuad(IVertexConsumer consumer, BakedQuad quad)
|
||||
{
|
||||
consumer.setTexture(quad.getSprite());
|
||||
consumer.setQuadOrientation(quad.getFace());
|
||||
if(quad.hasTintIndex())
|
||||
consumer.setQuadOrientation(quad.getDirection());
|
||||
if(quad.isTinted())
|
||||
{
|
||||
consumer.setQuadTint(quad.getTintIndex());
|
||||
}
|
||||
consumer.setApplyDiffuseLighting(quad.applyDiffuseLighting());
|
||||
consumer.setApplyDiffuseLighting(quad.isShade());
|
||||
float[] data = new float[4];
|
||||
VertexFormat formatFrom = consumer.getVertexFormat();
|
||||
VertexFormat formatTo = DefaultVertexFormats.BLOCK;
|
||||
@@ -106,7 +106,7 @@ public class LightUtil
|
||||
{
|
||||
if(eMap[e] != countTo)
|
||||
{
|
||||
unpack(quad.getVertexData(), data, formatTo, v, eMap[e]);
|
||||
unpack(quad.getVertices(), data, formatTo, v, eMap[e]);
|
||||
consumer.put(e, data);
|
||||
}
|
||||
else
|
||||
@@ -156,7 +156,7 @@ public class LightUtil
|
||||
{
|
||||
int length = 4 < to.length ? 4 : to.length;
|
||||
VertexFormatElement element = formatFrom.getElements().get(e);
|
||||
int vertexStart = v * formatFrom.getSize() + formatFrom.getOffset(e);
|
||||
int vertexStart = v * formatFrom.getVertexSize() + formatFrom.getOffset(e);
|
||||
int count = element.getElementCount();
|
||||
VertexFormatElement.Type type = element.getType();
|
||||
VertexFormatElement.Usage usage = element.getUsage();
|
||||
@@ -211,7 +211,7 @@ public class LightUtil
|
||||
public static void pack(float[] from, int[] to, VertexFormat formatTo, int v, int e)
|
||||
{
|
||||
VertexFormatElement element = formatTo.getElements().get(e);
|
||||
int vertexStart = v * formatTo.getSize() + formatTo.getOffset(e);
|
||||
int vertexStart = v * formatTo.getVertexSize() + formatTo.getOffset(e);
|
||||
int count = element.getElementCount();
|
||||
VertexFormatElement.Type type = element.getType();
|
||||
int size = type.getSize();
|
||||
@@ -255,7 +255,7 @@ public class LightUtil
|
||||
|
||||
public static void setLightData(BakedQuad q, int light)
|
||||
{
|
||||
int[] data = q.getVertexData();
|
||||
int[] data = q.getVertices();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
data[getLightOffset(i)] = light;
|
||||
|
||||
@@ -41,17 +41,17 @@ public class TRSRTransformer extends VertexTransformer
|
||||
case POSITION:
|
||||
Vector4f pos = new Vector4f(data[0], data[1], data[2], data[3]);
|
||||
transform.transformPosition(pos);
|
||||
data[0] = pos.getX();
|
||||
data[1] = pos.getY();
|
||||
data[2] = pos.getZ();
|
||||
data[3] = pos.getW();
|
||||
data[0] = pos.x();
|
||||
data[1] = pos.y();
|
||||
data[2] = pos.z();
|
||||
data[3] = pos.w();
|
||||
break;
|
||||
case NORMAL:
|
||||
Vector3f normal = new Vector3f(data);
|
||||
transform.transformNormal(normal);
|
||||
data[0] = normal.getX();
|
||||
data[1] = normal.getY();
|
||||
data[2] = normal.getZ();
|
||||
data[0] = normal.x();
|
||||
data[1] = normal.y();
|
||||
data[2] = normal.z();
|
||||
break;
|
||||
}
|
||||
super.put(element, data);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class VertexBufferConsumer implements IVertexConsumer
|
||||
switch (e)
|
||||
{
|
||||
case 0: // POSITION_3F
|
||||
renderer.pos(d0, d1, d2);
|
||||
renderer.vertex(d0, d1, d2);
|
||||
break;
|
||||
case 4: // NORMAL_3B
|
||||
renderer.normal(d0, d1, d2);
|
||||
@@ -66,10 +66,10 @@ public class VertexBufferConsumer implements IVertexConsumer
|
||||
renderer.color(d0, d1, d2, d3);
|
||||
break;
|
||||
case 2: // TEX_2F
|
||||
renderer.tex(d0, d1);
|
||||
renderer.uv(d0, d1);
|
||||
break;
|
||||
case 3: // TEX_2SB
|
||||
renderer.lightmap((int) (d0 * 0xF0), (int) (d1 * 0xF0));
|
||||
renderer.uv2((int) (d0 * 0xF0), (int) (d1 * 0xF0));
|
||||
break;
|
||||
case 5: // PADDING_1B
|
||||
break;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
|
||||
// TODO 1.16/1.17 possibly refactor out the need for the "unpacked" format entirely. It's creating more headaches than solutions.
|
||||
// This mess reverses the conversion to float bits done in LightUtil.unpack
|
||||
private static final int LIGHTMAP_PACKING_FACTOR = ((256 << (8 * (DefaultVertexFormats.TEX_2SB.getType().getSize() - 1))) - 1) >>> 1;
|
||||
private static final int LIGHTMAP_PACKING_FACTOR = ((256 << (8 * (DefaultVertexFormats.ELEMENT_UV2.getType().getSize() - 1))) - 1) >>> 1;
|
||||
// Max lightmap value, for rescaling
|
||||
private static final int LIGHTMAP_MAX = 0xF0;
|
||||
// Inlined factor for rescaling input lightmap values, "rounded" up to the next float value to avoid precision loss when result is truncated to int
|
||||
@@ -172,9 +172,9 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
v2.normalize();
|
||||
for(int v = 0; v < 4; v++)
|
||||
{
|
||||
normal[v][0] = v2.getX();
|
||||
normal[v][1] = v2.getY();
|
||||
normal[v][2] = v2.getZ();
|
||||
normal[v][0] = v2.x();
|
||||
normal[v][1] = v2.y();
|
||||
normal[v][2] = v2.z();
|
||||
normal[v][3] = 0;
|
||||
}
|
||||
}
|
||||
@@ -227,20 +227,20 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
case POSITION:
|
||||
final Vector4f pos = new Vector4f(
|
||||
position[v][0], position[v][1], position[v][2], 1);
|
||||
pos.transform(pose.getMatrix());
|
||||
pos.transform(pose.pose());
|
||||
|
||||
position[v][0] = pos.getX();
|
||||
position[v][1] = pos.getY();
|
||||
position[v][2] = pos.getZ();
|
||||
position[v][0] = pos.x();
|
||||
position[v][1] = pos.y();
|
||||
position[v][2] = pos.z();
|
||||
parent.put(e, position[v]);
|
||||
break;
|
||||
case NORMAL:
|
||||
final Vector3f norm = new Vector3f(normal[v]);
|
||||
norm.transform(pose.getNormal());
|
||||
norm.transform(pose.normal());
|
||||
|
||||
normal[v][0] = norm.getX();
|
||||
normal[v][1] = norm.getY();
|
||||
normal[v][2] = norm.getZ();
|
||||
normal[v][0] = norm.x();
|
||||
normal[v][1] = norm.y();
|
||||
normal[v][2] = norm.z();
|
||||
parent.put(e, normal[v]);
|
||||
break;
|
||||
case COLOR:
|
||||
@@ -279,8 +279,8 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
int i = side == null ? 0 : side.ordinal() + 1;
|
||||
int brightness = blockInfo.getPackedLight()[i];
|
||||
|
||||
lightmap[0] = LightTexture.getLightBlock(brightness) / (float) 0xF;
|
||||
lightmap[1] = LightTexture.getLightSky(brightness) / (float) 0xF;
|
||||
lightmap[0] = LightTexture.block(brightness) / (float) 0xF;
|
||||
lightmap[1] = LightTexture.sky(brightness) / (float) 0xF;
|
||||
}
|
||||
|
||||
protected void updateColor(float[] normal, float[] color, float x, float y, float z, float tint, int multiplier)
|
||||
|
||||
Reference in new issue
Block a user