use of com.bergerkiller.bukkit.common.map.util.Model in project BKCommonLib by bergerhealer.
the class FluidRenderingProvider method createModel.
@Override
public Model createModel(MapResourcePack resources, BlockRenderOptions options) {
// Read all water blocks from options
FluidBlock self = getFluidBlock(options.getBlockData());
FluidBlock neigh_nn = readFluidBlock(options, "neigh_nn");
FluidBlock neigh_ne = readFluidBlock(options, "neigh_ne");
FluidBlock neigh_ee = readFluidBlock(options, "neigh_ee");
FluidBlock neigh_se = readFluidBlock(options, "neigh_se");
FluidBlock neigh_ss = readFluidBlock(options, "neigh_ss");
FluidBlock neigh_sw = readFluidBlock(options, "neigh_sw");
FluidBlock neigh_ww = readFluidBlock(options, "neigh_ww");
FluidBlock neigh_nw = readFluidBlock(options, "neigh_nw");
Model model = new Model();
Model.Element water = new Model.Element();
// Cut out only the first animation block from the texture
// This is the 'side' of the water where no water animations show
MapTexture waterSide = resources.getTexture(this.fluidTexture1);
waterSide = waterSide.getView(0, 0, waterSide.getWidth(), waterSide.getWidth()).clone();
// Cut out only the first animation block from the texture
// For now, we don't do animations in this renderer.
MapTexture waterTexture = resources.getTexture(this.fluidTexture2);
waterTexture = waterTexture.getView(0, 0, waterTexture.getWidth(), waterTexture.getWidth()).clone();
for (BlockFace blockFace : FaceUtil.BLOCK_SIDES) {
Model.Element.Face face = new Model.Element.Face();
// If blocked by some solid block, show the non-animated 'overlay' texture
// If flowing or top, show the flowing texture
// On the top, we always show the flowing texture
// TODO!
face.texture = FaceUtil.isVertical(blockFace) ? waterTexture : waterSide;
water.faces.put(blockFace, face);
}
water.buildQuads();
// Only do this when not flowing down
if (!isFlowingDown(options.getBlockData())) {
Face topFace = water.faces.get(BlockFace.UP);
topFace.quad.p0.y = calcLevel(self, neigh_ww, neigh_nw, neigh_nn);
topFace.quad.p1.y = calcLevel(self, neigh_ss, neigh_sw, neigh_ww);
topFace.quad.p2.y = calcLevel(self, neigh_ee, neigh_se, neigh_ss);
topFace.quad.p3.y = calcLevel(self, neigh_nn, neigh_ne, neigh_ee);
}
model.elements.add(water);
return model;
}
Aggregations