Skip to content

Commit

Permalink
Added Nebu Chain & fixed Curio Display block displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Mar 10, 2021
1 parent ab065d3 commit 294d8ef
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
Expand All @@ -30,11 +29,13 @@

public class CurioDisplayBlock extends ContainerBlock {
private static final VoxelShape SHAPE = makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 16.0D, 13.0D);
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;

public CurioDisplayBlock() {
super(AbstractBlock.Properties.create(Material.WOOD).hardnessAndResistance(1.5F, 1.0F).sound(SoundType.GLASS));
this.setDefaultState(this.stateContainer.getBaseState().with(WATERLOGGED, false));
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH).with(WATERLOGGED, false));
}

@Override
Expand Down Expand Up @@ -119,7 +120,7 @@ public FluidState getFluidState(BlockState state) {
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
FluidState fluidstate = context.getWorld().getFluidState(context.getPos());
return this.getDefaultState().with(WATERLOGGED, fluidstate.getFluid() == Fluids.WATER);
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing()).with(WATERLOGGED, fluidstate.getFluid() == Fluids.WATER);
}

@Override
Expand All @@ -131,8 +132,19 @@ public BlockState updatePostPlacement(@Nonnull BlockState state, @Nonnull Direct
return super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
}

@Override
public BlockState rotate(BlockState state, IWorld world, BlockPos pos, Rotation rot) {
return state.with(FACING, rot.rotate(state.get(FACING)));
}

@Override
@Nonnull
public BlockState mirror(@Nonnull BlockState state, Mirror mirror) {
return state.rotate(mirror.toRotation(state.get(FACING)));
}

