piston bellows is working with animations needs sounds updated rendering for 3rd persion and gui

This commit is contained in:
Mohammad-Ali Minaie
2017-01-07 23:36:22 -05:00
parent 597cd056bc
commit 4f0b965f57
22 changed files with 576 additions and 258 deletions

View File

@@ -1,7 +1,8 @@
To-Dos
- [ ] Fix Firebox model to have more of a bowl shape and have the air inlet on the left
- [ ] Redo piston bellows if statements to match the new directional (should match the same directions)
- [x] Redo piston bellows if statements to match the new directional (should match the same directions)
- [ ] Fix PistonBellows Bounding Boxes to match the direction
- [ ] Crucible
- [ ] Model

View File

@@ -32,7 +32,8 @@ public class ModInfo {
//public static final String UPDATE_JSON = "";
public enum ForgecraftItems {
TEST("test", "ItemTest");
TEST("test", "ItemTest"),
BELLOWSHANDLE("bellowshandle", "bellowshandle");
private String unlocalizedName;
private String registryName;

View File

@@ -78,9 +78,6 @@ public class Firebox extends CustomContainerFacing implements ITileEntityProvide
return boundBox;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{

View File

@@ -19,10 +19,15 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.common.property.Properties;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.tiles.TileFirebox;
import nmd.primal.forgecraft.tiles.TilePistonBellows;
import javax.annotation.Nullable;
import java.util.Random;
@@ -30,9 +35,9 @@ import java.util.Random;
/**
* Created by mminaie on 1/1/17.
*/
public class PistonBellows extends CustomFacing {
public class PistonBellows extends CustomContainerFacing {
//public static final PropertyBool ACTIVE = PropertyBool.create("active");
public static final PropertyBool ACTIVE = PropertyBool.create("active");
//protected static final AxisAlignedBB collideBox = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.99D, 1.0D);
protected static final AxisAlignedBB boundBox = new AxisAlignedBB(0.1875D, 0.0D, 0.0D, 1.0D, 12 / 16D, 1.0D);
@@ -42,136 +47,142 @@ public class PistonBellows extends CustomFacing {
setUnlocalizedName(ModInfo.ForgecraftBlocks.PISTONBELLOWS.getUnlocalizedName());
setRegistryName(ModInfo.ForgecraftBlocks.PISTONBELLOWS.getRegistryName());
setCreativeTab(ModInfo.TAB_FORGECRAFT);
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, Boolean.valueOf(false)));
setHardness(3.0f);
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!world.isRemote){
//System.out.println(state.getValue(PistonBellows.FACING));
if(state.getValue(PistonBellows.FACING) == EnumFacing.NORTH){
BlockPos tempPos = new BlockPos(pos.getX()+1, pos.getY(), pos.getZ());
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.EAST)){
if(tile != null){
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
tile.setHeat(tile.getHeat() + 25);
tile.updateBlock();
tile.markDirty();
return true;
}
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.SOUTH){
BlockPos tempPos = new BlockPos(pos.getX()-1, pos.getY(), pos.getZ());
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.WEST)){
if(tile != null){
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
tile.setHeat(tile.getHeat() + 25);
tile.updateBlock();
tile.markDirty();
return true;
}
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.EAST){
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ()+1);
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.SOUTH)){
if(tile != null){
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
tile.setHeat(tile.getHeat() + 25);
tile.updateBlock();
tile.markDirty();
return true;
}
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.WEST){
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ()-1);
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.NORTH)){
if(tile != null){
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
tile.setHeat(tile.getHeat() + 25);
tile.updateBlock();
tile.markDirty();
return true;
}
}
}
}
if(world.isRemote){
if(state.getValue(PistonBellows.FACING) == EnumFacing.NORTH) {
BlockPos tempPos = new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ());
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.EAST)){
makeEmbers(world, tempPos, world.rand);
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.SOUTH) {
BlockPos tempPos = new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ());
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.WEST)){
makeEmbers(world, tempPos, world.rand);
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.EAST) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1);
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.SOUTH)){
makeEmbers(world, tempPos, world.rand);
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.WEST) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1);
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.NORTH)){
makeEmbers(world, tempPos, world.rand);
}
}
}
return true;
}
private void makeEmbers(World world, BlockPos pos, Random rand){
double d0 = (double)pos.getX() + 0.5D;
double d1 = (double)pos.getY() + 0.65D;
double d2 = (double)pos.getZ() + 0.5D;
double d3 = 0.52D;
double d4 = rand.nextDouble() * 0.6D - 0.3D;
if(rand.nextInt(3) == 0){
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
}
if(rand.nextInt(3) == 1){
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2-d4, 0.0D, 0.1D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
}
if(rand.nextInt(3) == 2){
world.spawnParticle(EnumParticleTypes.FLAME, d0-d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
}
if(rand.nextInt(3) == 3){
world.spawnParticle(EnumParticleTypes.FLAME, d0-d4, d1, d2-d4, 0.0D, 0.1D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
}
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TilePistonBellows();
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()), 2);
TilePistonBellows tile = (TilePistonBellows) worldIn.getTileEntity(pos);
if (tile != null) {
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(ACTIVE, Boolean.valueOf(false)), 2);
}
//@Override
//public TileEntity createNewTileEntity(World worldIn, int meta)
//{
//return new TilePistonBellows();
//}
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!world.isRemote){
System.out.println(state.getValue(PistonBellows.FACING));
if(state.getValue(this.ACTIVE) == false) {
world.setBlockState(pos, state.withProperty(ACTIVE, true), 2);
if (state.getValue(PistonBellows.FACING) == EnumFacing.NORTH) {
BlockPos tempPos = new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ());
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.EAST)) {
if (tile != null) {
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
tile.setHeat(tile.getHeat() + 25);
tile.updateBlock();
tile.markDirty();
return true;
}
}
}
}
if (state.getValue(PistonBellows.FACING) == EnumFacing.SOUTH) {
BlockPos tempPos = new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ());
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.WEST)) {
if (tile != null) {
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
tile.setHeat(tile.getHeat() + 25);
tile.updateBlock();
tile.markDirty();
return true;
}
}
}
}
if (state.getValue(PistonBellows.FACING) == EnumFacing.EAST) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1);
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.SOUTH)) {
if (tile != null) {
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
tile.setHeat(tile.getHeat() + 25);
tile.updateBlock();
tile.markDirty();
return true;
}
}
}
}
if (state.getValue(PistonBellows.FACING) == EnumFacing.WEST) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1);
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.NORTH)) {
if (tile != null) {
//System.out.println(world.getBlockState(tempPos).getValue(Firebox.FACING));
tile.setHeat(tile.getHeat() + 25);
tile.updateBlock();
tile.markDirty();
return true;
}
}
}
}
}
}
/*if(world.isRemote){
if(state.getValue(PistonBellows.FACING) == EnumFacing.NORTH) {
BlockPos tempPos = new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ());
if(world.getBlockState(tempPos).getBlock() == ModBlocks.firebox){
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.EAST)){
makeEmbers(world, tempPos, world.rand);
}
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.SOUTH) {
BlockPos tempPos = new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ());
if(world.getBlockState(tempPos).getBlock() == ModBlocks.firebox){
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.WEST)){
makeEmbers(world, tempPos, world.rand);
}
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.EAST) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1);
if(world.getBlockState(tempPos).getBlock() == ModBlocks.firebox){
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.SOUTH)){
makeEmbers(world, tempPos, world.rand);
}
}
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.WEST) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1);
if(world.getBlockState(tempPos).getBlock() == ModBlocks.firebox){
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.NORTH)){
makeEmbers(world, tempPos, world.rand);
}
}
}
}*/
return true;
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
@@ -209,22 +220,38 @@ public class PistonBellows extends CustomFacing {
public int getMetaFromState(IBlockState state) {
int i = 0;
if( (state.getValue(FACING) == EnumFacing.EAST)){
if( (state.getValue(FACING) == EnumFacing.EAST) && state.getValue(ACTIVE) == false){
i = 0;
return i;
}
if( (state.getValue(FACING) == EnumFacing.WEST)){
if( (state.getValue(FACING) == EnumFacing.WEST) && state.getValue(ACTIVE) == false){
i = 1;
return i;
}
if( (state.getValue(FACING) == EnumFacing.SOUTH)){
if( (state.getValue(FACING) == EnumFacing.SOUTH) && state.getValue(ACTIVE) == false){
i = 2;
return i;
}
if( (state.getValue(FACING) == EnumFacing.NORTH)){
if( (state.getValue(FACING) == EnumFacing.NORTH) && state.getValue(ACTIVE) == false){
i = 3;
return i;
}
if( (state.getValue(FACING) == EnumFacing.EAST) && state.getValue(ACTIVE) == true){
i = 4;
return i;
}
if( (state.getValue(FACING) == EnumFacing.WEST) && state.getValue(ACTIVE) == true){
i = 5;
return i;
}
if( (state.getValue(FACING) == EnumFacing.SOUTH) && state.getValue(ACTIVE) == true){
i = 6;
return i;
}
if( (state.getValue(FACING) == EnumFacing.NORTH) && state.getValue(ACTIVE) == true){
i = 7;
return i;
}
return i;
}
@@ -232,33 +259,59 @@ public class PistonBellows extends CustomFacing {
@Override
public IBlockState getStateFromMeta(int meta) {
EnumFacing enumfacing;
Boolean active;
switch (meta & 7)
{
case 0:
enumfacing = EnumFacing.EAST;
active = false;
break;
case 1:
enumfacing = EnumFacing.WEST;
active = false;
break;
case 2:
enumfacing = EnumFacing.SOUTH;
active = false;
break;
case 3:
enumfacing = EnumFacing.NORTH;
active = false;
break;
case 4:
enumfacing = EnumFacing.EAST;
active = true;
break;
case 5:
enumfacing = EnumFacing.WEST;
active = true;
break;
case 6:
enumfacing = EnumFacing.SOUTH;
active = true;
break;
case 7:
enumfacing = EnumFacing.NORTH;
active = true;
break;
default:
enumfacing = EnumFacing.NORTH;
active = false;
}
return this.getDefaultState().withProperty(FACING, enumfacing);
return this.getDefaultState().withProperty(FACING, enumfacing).withProperty(ACTIVE, Boolean.valueOf(active));
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {FACING});
return new BlockStateContainer(this, new IProperty[] {FACING, ACTIVE});
}
//return new ExtendedBlockState(this, new IProperty[] { BotaniaStateProps.CARDINALS, Properties.StaticProperty }, new IUnlistedProperty[] { Properties.AnimationProperty });
@Override
public boolean isFullCube(IBlockState state)
{
@@ -290,5 +343,74 @@ public class PistonBellows extends CustomFacing {
return EnumBlockRenderType.MODEL;
}
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand)
{
if(state.getValue(PistonBellows.ACTIVE) == Boolean.TRUE) {
if (state.getValue(PistonBellows.FACING) == EnumFacing.NORTH) {
BlockPos tempPos = new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ());
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.EAST)) {
makeEmbers(world, tempPos, world.rand);
}
}
}
if (state.getValue(PistonBellows.FACING) == EnumFacing.SOUTH) {
BlockPos tempPos = new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ());
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.WEST)) {
makeEmbers(world, tempPos, world.rand);
}
}
}
if (state.getValue(PistonBellows.FACING) == EnumFacing.EAST) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1);
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.SOUTH)) {
makeEmbers(world, tempPos, world.rand);
}
}
}
if (state.getValue(PistonBellows.FACING) == EnumFacing.WEST) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1);
if (world.getBlockState(tempPos).getBlock() == ModBlocks.firebox) {
TileFirebox tile = (TileFirebox) world.getTileEntity(tempPos);
if ((world.getBlockState(tempPos).getValue(Firebox.ACTIVE) == true) && (world.getBlockState(tempPos).getValue(Firebox.FACING) == EnumFacing.NORTH)) {
makeEmbers(world, tempPos, world.rand);
}
}
}
}
}
private void makeEmbers(World world, BlockPos pos, Random rand){
double d0 = (double)pos.getX() + 0.5D;
double d1 = (double)pos.getY() + 0.65D;
double d2 = (double)pos.getZ() + 0.5D;
double d3 = 0.52D;
double d4 = rand.nextDouble() * 0.6D - 0.3D;
if(rand.nextInt(3) == 0){
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
}
if(rand.nextInt(3) == 1){
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2-d4, 0.0D, 0.1D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
}
if(rand.nextInt(3) == 2){
world.spawnParticle(EnumParticleTypes.FLAME, d0-d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
}
if(rand.nextInt(3) == 3){
world.spawnParticle(EnumParticleTypes.FLAME, d0-d4, d1, d2-d4, 0.0D, 0.1D, 0.0D, new int[0]);
world.spawnParticle(EnumParticleTypes.FLAME, d0+d4, d1, d2+d4, 0.0D, 0.1D, 0.0D, new int[0]);
}
}
}

