Skip to content

Commit

Permalink
Stackable panes (like slabs)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdujovic17 committed Mar 6, 2021
1 parent cf3ecdf commit 5234d41
Show file tree
Hide file tree
Showing 87 changed files with 938 additions and 110 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'idea'
apply plugin: 'maven-publish'

version = '1.0.4'
group = 'com.codenamerevy.horizontalpanes'
archivesBaseName = 'horizontalpanes'
version = project.mod_version
group = project.maven_group
archivesBaseName = "[" + project.minecraft_version + "]" + "-" + project.archive_base_name

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = project.eclipse_java_version // Need this here so eclipse task generates correctly.

minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: '20201028-1.16.3'
mappings channel: project.mappings_channel, version: project.mappings_version
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
Expand Down Expand Up @@ -89,7 +89,7 @@ dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.16.4-35.1.13'
minecraft project.forge_version

// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
Expand Down
14 changes: 13 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.daemon=false

# Forge props
minecraft_version = 1.16.5
mappings_version = 20201028-1.16.3
mappings_channel = snapshot
forge_version = net.minecraftforge:forge:1.16.5-36.0.46
eclipse_java_version = 1.8

# Additional Bars props
mod_version = 1.1.0
maven_group = com.codenamerevy.horizontalpanes
archive_base_name = horizontalpanes
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.minecraft.world.IWorld;
import net.minecraftforge.common.ToolType;

@SuppressWarnings("deprecation")
@Deprecated
public class HorizontalPaneBlock extends GlassBlock implements IWaterLoggable
{
//Values for Voxel shape of a block. Doesn't have to be like this, but for readability I've put it like this.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.codenamerevy.horizontalpanes.content.blocks;

import net.minecraft.block.*;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.SlabType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;

import javax.annotation.Nullable;

public class HorizontalPaneSlab extends SlabBlock implements IWaterLoggable {

public static final EnumProperty<SlabType> TYPE = BlockStateProperties.SLAB_TYPE;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;

protected static final VoxelShape SHAPE_BOT = Block.makeCuboidShape(0.0F, 6.0F, 0.0F, 16.0F, 8.0F, 16.0F); //This is a bottom shape.
protected static final VoxelShape SHAPE_TOP = Block.makeCuboidShape(0.0F, 6.0F + 8.0F, 0.0F, 16.0F, 8.0F + 8.0F, 16.0F); //This is a top shape.
protected static final VoxelShape SHAPE_COM = VoxelShapes.or(SHAPE_BOT, SHAPE_TOP); //This is a combined shape

public HorizontalPaneSlab(Properties properties) {
super(properties.notSolid().hardnessAndResistance(0.3F, 0.3F).sound(SoundType.GLASS));
this.setDefaultState(this.getDefaultState().with(TYPE, SlabType.BOTTOM).with(WATERLOGGED, false));
}

@Override
public boolean isTransparent(BlockState state) {
return true;
}

@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
SlabType slabType = state.get(TYPE);
switch(slabType) {
case DOUBLE:
return SHAPE_COM;
case TOP:
return SHAPE_TOP;
default:
return SHAPE_BOT;
}
}

@Override
public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) {
if (adjacentBlockState.getBlock() == Blocks.GLASS) return true;
if (adjacentBlockState.getBlock() == this) if (slabSideInvisible(state, adjacentBlockState, side)) return true;

return super.isSideInvisible(state, adjacentBlockState, side);
}
private boolean slabSideInvisible(BlockState slabState, BlockState neighbourState, Direction dir)
{
SlabType slabType = slabState.get(TYPE);
SlabType neighbourType = neighbourState.get(TYPE);

if (neighbourType == SlabType.DOUBLE) return true;

switch (dir)
{
case NORTH: case SOUTH: case EAST: case WEST:
if(slabType == neighbourType) return true;
default:
break;
}

return false;
}

@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
BlockPos blockPos = ctx.getPos();
BlockState blockState = ctx.getWorld().getBlockState(blockPos);
FluidState fluidState = ctx.getWorld().getFluidState(blockPos);
if (blockState.isIn(this)) {
return blockState.with(TYPE, SlabType.DOUBLE).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
} else {
BlockState blockState2 = this.getDefaultState().with(TYPE, SlabType.BOTTOM).with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
Direction direction = ctx.getFace();
return direction != Direction.DOWN && (direction == Direction.UP || !(ctx.getHitVec().y - (double)blockPos.getY() > 0.5D)) ? blockState2 : blockState2.with(TYPE, SlabType.TOP);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ public class ModBlocks
//Deferred Registry for Blocks
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, HorizontalPanes.MODID);