@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> container) {
container.add(WATERLOGGED);
container.add(FACING, WATERLOGGED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public static void init() {
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event) {
RenderType cutout = RenderType.getCutout();
RenderType cutoutMipped = RenderType.getCutoutMipped();
RenderType translucent = RenderType.getTranslucent();
RenderTypeLookup.setRenderLayer(AtumBlocks.ANPUTS_FINGERS, cutout);
RenderTypeLookup.setRenderLayer(AtumBlocks.OASIS_GRASS, cutout);
Expand Down Expand Up @@ -250,6 +251,7 @@ public static void registerModels(ModelRegistryEvent event) {
RenderTypeLookup.setRenderLayer(AtumBlocks.LANTERN_OF_SETH, cutout);
RenderTypeLookup.setRenderLayer(AtumBlocks.LANTERN_OF_SHU, cutout);
RenderTypeLookup.setRenderLayer(AtumBlocks.LANTERN_OF_TEFNUT, cutout);
RenderTypeLookup.setRenderLayer(AtumBlocks.NEBU_CHAIN, cutoutMipped);

ClientRegistry.bindTileEntityRenderer(AtumTileEntities.LIMESTONE_CHEST, TileChestRender::new);
ClientRegistry.bindTileEntityRenderer(AtumTileEntities.SARCOPHAGUS, SarcophagusRender::new);
Expand Down
27 changes: 21 additions & 6 deletions src/main/java/com/teammetallurgy/atum/client/RenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.Entity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
Expand All @@ -21,16 +22,18 @@

public class RenderUtils {

public static void renderItem(TileEntity tileEntity, @Nonnull ItemStack stack, float rotation, double yOffset, boolean drawStackSize, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
renderItem(tileEntity, stack, Vector3f.YP.rotationDegrees(rotation), yOffset, drawStackSize, matrixStack, buffer, combinedLight, combinedOverlay);
public static void renderItem(TileEntity tileEntity, @Nonnull ItemStack stack, float rotation, double yOffset, boolean drawStackSize, boolean rotateEastWest, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
renderItem(tileEntity, stack, Vector3f.YP.rotationDegrees(rotation), yOffset, drawStackSize, rotateEastWest, matrixStack, buffer, combinedLight, combinedOverlay);
}

public static void renderItem(TileEntity tileEntity, @Nonnull ItemStack stack, Quaternion rotation, double yOffset, boolean drawStackSize, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
public static void renderItem(TileEntity tileEntity, @Nonnull ItemStack stack, Quaternion rotation, double yOffset, boolean drawStackSize, boolean rotateEastWest, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
if (!stack.isEmpty()) {
matrixStack.push();
matrixStack.translate(0.5F, yOffset + 1.225F, 0.5F);

matrixStack.rotate(rotation);
if (!(stack.getItem() instanceof BlockItem)) {
matrixStack.rotate(rotation);
}

if (stack.getItem().isShield(stack, null)) {
matrixStack.rotate(Vector3f.YP.rotationDegrees(180));
Expand All @@ -39,8 +42,20 @@ public static void renderItem(TileEntity tileEntity, @Nonnull ItemStack stack, Q
BlockState state = tileEntity.getBlockState();
if (state.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) {
Direction facing = state.get(BlockStateProperties.HORIZONTAL_FACING);
if (facing == Direction.EAST || facing == Direction.WEST) {
matrixStack.rotate(Vector3f.YP.rotationDegrees(90.0F));
if (rotateEastWest) {
if (facing == Direction.EAST || facing == Direction.WEST) {
matrixStack.rotate(Vector3f.YP.rotationDegrees(90.0F));
}
} else {
if (facing == Direction.EAST) {
matrixStack.rotate(Vector3f.YP.rotationDegrees(90.0F));
}
if (facing == Direction.WEST) {
matrixStack.rotate(Vector3f.YP.rotationDegrees(-90.0F));
}
if (facing == Direction.NORTH) {
matrixStack.rotate(Vector3f.YP.rotationDegrees(180.0F));
}
}
}
matrixStack.scale(0.25F, 0.25F, 0.25F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void render(@Nonnull CurioDisplayTileEntity tileEntity, float partialTick

ItemStack stack = tileEntity.getStackInSlot(0);
if (!stack.isEmpty()) {
RenderUtils.renderItem(tileEntity, stack, Minecraft.getInstance().getRenderManager().getCameraOrientation(), -0.5D, false, matrixStack, buffer, combinedLight, combinedOverlay);
RenderUtils.renderItem(tileEntity, stack, Minecraft.getInstance().getRenderManager().getCameraOrientation(), -0.5D, false, false, matrixStack, buffer, combinedLight, combinedOverlay);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void render(@Nonnull QuernTileEntity quern, float partialTicks, @Nonnull

ItemStack stack = quern.getStackInSlot(0);
if (!stack.isEmpty()) {
RenderUtils.renderItem(quern, stack, quernRotation, -0.7D, true, matrixStack, buffer, combinedLight, combinedOverlay);
RenderUtils.renderItem(quern, stack, quernRotation, -0.7D, true, true, matrixStack, buffer, combinedLight, combinedOverlay);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/teammetallurgy/atum/init/AtumBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public class AtumBlocks {
public static final Block LANTERN_OF_SETH = registerBlock(new AtumLanternBlock(), "lantern_of_seth");
public static final Block LANTERN_OF_SHU = registerBlock(new AtumLanternBlock(), "lantern_of_shu");
public static final Block LANTERN_OF_TEFNUT = registerBlock(new AtumLanternBlock(), "lantern_of_tefnut");
public static final Block NEBU_CHAIN = registerBlock(new ChainBlock(AbstractBlock.Properties.create(Material.IRON, MaterialColor.AIR).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.CHAIN).notSolid()), "nebu_chain");
public static final Block MARL = registerBlock(new Block(create(Material.CLAY).hardnessAndResistance(0.6F).sound(SoundType.GROUND).harvestTool(ToolType.SHOVEL).harvestLevel(0)), "marl");
public static final Block RA_STONE = registerBlock(new RaStoneBlock(), null, "ra_stone");
public static final Block LIMESTONE = registerBlock(new LimestoneBlock(), "limestone");
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/assets/atum/blockstates/curio_display.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"variants": {
"": {
"model": "atum:block/curio_display"
}
"facing=north": { "model": "atum:block/curio_display", "y": 180 },
"facing=south": { "model": "atum:block/curio_display" },
"facing=west": { "model": "atum:block/curio_display", "y": 90 },
"facing=east": { "model": "atum:block/curio_display", "y": -90 }
}
}
16 changes: 16 additions & 0 deletions src/main/resources/assets/atum/blockstates/nebu_chain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"variants": {
"axis=x": {
"model": "atum:block/nebu_chain",
"x": 90,
"y": 90
},
"axis=y": {
"model": "atum:block/nebu_chain"
},
"axis=z": {
"model": "atum:block/nebu_chain",
"x": 90
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/atum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@
"block.atum.lantern_of_seth": "Lantern of Seth",
"block.atum.lantern_of_shu": "Lantern of Shu",
"block.atum.lantern_of_tefnut": "Lantern of Tefnut",
"block.atum.nebu_chain": "Nebu Chain",
"block.atum.palm_slab": "Palm Wood Slab",
"block.atum.deadwood_slab": "Deadwood Slab",
"block.atum.palm_stairs": "Palm Stairs",
Expand Down
29 changes: 29 additions & 0 deletions src/main/resources/assets/atum/models/block/nebu_chain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parent": "block/block",
"textures": {
"particle": "atum:block/nebu_chain",
"all": "atum:block/nebu_chain"
},
"elements": [
{
"from": [ 6.5, 0, 8 ],
"to": [ 9.5, 16, 8 ],
"rotation": { "origin": [ 8, 8, 8 ], "axis": "y", "angle": 45},
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 3, 16 ], "texture": "#all" },
"south": { "uv": [ 0, 0, 3, 16 ], "texture": "#all" }
}
},
{
"from": [ 8, 0, 6.5 ],
"to": [ 8, 16, 9.5 ],
"rotation": { "origin": [ 8, 8, 8 ], "axis": "y", "angle": 45},
"shade": false,
"faces": {
"west": { "uv": [ 3, 0, 6, 16 ], "texture": "#all" },
"east": { "uv": [ 3, 0, 6, 16 ], "texture": "#all" }
}
}
]
}
6 changes: 6 additions & 0 deletions src/main/resources/assets/atum/models/item/nebu_chain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "atum:item/nebu_chain"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/main/resources/data/atum/loot_tables/blocks/nebu_chain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "atum:nebu_chain"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
19 changes: 19 additions & 0 deletions src/main/resources/data/atum/recipes/nebu_chain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"N",
"I",
"N"
],
"key": {
"I": {
"tag": "forge:ingots/nebu"
},
"N": {
"tag": "forge:nuggets/nebu"
}
},
"result": {
"item": "atum:nebu_chain"
}
}

0 comments on commit 294d8ef

Please sign in to comment.