View File

@@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nmd.primal.forgecraft.items.ItemBellowsHandle;
import nmd.primal.forgecraft.items.ItemTest;
/**
@@ -11,23 +12,21 @@ import nmd.primal.forgecraft.items.ItemTest;
*/
public class ModItems {
public static Item pistonbellows;
public static Item test;
//public static Item cheese;
public static void init() {
pistonbellows = new ItemBellowsHandle();
//test = new ItemTest();
//cheese = new ItemCheese();
}
public static void register() {
GameRegistry.register(pistonbellows);
//GameRegistry.register(test);
//GameRegistry.register(cheese);
}
public static void registerRenders() {
//registerRender(cheese);
registerRender(pistonbellows);
//registerRender(test);
}

View File

@@ -4,6 +4,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityNote;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nmd.primal.forgecraft.tiles.TileFirebox;
import nmd.primal.forgecraft.tiles.TilePistonBellows;
/**
* Created by kitsu on 12/2/2016.
@@ -12,10 +13,8 @@ public class ModTiles {
public static void registerTileEntities () {
registerTileEntity(TileFirebox.class, "firebox");
registerTileEntity(TilePistonBellows.class, "pistonbellows");
}
//public static void registerTileEntities () {
// registerTileEntity(TilePistonBellows.class, "pistonbellows");
//}
private static void registerTileEntity(Class<? extends TileEntity> tile_class, String baseName) {
GameRegistry.registerTileEntity(tile_class, "tile.forgecraft." + baseName);

View File

@@ -0,0 +1,15 @@
package nmd.primal.forgecraft.items;
import nmd.primal.forgecraft.ModInfo;
/**
* Created by mminaie on 1/7/17.
*/
public class ItemBellowsHandle extends BaseItem {
public ItemBellowsHandle() {
setUnlocalizedName(ModInfo.ForgecraftItems.BELLOWSHANDLE.getUnlocalizedName());
setRegistryName(ModInfo.ForgecraftItems.BELLOWSHANDLE.getRegistryName());
}
}

View File

@@ -13,7 +13,6 @@ public class ItemTest extends BaseItem {
public ItemTest() {
setUnlocalizedName(ModInfo.ForgecraftItems.TEST.getUnlocalizedName());
setRegistryName(ModInfo.ForgecraftItems.TEST.getRegistryName());
}
}

View File

@@ -4,7 +4,9 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.renders.TileFireboxRender;
import nmd.primal.forgecraft.renders.TilePistonBellowsRender;
import nmd.primal.forgecraft.tiles.TileFirebox;
import nmd.primal.forgecraft.tiles.TilePistonBellows;
import static nmd.primal.forgecraft.init.ModItems.*;
@@ -25,6 +27,7 @@ public class ClientProxy implements CommonProxy {
public void registerTileRendering()
{
ClientRegistry.bindTileEntitySpecialRenderer(TileFirebox.class, new TileFireboxRender());
ClientRegistry.bindTileEntitySpecialRenderer(TilePistonBellows.class, new TilePistonBellowsRender());
}

View File

@@ -34,7 +34,6 @@ import scala.collection.parallel.ParIterableLike;
public class TileFireboxRender extends TileEntitySpecialRenderer<TileFirebox>
{
private RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
//private EntityItem entItem = null;
@Override
public void renderTileEntityAt(TileFirebox tile, double x, double y, double z, float partialTicks, int destroyStage)

View File

@@ -0,0 +1,89 @@
package nmd.primal.forgecraft.renders;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import nmd.primal.forgecraft.blocks.PistonBellows;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.tiles.TileFirebox;
import nmd.primal.forgecraft.tiles.TilePistonBellows;
import org.lwjgl.Sys;
import org.lwjgl.opengl.GL11;
/**
* Created by mminaie on 1/7/17.
*/
public class TilePistonBellowsRender extends TileEntitySpecialRenderer<TilePistonBellows> {
private RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
@Override
public void renderTileEntityAt(TilePistonBellows tile, double x, double y, double z, float partialTicks, int destroyStage)
{
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5D, y + 0.5D, z + 0.5D);
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
float prevLGTX = OpenGlHelper.lastBrightnessX;
float prevLGTY = OpenGlHelper.lastBrightnessY;
BlockPos pos = tile.getPos();
IBlockState state = this.getWorld().getBlockState(pos);
int bright = tile.getWorld().getCombinedLight(pos.up(), 0);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, bright % 65536, bright / 65536);
GL11.glPushMatrix();
if(state.getValue(PistonBellows.FACING) == EnumFacing.NORTH){
GL11.glRotated(0, 0.0F, 1.0F, 0.0F);
if(state.getValue(PistonBellows.ACTIVE) == Boolean.TRUE){
//System.out.println(tile.getAnimation());
GL11.glTranslated(0.0D, 0, (double) tile.getAnimation()/80);
}
ItemStack stackToRender = new ItemStack(ModItems.pistonbellows, 1);
renderItem.renderItem(stackToRender, renderItem.getItemModelMesher().getItemModel(stackToRender));
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.SOUTH){
//GL11.glPushMatrix();
GL11.glRotated(180, 0.0F, 1.0F, 0.0F);
if(state.getValue(PistonBellows.ACTIVE) == Boolean.TRUE){
//System.out.println(tile.getAnimation());
GL11.glTranslated(0.0D, 0, (double) tile.getAnimation()/80);
}
ItemStack stackToRender = new ItemStack(ModItems.pistonbellows, 1);
renderItem.renderItem(stackToRender, renderItem.getItemModelMesher().getItemModel(stackToRender));
//GL11.glPopMatrix();
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.EAST){
//GL11.glPushMatrix();
GL11.glRotated(270, 0.0F, 1.0F, 0.0F);
if(state.getValue(PistonBellows.ACTIVE) == Boolean.TRUE){
System.out.println(tile.getAnimation());
GL11.glTranslated(0.0D, 0, (double) tile.getAnimation()/80);
}
ItemStack stackToRender = new ItemStack(ModItems.pistonbellows, 1);
renderItem.renderItem(stackToRender, renderItem.getItemModelMesher().getItemModel(stackToRender));
//GL11.glPopMatrix();
}
if(state.getValue(PistonBellows.FACING) == EnumFacing.WEST){
//GL11.glPushMatrix();
GL11.glRotated(90, 0.0F, 1.0F, 0.0F);
if(state.getValue(PistonBellows.ACTIVE) == Boolean.TRUE){
System.out.println(tile.getAnimation());
GL11.glTranslated(0.0D, 0, (double) tile.getAnimation()/80);
}
ItemStack stackToRender = new ItemStack(ModItems.pistonbellows, 1);
renderItem.renderItem(stackToRender, renderItem.getItemModelMesher().getItemModel(stackToRender));
//GL11.glPopMatrix();
}
GL11.glPopMatrix();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevLGTX, prevLGTY);
GL11.glPopMatrix();
}
}

