Try custom slab model. Json patterns.
This commit is contained in:
parent
287c1fce62
commit
59fe3183b0
60 changed files with 1557 additions and 144 deletions
|
@ -18,6 +18,7 @@ import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView;
|
|||
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
||||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
|
@ -30,13 +31,12 @@ import net.minecraft.client.render.model.json.ModelTransformation;
|
|||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.util.math.AffineTransformation;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class BaseBlockModel implements UnbakedModel, BakedModel, FabricBakedModel {
|
||||
|
@ -70,15 +70,9 @@ public class BaseBlockModel implements UnbakedModel, BakedModel, FabricBakedMode
|
|||
MeshBuilder builder = renderer.meshBuilder();
|
||||
QuadEmitter emitter = builder.getEmitter();
|
||||
|
||||
Vector3f rotation = AffineTransformation.getLinearTransformationAndTranslationFromAffine(rotationContainer.getRotation().getMatrix()).getSecond();
|
||||
|
||||
System.out.println("=====");
|
||||
System.out.println(rotation);
|
||||
|
||||
Direction[] directions = Direction.values();
|
||||
for (Direction direction : directions) {
|
||||
Direction rotate = Direction.transform(rotationContainer.getRotation().getMatrix(), direction);
|
||||
this.rotate(emitter, direction, rotate);
|
||||
emitter.square(direction, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
switch (sprites.length) {
|
||||
case 1: {
|
||||
emitter.spriteBake(0, sprites[0], MutableQuadView.BAKE_LOCK_UV);
|
||||
|
@ -160,138 +154,7 @@ public class BaseBlockModel implements UnbakedModel, BakedModel, FabricBakedMode
|
|||
return this;
|
||||
}
|
||||
|
||||
private void rotate(QuadEmitter emitter, Direction direction, Direction rotation) {
|
||||
switch (direction) {
|
||||
case NORTH: {
|
||||
switch (rotation) {
|
||||
case DOWN:
|
||||
case SOUTH: {
|
||||
emitter.square(rotation, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
emitter.square(rotation, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
emitter.square(rotation, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
emitter.square(rotation, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
switch (rotation) {
|
||||
case DOWN:
|
||||
case NORTH: {
|
||||
emitter.square(rotation, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
emitter.square(rotation, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
emitter.square(rotation, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
emitter.square(rotation, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
switch (rotation) {
|
||||
case NORTH: {
|
||||
emitter.square(rotation, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
emitter.square(rotation, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case DOWN:
|
||||
case WEST: {
|
||||
emitter.square(rotation, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
emitter.square(rotation, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
switch (rotation) {
|
||||
case NORTH: {
|
||||
emitter.square(rotation, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
emitter.square(rotation, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case DOWN:
|
||||
case EAST: {
|
||||
emitter.square(rotation, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
emitter.square(rotation, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
switch (rotation) {
|
||||
case EAST: {
|
||||
emitter.square(rotation, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
emitter.square(rotation, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case SOUTH:
|
||||
case UP: {
|
||||
emitter.square(rotation, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
emitter.square(rotation, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UP: {
|
||||
switch (rotation) {
|
||||
case EAST: {
|
||||
emitter.square(rotation, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
emitter.square(rotation, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case SOUTH:
|
||||
case DOWN: {
|
||||
emitter.square(rotation, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
emitter.square(rotation, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isVanillaAdapter() {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue