Skip to content

Commit

Permalink
Made Like Easy to make more or whatever
Browse files Browse the repository at this point in the history
  • Loading branch information
LudoCrypt committed Oct 5, 2020
1 parent b014c23 commit 02de609
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;

Expand Down Expand Up @@ -49,4 +50,8 @@ public Block getCarvingBlock() {
return Blocks.PUMPKIN;
}

public Identifier getRenderId() {
return new Identifier("carvepump", "textures/entity/pumpkin_halo_colors.png");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
Expand Down Expand Up @@ -74,4 +75,9 @@ public Block getCarvingBlock() {
return Blocks.MELON;
}

@Override
public Identifier getRenderId() {
return new Identifier("carvepump", "textures/entity/melon_halo_colors.png");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.predicate.block.BlockStatePredicate;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.function.MaterialPredicate;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
Expand Down Expand Up @@ -95,6 +96,11 @@ public Block getCarvingBlock() {
return Blocks.PUMPKIN;
}

@Override
public Identifier getRenderId() {
return new Identifier("carvepump", "textures/entity/pumpkin_halo_colors.png");
}

// Pumpkin Spawning

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;

Expand Down Expand Up @@ -49,4 +50,8 @@ public Block getCarvingBlock() {
return Blocks.PUMPKIN;
}

public Identifier getRenderId() {
return new Identifier("carvepump", "textures/entity/jack_o_lantern_halo_colors.png");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
Expand Down Expand Up @@ -93,4 +94,9 @@ public Block getCarvingBlock() {
return Blocks.MELON;
}

@Override
public Identifier getRenderId() {
return new Identifier("carvepump", "textures/entity/jack_o_melon_halo_colors.png");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.predicate.block.BlockStatePredicate;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.function.MaterialPredicate;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
Expand Down Expand Up @@ -114,6 +115,11 @@ public Block getCarvingBlock() {
return Blocks.PUMPKIN;
}

@Override
public Identifier getRenderId() {
return new Identifier("carvepump", "textures/entity/jack_o_lantern_halo_colors.png");
}

// Pumpkin Spawning

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.ludocrypt.carvepump.CarveMyPumpkin;
import net.ludocrypt.carvepump.blocks.CarvableBlock;
import net.ludocrypt.carvepump.blocks.UncarvableBlock;
import net.ludocrypt.carvepump.blocks.entity.CarvedBlockEntity;
Expand All @@ -26,13 +25,8 @@

@Environment(EnvType.CLIENT)
public class CarvedBlockEntityRenderer extends BlockEntityRenderer<CarvedBlockEntity> {

private static final MinecraftClient client = MinecraftClient.getInstance();
public static Identifier PUMPKIN_HALO = new Identifier("carvepump", "textures/entity/pumpkin_halo_colors.png");
public static Identifier JACK_O_LANTERN_HALO = new Identifier("carvepump",
"textures/entity/jack_o_lantern_halo_colors.png");
public static Identifier MELON_HALO = new Identifier("carvepump", "textures/entity/melon_halo_colors.png");
public static Identifier JACK_O_MELON_HALO = new Identifier("carvepump",
"textures/entity/jack_o_melon_halo_colors.png");

public CarvedBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
super(blockEntityRenderDispatcher);
Expand All @@ -53,26 +47,20 @@ public void render(CarvedBlockEntity carvedBlockEntity, float f, MatrixStack mat
MinecraftClient.getInstance().getItemRenderer().renderItem(
new ItemStack(((CarvableBlock) block).getCarvingBlock()), ModelTransformation.Mode.NONE, lightAbove,
OverlayTexture.DEFAULT_UV, matrixStack, vertexConsumerProvider);

matrixStack.translate(-0.5, -0.5, -0.5);

renderFace(carvedBlockEntity, ((CarvableBlock) block).getRenderId(), matrixStack, vertexConsumerProvider,
lightAbove, OverlayTexture.DEFAULT_UV);
} else if (block instanceof UncarvableBlock) {
MinecraftClient.getInstance().getItemRenderer().renderItem(
new ItemStack(((UncarvableBlock) block).getCarvingBlock()), ModelTransformation.Mode.NONE,
lightAbove, OverlayTexture.DEFAULT_UV, matrixStack, vertexConsumerProvider);
}

matrixStack.translate(-0.5, -0.5, -0.5);

if (block == CarveMyPumpkin.CARVED_PUMPKIN) {
renderFace(carvedBlockEntity, PUMPKIN_HALO, matrixStack, vertexConsumerProvider, lightAbove,
OverlayTexture.DEFAULT_UV);
} else if (block == CarveMyPumpkin.JACK_O_LANTERN) {
renderFace(carvedBlockEntity, JACK_O_LANTERN_HALO, matrixStack, vertexConsumerProvider, lightAbove,
OverlayTexture.DEFAULT_UV);
} else if (block == CarveMyPumpkin.CARVED_MELON) {
renderFace(carvedBlockEntity, MELON_HALO, matrixStack, vertexConsumerProvider, lightAbove,
OverlayTexture.DEFAULT_UV);
} else if (block == CarveMyPumpkin.JACK_O_MELON) {
renderFace(carvedBlockEntity, JACK_O_MELON_HALO, matrixStack, vertexConsumerProvider, lightAbove,
OverlayTexture.DEFAULT_UV);
matrixStack.translate(-0.5, -0.5, -0.5);

renderFace(carvedBlockEntity, ((UncarvableBlock) block).getRenderId(), matrixStack, vertexConsumerProvider,
lightAbove, OverlayTexture.DEFAULT_UV);
}

matrixStack.pop();
Expand Down Expand Up @@ -207,35 +195,22 @@ public static void renderInHand(ItemStack stack, ModelTransformation.Mode mode,
dir = Direction.NORTH;
break;
}

if (block == CarveMyPumpkin.CARVED_PUMPKIN) {
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
renderModel(x, y, carving, PUMPKIN_HALO, dir, matrixStack, vertexConsumerProvider, i,
j);
}
}
} else if (block == CarveMyPumpkin.JACK_O_LANTERN) {
if (block instanceof CarvableBlock) {
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
renderModel(x, y, carving, JACK_O_LANTERN_HALO, dir, matrixStack,
renderModel(x, y, carving, ((CarvableBlock) block).getRenderId(), dir, matrixStack,
vertexConsumerProvider, i, j);
}
}
} else if (block == CarveMyPumpkin.CARVED_MELON) {
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
renderModel(x, y, carving, MELON_HALO, dir, matrixStack, vertexConsumerProvider, i, j);
}
}
} else if (block == CarveMyPumpkin.JACK_O_MELON) {
} else if (block instanceof UncarvableBlock) {
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
renderModel(x, y, carving, JACK_O_MELON_HALO, dir, matrixStack, vertexConsumerProvider,
i, j);
renderModel(x, y, carving, ((UncarvableBlock) block).getRenderId(), dir, matrixStack,
vertexConsumerProvider, i, j);
}
}
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ActionResult useOnBlock(ItemUsageContext context) {
}));
}
if (carvedPumpkinBlockEntity.isUncarved()) {
world.setBlockState(pos, Blocks.PUMPKIN.getDefaultState(), 2);
world.setBlockState(pos, ((CarvableBlock) block).getCarvingBlock().getDefaultState(), 2);
}
return ActionResult.SUCCESS;
} else {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 02de609

Please sign in to comment.