View File

@@ -52,7 +52,7 @@ public class TileFirebox extends TileBaseSlot implements ITickable {
if(!world.isRemote){
World world = this.getWorld();
this.iteration ++;
if(this.iteration == 200 ) {
if(this.iteration == 300 ) {
this.iteration = 0;
IBlockState state = world.getBlockState(this.pos);
BlockPos abovePos = new BlockPos(this.getPos().getX(), this.getPos().getY()+1, this.getPos().getZ());

View File

@@ -1,8 +1,14 @@
package nmd.primal.forgecraft.tiles;
import com.google.common.collect.ImmutableMap;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.animation.TimeValues;
import net.minecraftforge.common.capabilities.Capability;
@@ -10,51 +16,74 @@ import net.minecraftforge.common.model.animation.CapabilityAnimation;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import nmd.primal.forgecraft.blocks.Firebox;
import nmd.primal.forgecraft.blocks.PistonBellows;
import javax.annotation.Nonnull;
/**
* Created by mminaie on 1/5/17.
*/
public class TilePistonBellows extends BaseTile {
private static final String TAG_ACTIVE = "active";
public float innerRingPos;
public boolean active = false;
public boolean hasCart = false;
public boolean hasCartOnTop = false;
public float moving = 0F;
public class TilePistonBellows extends BaseTile implements ITickable{
public int comparator;
public boolean hasRedstone = false;
private int lastComparator = 0;
private final TimeValues.VariableValue move;
private final IAnimationStateMachine asm;
public TilePistonBellows() {
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
move = new TimeValues.VariableValue(0);
asm = ModelLoaderRegistry.loadASM(new ResourceLocation("botania", "asms/block/pump.json"), ImmutableMap.of("move", move));
} else {
move = null;
asm = null;
}
}
private int iteration = 0;
private int animateIteration = 0;
@Override
public boolean hasCapability(@Nonnull Capability<?> cap, @Nonnull EnumFacing side) {
return cap == CapabilityAnimation.ANIMATION_CAPABILITY || super.hasCapability(cap, side);
public void update () {
if (!world.isRemote) {
World world = this.getWorld();
IBlockState state = world.getBlockState(this.pos);
if (world.getBlockState(this.getPos()).getValue(PistonBellows.ACTIVE)) {
iteration++;
if(iteration <= 35){
animateIteration++;
//
}
if(iteration > 35){
animateIteration = 35 - (iteration - 35);
if(animateIteration < 0){
animateIteration = 0;
}
//
}
if(iteration > 71){
iteration = 0;
animateIteration = 0;
world.setBlockState(this.getPos(), state.withProperty(PistonBellows.ACTIVE, false), 3);
}
@Nonnull
@Override
public <T> T getCapability(@Nonnull Capability<T> cap, @Nonnull EnumFacing side) {
if (cap == CapabilityAnimation.ANIMATION_CAPABILITY) {
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
//System.out.println("Iterating");
this.updateBlock();
this.markDirty();
}
return super.getCapability(cap, side);
}
}
public int getIteration(){
return this.iteration;
}
public int getAnimation(){
return this.animateIteration;
}
public NBTTagCompound readNBT(NBTTagCompound nbt)
{
super.readNBT(nbt);
this.iteration = nbt.getInteger("iteration");
this.animateIteration = nbt.getInteger("animate");
return nbt;
}
public NBTTagCompound writeNBT(NBTTagCompound nbt)
{
nbt.setInteger("iteration", this.iteration);
nbt.setInteger("animate", this.animateIteration);
return nbt;
}
}

Binary file not shown.

View File

@@ -0,0 +1,24 @@
{
"joints": {
"head": { "0": [ 1.0 ], "1": [ 1.0 ], "2": [ 1.0 ], "3": [ 1.0 ] }
},
"clips": {
"default": {
"loop": false,
"joint_clips": {},
"events": {}
},
"moving": {
"loop": false,
"joint_clips": {
"head": [{
"variable": "offset_z",
"type": "uniform",
"interpolation": "linear",
"samples": [ 0, 0.5, 0 ]
}]
},
"events": {}
}
}
}

View File

@@ -0,0 +1,13 @@
{
"parameters": {},
"clips": {
"default": "forgecraft:block/pump_head@default",
"moving": [ "apply", "forgecraft:block/pump_head@moving", "#move" ]
},
"states": [ "default", "moving" ],
"transitions": {
"default": "moving",
"moving": "default"
},
"start_state": "default"
}

View File

@@ -1,8 +1,12 @@
{
"variants": {
"facing=north": { "model": "forgecraft:pistonbellows" },
"facing=east": { "model": "forgecraft:pistonbellows", "y": 90 },
"facing=south": { "model": "forgecraft:pistonbellows", "y": 180 },
"facing=west": { "model": "forgecraft:pistonbellows", "y": 270 }
"active=false,facing=north": { "model": "forgecraft:pistonbellows" },
"active=true,facing=north": { "model": "forgecraft:pistonbellows" },
"active=false,facing=east": { "model": "forgecraft:pistonbellows", "y": 90 },
"active=true,facing=east": { "model": "forgecraft:pistonbellows", "y": 90 },
"active=false,facing=south": { "model": "forgecraft:pistonbellows", "y": 180 },
"active=true,facing=south": { "model": "forgecraft:pistonbellows", "y": 180 },
"active=false,facing=west": { "model": "forgecraft:pistonbellows", "y": 270 },
"active=true,facing=west": { "model": "forgecraft:pistonbellows", "y": 270 }
}
}

View File

@@ -96,5 +96,19 @@
"east": { "uv": [ 0, 0, 0, 8 ], "texture": "#texture" }
}
}
]
],
"display": {
"thirdperson_righthand": {
"rotation": [ 60, 45, 0 ],
"scale": [ 0.5, 0.6, 0.5 ]
},
"firstperson_righthand": {
"rotation": [ 0, 45, 0 ],
"scale": [ 0.7, 0.7, 0.7 ]
},
"gui": {
"rotation": [ 45, 45, 0 ],
"scale": [ 0.6, 0.6, 0.6 ]
}
}
}

View File

@@ -1,8 +1,8 @@
{
"__comment": "Designed by Kitsushadow with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "forgecraft:blocks/checker_test",
"texture_test": "forgecraft:blocks/checker_test",
"particle": "blocks/checker_test",
"texture_test": "blocks/checker_test",
"texture": "blocks/planks_oak"
},
"elements": [
@@ -32,32 +32,6 @@
"east": { "uv": [ 15, 5, 16, 15 ], "texture": "#texture" }
}
},
{
"__comment": "piston_arm",
"from": [ 7.5, 3, 2 ],
"to": [ 8.5, 4, 15 ],
"faces": {
"down": { "uv": [ 7.5, 1, 8.5, 14 ], "texture": "#texture" },
"up": { "uv": [ 7.5, 2, 8.5, 15 ], "texture": "#texture" },
"north": { "uv": [ 7.5, 12, 8.5, 13 ], "texture": "#texture" },
"south": { "uv": [ 7.5, 12, 8.5, 13 ], "texture": "#texture" },
"west": { "uv": [ 2, 12, 15, 13 ], "texture": "#texture" },
"east": { "uv": [ 1, 12, 14, 13 ], "texture": "#texture" }
}
},
{
"__comment": "piston_arm1",
"from": [ 7.5, 8, 2 ],
"to": [ 8.5, 9, 15 ],
"faces": {
"down": { "uv": [ 7.5, 1, 8.5, 14 ], "texture": "#texture" },
"up": { "uv": [ 7.5, 2, 8.5, 15 ], "texture": "#texture" },
"north": { "uv": [ 7.5, 11, 8.5, 12 ], "texture": "#texture" },
"south": { "uv": [ 7.5, 11, 8.5, 12 ], "texture": "#texture" },
"west": { "uv": [ 2, 11, 15, 12 ], "texture": "#texture" },
"east": { "uv": [ 1, 11, 14, 12 ], "texture": "#texture" }
}
},
{
"__comment": "wall",
"from": [ 3, 3, 13 ],
@@ -162,19 +136,6 @@
"east": { "uv": [ 2, 13, 3, 15 ], "texture": "#texture" }
}
},
{
"__comment": "piston_arm2",
"from": [ 7.5, 2, 15 ],
"to": [ 8.5, 10, 16 ],
"faces": {
"down": { "uv": [ 7.5, 0, 8.5, 1 ], "texture": "#texture" },
"up": { "uv": [ 7.5, 15, 8.5, 16 ], "texture": "#texture" },
"north": { "uv": [ 7.5, 6, 8.5, 14 ], "texture": "#texture" },
"south": { "uv": [ 7.5, 6, 8.5, 14 ], "texture": "#texture" },
"west": { "uv": [ 15, 6, 16, 14 ], "texture": "#texture" },
"east": { "uv": [ 0, 6, 1, 14 ], "texture": "#texture" }
}
},
{
"__comment": "wall8",
"from": [ 3, 1, 1 ],
@@ -266,5 +227,19 @@
"east": { "uv": [ 4, 5, 5, 15 ], "texture": "#texture" }
}
}
]
],
"display": {
"thirdperson_righthand": {
"rotation": [ 60, 45, 0 ],
"scale": [ 0.5, 0.6, 0.5 ]
},
"firstperson_righthand": {
"rotation": [ 0, 45, 0 ],
"scale": [ 0.7, 0.7, 0.7 ]
},
"gui": {
"rotation": [ 45, 45, 0 ],
"scale": [ 0.6, 0.6, 0.6 ]
}
}
}

