-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Placable metal sheets. Rendering / blockstates / registry is done, ne…
…ed to fix bounding boxes, etc.
- Loading branch information
1 parent
137f8e2
commit fbacd3c
Showing
8 changed files
with
206 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/main/java/net/dries007/tfc/objects/blocks/metal/BlockSheet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Work under Copyright. Licensed under the EUPL. | ||
* See the project README.md and LICENSE.txt for more information. | ||
* | ||
*/ | ||
|
||
package net.dries007.tfc.objects.blocks.metal; | ||
|
||
import java.util.EnumMap; | ||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.properties.PropertyDirection; | ||
import net.minecraft.block.state.BlockStateContainer; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.math.AxisAlignedBB; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.IBlockAccess; | ||
|
||
import mcp.MethodsReturnNonnullByDefault; | ||
import net.dries007.tfc.objects.Metal; | ||
|
||
@MethodsReturnNonnullByDefault | ||
@ParametersAreNonnullByDefault | ||
public class BlockSheet extends Block | ||
{ | ||
public static final PropertyDirection FACE = PropertyDirection.create("face"); | ||
private static final EnumMap<Metal, BlockSheet> MAP = new EnumMap<>(Metal.class); | ||
|
||
public static BlockSheet get(Metal metal) | ||
{ | ||
return MAP.get(metal); | ||
} | ||
|
||
public static ItemStack get(Metal metal, int amount) | ||
{ | ||
return new ItemStack(MAP.get(metal), amount); | ||
} | ||
|
||
public final Metal metal; | ||
|
||
public BlockSheet(Metal metal) | ||
{ | ||
super(Material.IRON); | ||
|
||
this.metal = metal; | ||
if (MAP.put(metal, this) != null) throw new IllegalStateException("There can only be one."); | ||
|
||
this.setDefaultState(blockState.getBaseState().withProperty(FACE, EnumFacing.NORTH)); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("deprecation") | ||
public IBlockState getStateFromMeta(int meta) | ||
{ | ||
return this.getDefaultState().withProperty(FACE, EnumFacing.getFront(meta)); | ||
} | ||
|
||
@Override | ||
public int getMetaFromState(IBlockState state) | ||
{ | ||
return state.getValue(FACE).getIndex(); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@Override | ||
public boolean isFullCube(IBlockState state) | ||
{ | ||
return false; | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@Override | ||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) | ||
{ | ||
return FULL_BLOCK_AABB; // todo: proper bounding box | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@Override | ||
public boolean isOpaqueCube(IBlockState state) | ||
{ | ||
return false; | ||
} | ||
|
||
@Override | ||
protected BlockStateContainer createBlockState() | ||
{ | ||
return new BlockStateContainer(this, FACE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"credit": "Made with Blockbench", | ||
"elements": [ | ||
{ | ||
"from": [ | ||
0, | ||
0, | ||
0 | ||
], | ||
"to": [ | ||
16, | ||
1, | ||
16 | ||
], | ||
"faces": { | ||
"north": { | ||
"uv": [ | ||
0, | ||
0, | ||
16, | ||
1 | ||
], | ||
"texture": "#all" | ||
}, | ||
"east": { | ||
"uv": [ | ||
0, | ||
0, | ||
16, | ||
1 | ||
], | ||
"texture": "#all" | ||
}, | ||
"south": { | ||
"uv": [ | ||
0, | ||
0, | ||
16, | ||
1 | ||
], | ||
"texture": "#all" | ||
}, | ||
"west": { | ||
"uv": [ | ||
0, | ||
0, | ||
16, | ||
1 | ||
], | ||
"texture": "#all" | ||
}, | ||
"up": { | ||
"uv": [ | ||
0, | ||
0, | ||
16, | ||
16 | ||
], | ||
"texture": "#all" | ||
} | ||
} | ||
} | ||
] | ||
} |