mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-27 23:45:57 +00:00
Even more blocks
This commit is contained in:
1 parent
70c5e51df4
commit
3227e1b591
17 files changed
+253
-528
No files matched your search
@@ -11,8 +11,6 @@
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -25,14 +23,15 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.state.BotaniaStateProps;
|
||||
import vazkii.botania.common.block.tile.TileLightRelay;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -40,19 +39,17 @@ import java.util.List;
|
||||
|
||||
public class BlockLightLauncher extends BlockMod implements ILexiconable {
|
||||
|
||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 0.25, 1);
|
||||
private static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 4, 16);
|
||||
|
||||
public BlockLightLauncher() {
|
||||
super(Material.WOOD, LibBlockNames.LIGHT_LAUNCHER);
|
||||
setHardness(2.0F);
|
||||
setSoundType(SoundType.WOOD);
|
||||
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.POWERED, false));
|
||||
public BlockLightLauncher(Builder builder) {
|
||||
super(builder);
|
||||
setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.POWERED, false));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return AABB;
|
||||
public VoxelShape getShape(IBlockState state, IBlockReader world, BlockPos pos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -61,47 +58,26 @@ public class BlockLightLauncher extends BlockMod implements ILexiconable {
|
||||
return new BlockStateContainer(this, BotaniaStateProps.POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(BotaniaStateProps.POWERED) ? 8 : 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(BotaniaStateProps.POWERED, meta == 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassable(IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
|
||||
boolean power = world.getRedstonePowerFromNeighbors(pos) > 0|| world.getRedstonePowerFromNeighbors(pos.up()) > 0;
|
||||
boolean powered = state.getValue(BotaniaStateProps.POWERED);
|
||||
boolean powered = state.get(BotaniaStateProps.POWERED);
|
||||
|
||||
if(power && !powered) {
|
||||
pickUpEntities(world, pos);
|
||||
world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, true), 4);
|
||||
world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4);
|
||||
} else if(!power && powered)
|
||||
world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 4);
|
||||
world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4);
|
||||
}
|
||||
|
||||
private void pickUpEntities(World world, BlockPos pos) {
|
||||
List<TileLightRelay> relays = new ArrayList<>();
|
||||
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
|
||||
for(EnumFacing dir : EnumFacing.BY_INDEX) {
|
||||
TileEntity tile = world.getTileEntity(pos.offset(dir));
|
||||
if(tile instanceof TileLightRelay) {
|
||||
TileLightRelay relay = (TileLightRelay) tile;
|
||||
@@ -131,7 +107,7 @@ public class BlockLightLauncher extends BlockMod implements ILexiconable {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) {
|
||||
public BlockFaceShape getBlockFaceShape(IBlockReader world, IBlockState state, BlockPos pos, EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user