Skip to content

Commit

Permalink
Merge pull request #28 from modmuss50/1.15
Browse files Browse the repository at this point in the history
1.15
  • Loading branch information
Vexatos authored Mar 12, 2020
2 parents 650b3d2 + d94025c commit 22ef5aa
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 120 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:0.2.3-SNAPSHOT"
classpath "net.fabricmc:fabric-loom:0.2.6-SNAPSHOT"
}
}

Expand All @@ -26,16 +26,16 @@ targetCompatibility = 1.8

group = "com.reddit.user.koppeh.flamingo"
archivesBaseName = "Flamingo"
version = "1.14.3-1.15"
version = "1.15-1.16"

minecraft {
}

dependencies {
minecraft "com.mojang:minecraft:1.14.3"
mappings "net.fabricmc:yarn:1.14.3+build.12"
modCompile "net.fabricmc:fabric-loader:0.4.8+build.155"
modCompile "net.fabricmc.fabric-api:fabric-api:0.3.0+build.198"
minecraft "com.mojang:minecraft:1.15.2"
mappings "net.fabricmc:yarn:1.15.2+build.14:v2"
modCompile "net.fabricmc:fabric-loader:0.7.8+build.187"
modCompile "net.fabricmc.fabric-api:fabric-api:0.5.1+build.294-1.15"
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static Item register(String name, Item item) {

public static <T extends BlockEntity> BlockEntityType<T> register(String name, BlockEntityType.Builder<T> builder) {
BlockEntityType<T> blockEntityType = builder.build(null);
Registry.register(Registry.BLOCK_ENTITY, MOD_ID + ":" + name, blockEntityType);
Registry.register(Registry.BLOCK_ENTITY_TYPE, MOD_ID + ":" + name, blockEntityType);
return blockEntityType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateFactory;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
Expand Down Expand Up @@ -41,7 +43,7 @@ public BlockRenderType getRenderType(BlockState var1) {
}

@Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(ROTATION);
}
Expand All @@ -67,8 +69,7 @@ public boolean onAttackInteraction(BlockState state, World world, BlockPos pos,
}

@Override
@Deprecated
public boolean onBlockAction(BlockState state, World world, BlockPos pos, int id, int value) {
public boolean onBlockAction(BlockState state, World world, BlockPos pos, int type, int data) {
if (world.getBlockEntity(pos) != null) {
((FlamingoBlockEntity) world.getBlockEntity(pos)).wiggle();
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
package com.reddit.user.koppeh.flamingo.client;

import com.mojang.blaze3d.platform.GlStateManager;
import com.reddit.user.koppeh.flamingo.FlamingoBlock;
import com.reddit.user.koppeh.flamingo.FlamingoBlockEntity;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier;
import net.minecraft.world.BlockView;
import org.lwjgl.opengl.GL11;

public class FlamingoBlockEntityRenderer extends BlockEntityRenderer<FlamingoBlockEntity> {

private FlamingoModel model = new FlamingoModel();
private Identifier resource = new Identifier("flamingo", "textures/model/flamingo.png");

public FlamingoBlockEntityRenderer(BlockEntityRenderDispatcher renderDispatcher) {
super(renderDispatcher);
}

@Override
public void render(FlamingoBlockEntity flamingo, double x, double y, double z, float partialTicks, int destroyStage) {
public void render(FlamingoBlockEntity flamingo, float partialTicks, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
int rotation = 0;
float wiggle = 0;

GlStateManager.enableDepthTest();
GlStateManager.depthFunc(GL11.GL_LEQUAL);
GlStateManager.depthMask(true);

bindTexture(resource);

GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();

GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);

if (flamingo != null) {
final BlockView world = flamingo.getWorld();
if (world != null) {
Expand All @@ -38,23 +34,19 @@ public void render(FlamingoBlockEntity flamingo, double x, double y, double z, f
wiggle = (float) Math.sin(flamingo.wiggle + partialTicks) * flamingo.wiggleStrength;
}

GlStateManager.translated(x, y, z);
GlStateManager.rotated(1.0F, 1.0F, -1.0F, -1.0F);
GlStateManager.translated(0.5F, 0F, 0.5F);
GlStateManager.rotated(rotation, 0.0F, -1.0F, 0.0F);
GlStateManager.rotated(1, 1F, 0, 0.0F);
GlStateManager.translated(0.0, 1.5, 0.0);
GlStateManager.rotated(180, 1.0F, 0.0F, 0.0F);
GlStateManager.translated(0.0, 1.5, 0.0);
GlStateManager.rotated(wiggle, 0.0F, 0.0F, 1.0F);
GlStateManager.translated(0.0, -1.5, 0.0);
matrixStack.push();

model.renderAll();
matrixStack.translate(0.5F, 0, 0.5F);
matrixStack.multiply(Vector3f.NEGATIVE_Y.getDegreesQuaternion(rotation));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(1F));
matrixStack.translate(0.0, 1.5, 0.0);
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180F));
matrixStack.translate(0.0, 1.5, 0.0);
matrixStack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(wiggle));
matrixStack.translate(0.0, -1.5, 0.0);

GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
model.render(matrixStack, vertexConsumerProvider.getBuffer(RenderLayer.getEntitySolid(resource)), i, j, 1F, 1F, 1F, 1F);

GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
matrixStack.pop();
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.reddit.user.koppeh.flamingo.client;

import com.reddit.user.koppeh.flamingo.FlamingoBlockEntity;
import com.reddit.user.koppeh.flamingo.Flamingo;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.render.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;

public class FlamingoClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
BlockEntityRendererRegistry.INSTANCE.register(FlamingoBlockEntity.class, new FlamingoBlockEntityRenderer());
BlockEntityRendererRegistry.INSTANCE.register(Flamingo.FLAMINGO_BLOCK_ENTITY, FlamingoBlockEntityRenderer::new);
}
}
Original file line number Diff line number Diff line change
@@ -1,115 +1,114 @@
package com.reddit.user.koppeh.flamingo.client;

import net.minecraft.client.model.Cuboid;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;

public class FlamingoModel extends EntityModel {

Cuboid beak;
Cuboid beakBase;
Cuboid head;
Cuboid neck;
Cuboid neckBase;
Cuboid bodyWingsMain;
Cuboid bodyWingsSecond;
Cuboid bodyMain;
Cuboid bodyTail;
Cuboid legRight;
Cuboid legLeft1;
Cuboid legLeft2;
Cuboid legLeft3;
ModelPart beak;
ModelPart beakBase;
ModelPart head;
ModelPart neck;
ModelPart neckBase;
ModelPart bodyWingsMain;
ModelPart bodyWingsSecond;
ModelPart bodyMain;
ModelPart bodyTail;
ModelPart legRight;
ModelPart legLeft1;
ModelPart legLeft2;
ModelPart legLeft3;

public FlamingoModel() {
beak = new Cuboid(this, 0, 3).setTextureSize(64, 64);
beak.addBox(-0.5F, 0F, 0F, 1, 2, 1);
beak.setRotationPoint(0F, 8F, -5F);
beak = new ModelPart(this, 0, 3).setTextureSize(64, 64);
beak.addCuboid(-0.5F, 0F, 0F, 1, 2, 1);
beak.setPivot(0F, 8F, -5F);
beak.setTextureSize(64, 64);

beakBase = new Cuboid(this, 4, 3).setTextureSize(64, 64);
beakBase.addBox(-0.5F, 0F, 0F, 1, 1, 1);
beakBase.setRotationPoint(0F, 8F, -4F);
beakBase = new ModelPart(this, 4, 3).setTextureSize(64, 64);
beakBase.addCuboid(-0.5F, 0F, 0F, 1, 1, 1);
beakBase.setPivot(0F, 8F, -4F);
beakBase.setTextureSize(64, 64);

head = new Cuboid(this, 8, 0).setTextureSize(64, 64);
head.addBox(-1F, 0F, 0F, 2, 2, 3);
head.setRotationPoint(0F, 7F, -3F);
head = new ModelPart(this, 8, 0).setTextureSize(64, 64);
head.addCuboid(-1F, 0F, 0F, 2, 2, 3);
head.setPivot(0F, 7F, -3F);
head.setTextureSize(64, 64);

neck = new Cuboid(this, 10, 5).setTextureSize(64, 64);
neck.addBox(-1F, 0F, 0F, 2, 3, 2);
neck.setRotationPoint(0F, 9F, -2F);
neck = new ModelPart(this, 10, 5).setTextureSize(64, 64);
neck.addCuboid(-1F, 0F, 0F, 2, 3, 2);
neck.setPivot(0F, 9F, -2F);
neck.setTextureSize(64, 64);

neckBase = new Cuboid(this, 6, 10).setTextureSize(64, 64);
neckBase.addBox(-1F, 0F, 0F, 2, 5, 2);
neckBase.setRotationPoint(0F, 11F, -3F);
neckBase = new ModelPart(this, 6, 10).setTextureSize(64, 64);
neckBase.addCuboid(-1F, 0F, 0F, 2, 5, 2);
neckBase.setPivot(0F, 11F, -3F);
neckBase.setTextureSize(64, 64);

bodyMain = new Cuboid(this, 26, 17).setTextureSize(64, 64);
bodyMain.addBox(-2F, 0F, 0F, 4, 4, 6);
bodyMain.setRotationPoint(0F, 14F, -2F);
bodyMain = new ModelPart(this, 26, 17).setTextureSize(64, 64);
bodyMain.addCuboid(-2F, 0F, 0F, 4, 4, 6);
bodyMain.setPivot(0F, 14F, -2F);
bodyMain.setTextureSize(64, 64);

bodyWingsMain = new Cuboid(this, 6, 17).setTextureSize(64, 64);
bodyWingsMain.addBox(-3F, 0F, 0F, 6, 3, 4);
bodyWingsMain.setRotationPoint(0F, 14F, -2F);
bodyWingsMain = new ModelPart(this, 6, 17).setTextureSize(64, 64);
bodyWingsMain.addCuboid(-3F, 0F, 0F, 6, 3, 4);
bodyWingsMain.setPivot(0F, 14F, -2F);
bodyWingsMain.setTextureSize(64, 64);

bodyWingsSecond = new Cuboid(this, 12, 24).setTextureSize(64, 64);
bodyWingsSecond.addBox(-3F, 0F, 0F, 6, 1, 1);
bodyWingsSecond.setRotationPoint(0F, 16F, 2F);
bodyWingsSecond = new ModelPart(this, 12, 24).setTextureSize(64, 64);
bodyWingsSecond.addCuboid(-3F, 0F, 0F, 6, 1, 1);
bodyWingsSecond.setPivot(0F, 16F, 2F);
bodyWingsSecond.setTextureSize(64, 64);

bodyTail = new Cuboid(this, 46, 17).setTextureSize(64, 64);
bodyTail.addBox(-2F, 0F, 0F, 4, 1, 2);
bodyTail.setRotationPoint(0F, 14F, 4F);
bodyTail = new ModelPart(this, 46, 17).setTextureSize(64, 64);
bodyTail.addCuboid(-2F, 0F, 0F, 4, 1, 2);
bodyTail.setPivot(0F, 14F, 4F);
bodyTail.setTextureSize(64, 64);

legRight = new Cuboid(this, 24, 27).setTextureSize(64, 64);
legRight.addBox(-1F, 0F, 0F, 1, 6, 1);
legRight.setRotationPoint(0F, 18F, 1F);
legRight = new ModelPart(this, 24, 27).setTextureSize(64, 64);
legRight.addCuboid(-1F, 0F, 0F, 1, 6, 1);
legRight.setPivot(0F, 18F, 1F);
legRight.setTextureSize(64, 64);

legLeft1 = new Cuboid(this, 20, 27).setTextureSize(64, 64);
legLeft1.addBox(0F, 0F, 0F, 1, 1, 1);
legLeft1.setRotationPoint(0F, 18F, 0F);
legLeft1 = new ModelPart(this, 20, 27).setTextureSize(64, 64);
legLeft1.addCuboid(0F, 0F, 0F, 1, 1, 1);
legLeft1.setPivot(0F, 18F, 0F);
legLeft1.setTextureSize(64, 64);

legLeft2 = new Cuboid(this, 16, 29).setTextureSize(64, 64);
legLeft2.addBox(0F, 0F, 0F, 1, 1, 1);
legLeft2.setRotationPoint(0F, 19F, -1F);
legLeft2 = new ModelPart(this, 16, 29).setTextureSize(64, 64);
legLeft2.addCuboid(0F, 0F, 0F, 1, 1, 1);
legLeft2.setPivot(0F, 19F, -1F);
legLeft2.setTextureSize(64, 64);

legLeft3 = new Cuboid(this, 12, 31).setTextureSize(64, 64);
legLeft3.addBox(0F, 0F, 0F, 1, 1, 5);
legLeft3.setRotationPoint(0F, 20F, -2F);
legLeft3 = new ModelPart(this, 12, 31).setTextureSize(64, 64);
legLeft3.addCuboid(0F, 0F, 0F, 1, 1, 5);
legLeft3.setPivot(0F, 20F, -2F);
legLeft3.setTextureSize(64, 64);

}

@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);

// setRotationAngles(f, f1, f2, f3, f4, f5, null);
beak.render(f5);
beakBase.render(f5);
head.render(f5);
neck.render(f5);
neckBase.render(f5);
bodyWingsMain.render(f5);
bodyWingsSecond.render(f5);
bodyMain.render(f5);
bodyTail.render(f5);
legRight.render(f5);
legLeft1.render(f5);
legLeft2.render(f5);
legLeft3.render(f5);
public void setAngles(Entity entity, float limbAngle, float limbDistance, float age, float headYaw, float headPitch) {

}

public void renderAll() {
render(null, 0, 0, 0, 0, 0, 1 / 16.0F);
@Override
public void render(MatrixStack matrixStack, VertexConsumer vertexConsumer, int i, int j, float r, float g, float b, float f) {
beak.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
beakBase.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
head.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
neck.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
neckBase.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
bodyWingsMain.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
bodyWingsSecond.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
bodyMain.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
bodyTail.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
legRight.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
legLeft1.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
legLeft2.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
legLeft3.render(matrixStack, vertexConsumer, i, j, r, g, b, f);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.reddit.user.koppeh.flamingo.Flamingo;
import com.reddit.user.koppeh.flamingo.FlamingoBlockEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.item.ItemDynamicRenderer;
import net.minecraft.client.render.item.BuiltinModelItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
Expand All @@ -12,14 +14,14 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ItemDynamicRenderer.class)
@Mixin(BuiltinModelItemRenderer.class)
public class ItemDynamicRendererMixin {
private final FlamingoBlockEntity flamingoRender = new FlamingoBlockEntity();

@Inject(at = @At("HEAD"), method = "render", cancellable = true)
public void render(ItemStack stack, CallbackInfo info) {
public void render(ItemStack stack, MatrixStack matrix, VertexConsumerProvider vertexConsumerProvider, int light, int overlay, CallbackInfo info) {
if (Registry.ITEM.getId(stack.getItem()).equals(new Identifier(Flamingo.MOD_ID, "flamingo"))) {
BlockEntityRenderDispatcher.INSTANCE.renderEntity(this.flamingoRender);
BlockEntityRenderDispatcher.INSTANCE.renderEntity(this.flamingoRender, matrix, vertexConsumerProvider, light, overlay);
info.cancel();
}
}
Expand Down

0 comments on commit 22ef5aa

Please sign in to comment.