public static final RegistryObject<Block> HORIZONTAL_PANE = BLOCKS.register("horizontal_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS)));
public static final RegistryObject<Block> HORIZONTAL_PANE = BLOCKS.register("horizontal_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS)));

public static final RegistryObject<Block> GLASS_PANE = BLOCKS.register("horizontal_glass_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS)));
public static final RegistryObject<Block> GLASS_PANE = BLOCKS.register("horizontal_glass_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS)));

public static final RegistryObject<Block> WHITE_STAINED_PANE = BLOCKS.register("horizontal_stained_white_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.SNOW)));
public static final RegistryObject<Block> RED_STAINED_PANE = BLOCKS.register("horizontal_stained_red_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.RED)));
public static final RegistryObject<Block> ORANGE_STAINED_PANE = BLOCKS.register("horizontal_stained_orange_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.ADOBE)));
public static final RegistryObject<Block> PINK_STAINED_PANE = BLOCKS.register("horizontal_stained_pink_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.PINK)));
public static final RegistryObject<Block> YELLOW_STAINED_PANE = BLOCKS.register("horizontal_stained_yellow_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.YELLOW)));
public static final RegistryObject<Block> LIME_STAINED_PANE = BLOCKS.register("horizontal_stained_lime_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.LIME)));
public static final RegistryObject<Block> GREEN_STAINED_PANE = BLOCKS.register("horizontal_stained_green_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.GREEN)));
public static final RegistryObject<Block> LIGHT_BLUE_STAINED_PANE = BLOCKS.register("horizontal_stained_light_blue_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.LIGHT_BLUE)));
public static final RegistryObject<Block> CYAN_STAINED_PANE = BLOCKS.register("horizontal_stained_cyan_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.CYAN)));
public static final RegistryObject<Block> BLUE_STAINED_PANE = BLOCKS.register("horizontal_stained_blue_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.BLUE)));
public static final RegistryObject<Block> MAGENTA_STAINED_PANE = BLOCKS.register("horizontal_stained_magenta_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.MAGENTA)));
public static final RegistryObject<Block> PURPLE_STAINED_PANE = BLOCKS.register("horizontal_stained_purple_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.PURPLE)));
public static final RegistryObject<Block> BROWN_STAINED_PANE = BLOCKS.register("horizontal_stained_brown_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.BROWN)));
public static final RegistryObject<Block> GRAY_STAINED_PANE = BLOCKS.register("horizontal_stained_gray_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.GRAY)));
public static final RegistryObject<Block> LIGHT_GRAY_STAINED_PANE = BLOCKS.register("horizontal_stained_light_gray_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.LIGHT_GRAY)));
public static final RegistryObject<Block> BLACK_STAINED_PANE = BLOCKS.register("horizontal_stained_black_pane", () -> new HorizontalPaneBlock(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.BLACK)));
public static final RegistryObject<Block> WHITE_STAINED_PANE = BLOCKS.register("horizontal_stained_white_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.SNOW)));
public static final RegistryObject<Block> RED_STAINED_PANE = BLOCKS.register("horizontal_stained_red_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.RED)));
public static final RegistryObject<Block> ORANGE_STAINED_PANE = BLOCKS.register("horizontal_stained_orange_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.ADOBE)));
public static final RegistryObject<Block> PINK_STAINED_PANE = BLOCKS.register("horizontal_stained_pink_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.PINK)));
public static final RegistryObject<Block> YELLOW_STAINED_PANE = BLOCKS.register("horizontal_stained_yellow_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.YELLOW)));
public static final RegistryObject<Block> LIME_STAINED_PANE = BLOCKS.register("horizontal_stained_lime_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.LIME)));
public static final RegistryObject<Block> GREEN_STAINED_PANE = BLOCKS.register("horizontal_stained_green_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.GREEN)));
public static final RegistryObject<Block> LIGHT_BLUE_STAINED_PANE = BLOCKS.register("horizontal_stained_light_blue_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.LIGHT_BLUE)));
public static final RegistryObject<Block> CYAN_STAINED_PANE = BLOCKS.register("horizontal_stained_cyan_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.CYAN)));
public static final RegistryObject<Block> BLUE_STAINED_PANE = BLOCKS.register("horizontal_stained_blue_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.BLUE)));
public static final RegistryObject<Block> MAGENTA_STAINED_PANE = BLOCKS.register("horizontal_stained_magenta_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.MAGENTA)));
public static final RegistryObject<Block> PURPLE_STAINED_PANE = BLOCKS.register("horizontal_stained_purple_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.PURPLE)));
public static final RegistryObject<Block> BROWN_STAINED_PANE = BLOCKS.register("horizontal_stained_brown_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.BROWN)));
public static final RegistryObject<Block> GRAY_STAINED_PANE = BLOCKS.register("horizontal_stained_gray_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.GRAY)));
public static final RegistryObject<Block> LIGHT_GRAY_STAINED_PANE = BLOCKS.register("horizontal_stained_light_gray_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.LIGHT_GRAY)));
public static final RegistryObject<Block> BLACK_STAINED_PANE = BLOCKS.register("horizontal_stained_black_pane", () -> new HorizontalPaneSlab(AbstractBlock.Properties.create(Material.GLASS, MaterialColor.BLACK)));

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class ModItems
//Deferred Registry for Items
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, HorizontalPanes.MODID);

public static final RegistryObject<Item> HORIZONTAL_PANE = ITEMS.register("horizontal_pane", () -> new BlockItem(ModBlocks.HORIZONTAL_PANE.get(), new Item.Properties()));
//public static final RegistryObject<Item> HORIZONTAL_PANE = ITEMS.register("horizontal_pane", () -> new BlockItem(ModBlocks.HORIZONTAL_PANE.get(), new Item.Properties()));

public static final RegistryObject<Item> GLASS_PANE = ITEMS.register("horizontal_glass_pane", () -> new BlockItem(ModBlocks.HORIZONTAL_PANE.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
public static final RegistryObject<Item> GLASS_PANE = ITEMS.register("horizontal_glass_pane", () -> new BlockItem(ModBlocks.GLASS_PANE.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));

public static final RegistryObject<Item> WHITE_STAINED_PANE = ITEMS.register("horizontal_stained_white_pane", () -> new BlockItem(ModBlocks.WHITE_STAINED_PANE.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
public static final RegistryObject<Item> RED_STAINED_PANE = ITEMS.register("horizontal_stained_red_pane", () -> new BlockItem(ModBlocks.RED_STAINED_PANE.get(), new Item.Properties().group(ItemGroup.DECORATIONS)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"variants": {
"": {
"type=bottom": {
"model": "horizontalpanes:block/horizontal_glass_pane"
},
"type=double": {
"model": "horizontalpanes:block/horizontal_glass_pane_combined"
},
"type=top": {
"model": "horizontalpanes:block/horizontal_glass_pane_top"
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"variants": {
"": {
"type=bottom": {
"model": "horizontalpanes:block/horizontal_stained_black_pane"
},
"type=double": {
"model": "horizontalpanes:block/horizontal_stained_black_pane_combined"
},
"type=top": {
"model": "horizontalpanes:block/horizontal_stained_black_pane_top"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"variants": {
"": {
"type=bottom": {
"model": "horizontalpanes:block/horizontal_stained_blue_pane"
},
"type=double": {
"model": "horizontalpanes:block/horizontal_stained_blue_pane_combined"
},
"type=top": {
"model": "horizontalpanes:block/horizontal_stained_blue_pane_top"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"variants": {
"": {
"type=bottom": {
"model": "horizontalpanes:block/horizontal_stained_brown_pane"
},
"type=double": {
"model": "horizontalpanes:block/horizontal_stained_brown_pane_combined"
},
"type=top": {
"model": "horizontalpanes:block/horizontal_stained_brown_pane_top"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"variants": {
"": {
"type=bottom": {
"model": "horizontalpanes:block/horizontal_stained_cyan_pane"
},
"type=double": {
"model": "horizontalpanes:block/horizontal_stained_cyan_pane_combined"
},
"type=top": {
"model": "horizontalpanes:block/horizontal_stained_cyan_pane_top"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"variants": {
"": {
"type=bottom": {
"model": "horizontalpanes:block/horizontal_stained_gray_pane"
},
"type=double": {
"model": "horizontalpanes:block/horizontal_stained_gray_pane_combined"
},
"type=top": {
"model": "horizontalpanes:block/horizontal_stained_gray_pane_top"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"variants": {
"": {
"type=bottom": {
"model": "horizontalpanes:block/horizontal_stained_green_pane"
},
"type=double": {
"model": "horizontalpanes:block/horizontal_stained_green_pane_combined"
},
"type=top": {
"model": "horizontalpanes:block/horizontal_stained_green_pane_top"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"variants": {
"": {
"type=bottom": {
"model": "horizontalpanes:block/horizontal_stained_light_blue_pane"
},
"type=double": {
"model": "horizontalpanes:block/horizontal_stained_light_blue_pane_combined"
},
"type=top": {
"model": "horizontalpanes:block/horizontal_stained_light_blue_pane_top"
}
}
}
Loading

0 comments on commit 5234d41

Please sign in to comment.