feat: force stairs
This commit is contained in:
parent
fa6ad449f0
commit
034d0e5852
|
@ -26,15 +26,16 @@ import net.minecraft.util.Vec3;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockForceBrick extends Block implements ICustomItemBlockProvider {
|
||||
public IIcon[] icons;
|
||||
public class BlockForceBrick extends Block {
|
||||
int type;
|
||||
|
||||
public BlockForceBrick() {
|
||||
public BlockForceBrick(int type) {
|
||||
super(Material.rock);
|
||||
Util.configureBlock(this, "forcebrick");
|
||||
Util.configureBlock(this, "forcebrick" + type);
|
||||
this.setHardness(2.0F);
|
||||
this.setResistance(2000.0F);
|
||||
this.setStepSound(Block.soundTypeStone);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,25 +44,6 @@ public class BlockForceBrick extends Block implements ICustomItemBlockProvider {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return meta >= 0 && meta < 16 ? this.icons[meta] : this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void getSubBlocks(Item par1, CreativeTabs tab, List list) {
|
||||
IntStream.range(0, 16)
|
||||
.mapToObj(i -> new ItemStack(this, 1, i))
|
||||
.forEach(list::add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void
|
||||
onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
|
@ -104,15 +86,13 @@ public class BlockForceBrick extends Block implements ICustomItemBlockProvider {
|
|||
public boolean addDestroyEffects(
|
||||
World world, int x, int y, int z, int meta, EffectRenderer renderer
|
||||
) {
|
||||
int color = world.getBlockMetadata(x, y, z);
|
||||
System.out.println("ALEC: " + color + " " + Integer.toHexString(DartUtils.getMcColor(color)));
|
||||
FXUtils.makeShiny(
|
||||
world,
|
||||
(double) x,
|
||||
(double) y,
|
||||
(double) z,
|
||||
2,
|
||||
DartUtils.getMcColor(color),
|
||||
DartUtils.getMcColor(this.type),
|
||||
32,
|
||||
true
|
||||
);
|
||||
|
@ -121,17 +101,15 @@ public class BlockForceBrick extends Block implements ICustomItemBlockProvider {
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addHitEffects(
|
||||
World world, MovingObjectPosition target, EffectRenderer renderer
|
||||
) {
|
||||
int color = world.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
|
||||
public boolean
|
||||
addHitEffects(World world, MovingObjectPosition target, EffectRenderer renderer) {
|
||||
FXUtils.makeShiny(
|
||||
world,
|
||||
(double) target.blockX,
|
||||
(double) target.blockY,
|
||||
(double) target.blockZ,
|
||||
2,
|
||||
DartUtils.getMcColor(color),
|
||||
DartUtils.getMcColor(this.type),
|
||||
4,
|
||||
true
|
||||
);
|
||||
|
@ -141,25 +119,6 @@ public class BlockForceBrick extends Block implements ICustomItemBlockProvider {
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reggie) {
|
||||
this.icons = IntStream.range(0, 16)
|
||||
.mapToObj(i -> "dartcraft:brick" + i)
|
||||
.map(reggie::registerIcon)
|
||||
.toArray(IIcon[] ::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends ItemBlock> getItemBlockClass() {
|
||||
return BlockItem.class;
|
||||
}
|
||||
|
||||
public static class BlockItem extends AbstractItemBlockMetadata {
|
||||
public BlockItem(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "forcebrick";
|
||||
}
|
||||
this.blockIcon = reggie.registerIcon("dartcraft:brick" + this.type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,34 @@
|
|||
package ley.modding.dartcraft.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ley.modding.dartcraft.Dartcraft;
|
||||
import ley.modding.dartcraft.item.AbstractItemBlockMetadata;
|
||||
import ley.modding.dartcraft.tile.TileEntityStairs;
|
||||
import ley.modding.dartcraft.util.DartUtils;
|
||||
import ley.modding.dartcraft.util.FXUtils;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import ley.modding.tileralib.api.ICustomItemBlockProvider;
|
||||
import ley.modding.tileralib.api.ITEProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockForceSlab
|
||||
extends BlockSlab implements ITEProvider, ICustomItemBlockProvider {
|
||||
public BlockForceSlab() {
|
||||
public class BlockForceSlab extends BlockSlab {
|
||||
int type;
|
||||
|
||||
public BlockForceSlab(int type) {
|
||||
super(false, Material.rock);
|
||||
Util.configureBlock(this, "forceslab");
|
||||
Util.configureBlock(this, "forceslab" + type);
|
||||
this.setHardness(2.0F);
|
||||
this.setResistance(2000.0F);
|
||||
this.setStepSound(Block.soundTypeStone);
|
||||
this.setLightOpacity(0);
|
||||
// TODO: WTF
|
||||
//Block.useNeighborBrightness[id] = true;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
// TODO: WTF
|
||||
|
@ -50,27 +37,6 @@ public class BlockForceSlab
|
|||
// return "forceSlab";
|
||||
//}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(
|
||||
MovingObjectPosition arg0,
|
||||
World arg1,
|
||||
int arg2,
|
||||
int arg3,
|
||||
int arg4,
|
||||
EntityPlayer arg5
|
||||
) {
|
||||
return new ItemStack(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void getSubBlocks(Item id, CreativeTabs tab, List list) {
|
||||
IntStream.range(0, 17)
|
||||
.mapToObj(i -> new ItemStack(this, 1, i))
|
||||
.forEach(list::add);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(
|
||||
|
@ -88,176 +54,55 @@ public class BlockForceSlab
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int meta) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int meta) {
|
||||
return new TileEntityStairs();
|
||||
}
|
||||
|
||||
public static TileEntityStairs getStairTile(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
return tile != null && tile instanceof TileEntityStairs ? (TileEntityStairs) tile
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean
|
||||
removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean alec) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (Dartcraft.proxy.isSimulating(world) && this.canHarvestBlock(player, meta)
|
||||
&& !player.capabilities.isCreativeMode) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityStairs) {
|
||||
TileEntityStairs stairs = (TileEntityStairs) tile;
|
||||
ItemStack stack = new ItemStack(this, 1, stairs.color);
|
||||
DartUtils.dropItem(stack, world, (double) x, (double) y, (double) z);
|
||||
}
|
||||
}
|
||||
|
||||
return world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack>
|
||||
getDrops(World alec1, int alec2, int alec3, int alec4, int alec5, int alec6) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int par5,
|
||||
float par6,
|
||||
float par7,
|
||||
float par8,
|
||||
int par9
|
||||
) {
|
||||
TileEntityStairs stairs = getStairTile(world, x, y, z);
|
||||
if (stairs != null) {
|
||||
stairs.color = world.getBlockMetadata(x, y, z);
|
||||
stairs.markDirty();
|
||||
}
|
||||
|
||||
return par5 != 0 && (par5 == 1 || (double) par7 <= 0.5D) ? 0 : 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(
|
||||
World par1World,
|
||||
int par2,
|
||||
int par3,
|
||||
int par4,
|
||||
EntityLivingBase entity,
|
||||
ItemStack stack
|
||||
) {
|
||||
TileEntityStairs stairs = getStairTile(par1World, par2, par3, par4);
|
||||
if (stack != null && stairs != null) {
|
||||
stairs.color = stack.getItemDamage();
|
||||
stairs.markDirty();
|
||||
}
|
||||
|
||||
super.onBlockPlacedBy(par1World, par2, par3, par4, entity, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int alec, int meta) {
|
||||
return meta == 16 ? DartBlocks.forceplanks.getIcon(0, 0)
|
||||
: ((BlockForceBrick) DartBlocks.forcebrick).icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
TileEntityStairs stairs = getStairTile(world, x, y, z);
|
||||
if (stairs != null && stairs.color >= 0) {
|
||||
if (stairs.color < 16) {
|
||||
return ((BlockForceBrick) DartBlocks.forcebrick).icons[stairs.color];
|
||||
}
|
||||
|
||||
if (stairs.color == 16) {
|
||||
return DartBlocks.forceplanks.getIcon(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.blockIcon == null)
|
||||
this.blockIcon = (this.type == 16 ? DartBlocks.forceplanks
|
||||
: DartBlocks.forcebrick[this.type])
|
||||
.getIcon(0, 0);
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister arg0) {}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addDestroyEffects(
|
||||
World world, int x, int y, int z, int meta, EffectRenderer renderer
|
||||
) {
|
||||
TileEntityStairs stairs = getStairTile(world, x, y, z);
|
||||
if (stairs != null) {
|
||||
FXUtils.makeShiny(
|
||||
world,
|
||||
(double) x,
|
||||
(double) y,
|
||||
(double) z,
|
||||
2,
|
||||
DartUtils.getMcColor(stairs.color),
|
||||
32,
|
||||
true
|
||||
);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
FXUtils.makeShiny(
|
||||
world,
|
||||
(double) x,
|
||||
(double) y,
|
||||
(double) z,
|
||||
2,
|
||||
DartUtils.getMcColor(this.type),
|
||||
32,
|
||||
true
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addHitEffects(
|
||||
World world, MovingObjectPosition target, EffectRenderer renderer
|
||||
) {
|
||||
TileEntityStairs stairs
|
||||
= getStairTile(world, target.blockX, target.blockY, target.blockZ);
|
||||
if (stairs != null) {
|
||||
FXUtils.makeShiny(
|
||||
world,
|
||||
(double) target.blockX,
|
||||
(double) target.blockY,
|
||||
(double) target.blockZ,
|
||||
2,
|
||||
DartUtils.getMcColor(stairs.color),
|
||||
4,
|
||||
true
|
||||
);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> getTEClass() {
|
||||
return TileEntityStairs.class;
|
||||
public boolean
|
||||
addHitEffects(World world, MovingObjectPosition target, EffectRenderer renderer) {
|
||||
FXUtils.makeShiny(
|
||||
world,
|
||||
(double) target.blockX,
|
||||
(double) target.blockY,
|
||||
(double) target.blockZ,
|
||||
2,
|
||||
DartUtils.getMcColor(this.type),
|
||||
4,
|
||||
true
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150002_b(int arg0) {
|
||||
throw new UnsupportedOperationException("ALEC");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends ItemBlock> getItemBlockClass() {
|
||||
return BlockItem.class;
|
||||
}
|
||||
|
||||
public static class BlockItem extends AbstractItemBlockMetadata {
|
||||
public BlockItem(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "forceslab";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package ley.modding.dartcraft.block;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ley.modding.dartcraft.util.DartUtils;
|
||||
import ley.modding.dartcraft.util.FXUtils;
|
||||
import ley.modding.dartcraft.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockForceStairs extends BlockStairs {
|
||||
int type;
|
||||
|
||||
public BlockForceStairs(int type) {
|
||||
super(type == 16 ? DartBlocks.forceplanks : DartBlocks.forcebrick[type], 32);
|
||||
Util.configureBlock(this, "forcestairs" + type);
|
||||
this.setHardness(2.0F);
|
||||
this.setResistance(2000.0F);
|
||||
this.setStepSound(Block.soundTypeStone);
|
||||
this.setLightOpacity(0);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int alec, int meta) {
|
||||
if (this.blockIcon == null)
|
||||
this.blockIcon = (this.type == 16 ? DartBlocks.forceplanks
|
||||
: DartBlocks.forcebrick[this.type])
|
||||
.getIcon(0, 0);
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister p_registerBlockIcons_1_) {}
|
||||
|
||||
@Override
|
||||
public boolean canCreatureSpawn(
|
||||
EnumCreatureType arg0, IBlockAccess arg1, int arg2, int arg3, int arg4
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addDestroyEffects(
|
||||
World world, int x, int y, int z, int meta, EffectRenderer renderer
|
||||
) {
|
||||
FXUtils.makeShiny(
|
||||
world,
|
||||
(double) x,
|
||||
(double) y,
|
||||
(double) z,
|
||||
2,
|
||||
DartUtils.getMcColor(this.type),
|
||||
32,
|
||||
true
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean
|
||||
addHitEffects(World world, MovingObjectPosition target, EffectRenderer renderer) {
|
||||
FXUtils.makeShiny(
|
||||
world,
|
||||
(double) target.blockX,
|
||||
(double) target.blockY,
|
||||
(double) target.blockZ,
|
||||
2,
|
||||
DartUtils.getMcColor(this.type),
|
||||
4,
|
||||
true
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package ley.modding.dartcraft.block;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import ley.modding.tileralib.api.IRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
@ -7,12 +9,13 @@ import net.minecraftforge.fluids.FluidRegistry;
|
|||
|
||||
public class DartBlocks {
|
||||
public static Block engine;
|
||||
public static Block forcebrick;
|
||||
public static Block[] forcebrick;
|
||||
public static Block forceleaves;
|
||||
public static Block forcelog;
|
||||
public static Block forceplanks;
|
||||
public static Block forcesapling;
|
||||
public static Block forceslab;
|
||||
public static Block[] forceslab;
|
||||
public static Block[] forcestairs;
|
||||
public static Block liquidforce;
|
||||
public static Block powerore;
|
||||
|
||||
|
@ -24,12 +27,22 @@ public class DartBlocks {
|
|||
}
|
||||
|
||||
DartBlocks.engine = reg.registerBlock(new BlockForceEngine());
|
||||
DartBlocks.forcebrick = reg.registerBlock(new BlockForceBrick());
|
||||
DartBlocks.forcebrick = IntStream.range(0, 16)
|
||||
.mapToObj(BlockForceBrick::new)
|
||||
.map(reg::registerBlock)
|
||||
.toArray(Block[] ::new);
|
||||
DartBlocks.forceleaves = reg.registerBlock(new BlockForceLeaves());
|
||||
DartBlocks.forcelog = reg.registerBlock(new BlockForceLog());
|
||||
DartBlocks.forceplanks = reg.registerBlock(new BlockForcePlanks());
|
||||
DartBlocks.forcesapling = reg.registerBlock(new BlockForceSapling());
|
||||
DartBlocks.forceslab = reg.registerBlock(new BlockForceSlab());
|
||||
DartBlocks.forceslab = IntStream.range(0, 17)
|
||||
.mapToObj(BlockForceSlab::new)
|
||||
.map(reg::registerBlock)
|
||||
.toArray(Block[] ::new);
|
||||
DartBlocks.forcestairs = IntStream.range(0, 17)
|
||||
.mapToObj(BlockForceStairs::new)
|
||||
.map(reg::registerBlock)
|
||||
.toArray(Block[] ::new);
|
||||
DartBlocks.liquidforce = reg.registerBlock(new BlockLiquidForce());
|
||||
DartBlocks.powerore = reg.registerBlock(new BlockPowerOre());
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ public class DartUtils {
|
|||
Color.magenta.getRGB(),
|
||||
Color.orange.getRGB(),
|
||||
Color.white.getRGB(),
|
||||
Color.yellow.getRGB(),
|
||||
};
|
||||
|
||||
return color >= 0 && color < lookup.length ? lookup[color] : 0;
|
||||
|
|
|
@ -54,5 +54,22 @@ tile.forceslab13.name=Magenta Force Slab
|
|||
tile.forceslab14.name=Orange Force Slab
|
||||
tile.forceslab15.name=White Force Slab
|
||||
tile.forceslab16.name=Wooden Force Slab
|
||||
tile.forcestairs0.name=Black Force Stairs
|
||||
tile.forcestairs1.name=Red Force Stairs
|
||||
tile.forcestairs2.name=Green Force Stairs
|
||||
tile.forcestairs3.name=Brown Force Stairs
|
||||
tile.forcestairs4.name=Blue Force Stairs
|
||||
tile.forcestairs5.name=Purple Force Stairs
|
||||
tile.forcestairs6.name=Cyan Force Stairs
|
||||
tile.forcestairs7.name=Light Gray Force Stairs
|
||||
tile.forcestairs8.name=Gray Force Stairs
|
||||
tile.forcestairs9.name=Pink Force Stairs
|
||||
tile.forcestairs10.name=Lime Force Stairs
|
||||
tile.forcestairs11.name=Yellow Force Stairs
|
||||
tile.forcestairs12.name=Light Blue Force Stairs
|
||||
tile.forcestairs13.name=Magenta Force Stairs
|
||||
tile.forcestairs14.name=Orange Force Stairs
|
||||
tile.forcestairs15.name=White Force Stairs
|
||||
tile.forcestairs16.name=Wooden Force Stairs
|
||||
|
||||
itemGroup.dartcraft=Dartcraft
|
||||
|
|
Loading…
Reference in New Issue