View File

@@ -0,0 +1,62 @@
{
"__comment": "Designed by Kitsushadow with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "blocks/checker_test",
"texture_test": "blocks/checker_test",
"texture": "blocks/planks_oak"
},
"elements": [
{
"__comment": "piston_arm",
"from": [ 7.5, 3, 2 ],
"to": [ 8.5, 4, 15 ],
"faces": {
"down": { "uv": [ 7.5, 1, 8.5, 14 ], "texture": "#texture" },
"up": { "uv": [ 7.5, 2, 8.5, 15 ], "texture": "#texture" },
"north": { "uv": [ 7.5, 12, 8.5, 13 ], "texture": "#texture" },
"south": { "uv": [ 7.5, 12, 8.5, 13 ], "texture": "#texture" },
"west": { "uv": [ 2, 12, 15, 13 ], "texture": "#texture" },
"east": { "uv": [ 1, 12, 14, 13 ], "texture": "#texture" }
}
},
{
"__comment": "piston_arm1",
"from": [ 7.5, 8, 2 ],
"to": [ 8.5, 9, 15 ],
"faces": {
"down": { "uv": [ 7.5, 1, 8.5, 14 ], "texture": "#texture" },
"up": { "uv": [ 7.5, 2, 8.5, 15 ], "texture": "#texture" },
"north": { "uv": [ 7.5, 11, 8.5, 12 ], "texture": "#texture" },
"south": { "uv": [ 7.5, 11, 8.5, 12 ], "texture": "#texture" },
"west": { "uv": [ 2, 11, 15, 12 ], "texture": "#texture" },
"east": { "uv": [ 1, 11, 14, 12 ], "texture": "#texture" }
}
},
{
"__comment": "piston_arm2",
"from": [ 7.5, 2, 15 ],
"to": [ 8.5, 10, 16 ],
"faces": {
"down": { "uv": [ 7.5, 0, 8.5, 1 ], "texture": "#texture" },
"up": { "uv": [ 7.5, 15, 8.5, 16 ], "texture": "#texture" },
"north": { "uv": [ 7.5, 6, 8.5, 14 ], "texture": "#texture" },
"south": { "uv": [ 7.5, 6, 8.5, 14 ], "texture": "#texture" },
"west": { "uv": [ 15, 6, 16, 14 ], "texture": "#texture" },
"east": { "uv": [ 0, 6, 1, 14 ], "texture": "#texture" }
}
}
],
"display": {
"thirdperson_righthand": {
"translation": [ 0, 0, -6.9 ]
},
"gui": {
"rotation": [ 90, 0, -90 ],
"translation": [ 2, 1, 0 ]
},
"fixed": {
"rotation": [ 90, 0, -90 ],
"translation": [ 2, 1, 0 ]
}
}
}

View File

@@ -4,41 +4,5 @@
"particle": "forgecraft:blocks/brick",
"texture": "forgecraft:blocks/brick"
},
"parent": "forgecraft:block/firebox",
"display": {
"thirdperson_": {
"rotation": [
0,
0,
0
],
"translation": [
0,
0,
0
],
"scale": [
0.1,
0.1,
0.1
]
},
"firstperson": {
"rotation": [
0,
0,
0
],
"translation": [
0,
0,
0
],
"scale": [
0.1,
0.1,
0.1
]
}
}
"parent": "forgecraft:block/firebox"
}

View File

@@ -0,0 +1,9 @@
{
"forge_marker":1,
"textures": {
"particle": "blocks/checker_test",
"texture_test": "blocks/checker_test",
"texture": "blocks/planks_oak"
},
"parent": "forgecraft:block/pistonbellows"
}