Jump to content

Recommended Posts

Posted (edited)

When I break a machine block the particles are from the wrong model.

 

I have three machines using the same block class and different variants, they also have a facing property. (I have only textured one, the others use cobblestone and dirt for now)

EDIT (accidentally removed line, need to read before I post) - The first machine's particles work when it is facing north and south, but have cobblestone (2nd machine) particles for east and west.

The second machine does the same but the broken particle texture is dirt, from the third model file

And the same with the third and the particles are from the first machine

 

The blockstates file is: (sorry I like to spread it out)

{

    "variants": {
    
        "facing=north,type=threefold_combiner": {
        
            "model": "enhancedmechanisms:machine_threefold_combiner",
            "y": 180
            
        },
        
        "facing=south,type=threefold_combiner": {
        
            "model": "enhancedmechanisms:machine_threefold_combiner"
            
        },
        
        "facing=east,type=threefold_combiner": {
        
            "model": "enhancedmechanisms:machine_threefold_combiner",
            "y": 270
            
        },
        
        "facing=west,type=threefold_combiner": {
        
            "model": "enhancedmechanisms:machine_threefold_combiner",
            "y": 90
            
        },
        
        "facing=north,type=alloy_smeltery": {
        
            "model": "cobblestone"
            
        },
        
        "facing=south,type=alloy_smeltery": {
        
            "model": "cobblestone"
            
        },
        
        "facing=east,type=alloy_smeltery": {
        
            "model": "cobblestone"
            
        },
        
        "facing=west,type=alloy_smeltery": {
        
            "model": "cobblestone"
            
        },
        
        "facing=north,type=machine_builder_crude": {
        
            "model": "dirt"
            
        },
        
        "facing=south,type=machine_builder_crude": {
        
            "model": "dirt"
            
        },
        
        "facing=east,type=machine_builder_crude": {
        
            "model": "dirt"
            
        },
        
        "facing=west,type=machine_builder_crude": {
        
            "model": "dirt"
            
        }
    
    }

}

 

The first machine "threefold_combiner" model:

{

    "parent": "block/block",
    
    "elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  {"texture": "#down", "cullface": "down"},
                "up":    {"texture": "#up", "cullface": "up" },
                "north": {"uv": [16, 0, 0, 16], "texture": "#north", "cullface": "north" },
                "south": {"texture": "#south", "cullface": "south" },
                "west":  {"texture": "#west", "cullface": "west" },
                "east":  {"texture": "#east", "cullface": "east" }
            }
        }
    ],
    
    "textures": {
        
        "particle": "enhancedmechanisms:blocks/machine_threefold_combiner_front",
        
        "up": "enhancedmechanisms:blocks/machine_threefold_combiner_up",
        "down": "enhancedmechanisms:blocks/machine_threefold_combiner_front",
        "north": "enhancedmechanisms:blocks/machine_threefold_combiner_front",
        "east": "enhancedmechanisms:blocks/machine_threefold_combiner_east",
        "south": "enhancedmechanisms:blocks/machine_threefold_combiner_front",
        "west": "enhancedmechanisms:blocks/machine_threefold_combiner_west"
    
    }

}

 

The machine block class:

package theredmelon.enhancedmechanisms.objects.machines;

import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.scoreboard.IScoreCriteria.EnumRenderType;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import theredmelon.enhancedmechanisms.EnhancedMechanisms;
import theredmelon.enhancedmechanisms.init.BlockInit;
import theredmelon.enhancedmechanisms.init.ItemInit;
import theredmelon.enhancedmechanisms.objects.blocks.item.IMetaBlockName;
import theredmelon.enhancedmechanisms.objects.blocks.item.ItemBlockBase;
import theredmelon.enhancedmechanisms.utils.IHasModel;
import theredmelon.enhancedmechanisms.utils.handlers.EnumHandler.MachineTypes;

public class Machine extends Block implements IMetaBlockName, IHasModel {

	public static final PropertyEnum TYPE = PropertyEnum.create("type", MachineTypes.class);
	public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
	
	public Machine (String name, Material material, CreativeTabs tab) {

		super(material);
		setCreativeTab(tab);
		setUnlocalizedName(name);
		setRegistryName(name);
		setDefaultState(blockState.getBaseState().withProperty(TYPE, MachineTypes.THREEFOLD_COMBINER).withProperty(FACING, EnumFacing.NORTH));
		
		BlockInit.BLOCKS.add(this);
		ItemInit.MACHINE_ITEM = new ItemBlockBase(this).setRegistryName(name);
		ItemInit.ITEMS.add(ItemInit.MACHINE_ITEM);
		
	}	

	@Override
	public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
		
		return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(TYPE, getStateFromMeta(meta * EnumFacing.HORIZONTALS.length).getValue(TYPE));
		
	}
	
	@Override
	protected BlockStateContainer createBlockState() {
		
		return new BlockStateContainer(this, new IProperty[] {TYPE, FACING});
		
	}
	
	@Override
	public int getMetaFromState(IBlockState state) {
		
		MachineTypes type = (MachineTypes) state.getValue(TYPE);
		EnumFacing facing = (EnumFacing) state.getValue(FACING);
		int meta = type.getID() * EnumFacing.HORIZONTALS.length + facing.getIndex();
		return meta;
		
	}
		
	@Override
	public IBlockState getStateFromMeta(int meta) {
		
		MachineTypes type = MachineTypes.values()[(int) (meta / EnumFacing.HORIZONTALS.length) % MachineTypes.values().length];
		EnumFacing facing = EnumFacing.HORIZONTALS[meta % EnumFacing.HORIZONTALS.length];
		return getDefaultState().withProperty(TYPE, type).withProperty(FACING, facing);
		
	}
	
	@Override
	public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) {
		
		for (int i = 0; i < MachineTypes.values().length; i++) {
			
			items.add(new ItemStack(this, 1, i));
			
		}
		
	}

	@Override
	public String getSpecialName(ItemStack stack) {

		return MachineTypes.values()[stack.getItemDamage() % MachineTypes.values().length].getName();
		
	}
	
	@Override
	public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
		
		return new ItemStack(Item.getItemFromBlock(this), 1, ((MachineTypes) state.getValue(TYPE)).getID());
		
	}
	
	@Override
	public int damageDropped(IBlockState state) {

		return (int) getMetaFromState(state) / EnumFacing.HORIZONTALS.length;
		
	}

	@Override
	public void registerModels() {

		for (int i = 0; i < MachineTypes.values().length; i++) {
			
			EnhancedMechanisms.proxy.registerItemVariantsRenderer(Item.getItemFromBlock(this), i, "inventory", MachineTypes.values()[i].getName());
			
		}
		
	}
	
}

 

I don't know what else you'd want to see, but these are the ones I think you'd want to see, and there are no errors in console related to this issue.

 

Thanks for the help.

Edited by TRMelon
Posted

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

, Don't really know what you wanted me to with this line and since they all have different particle textures I don't think setting a default would help, so I tried putting it like this:

        "facing=north,type=threefold_combiner": {
        
            "model": "enhancedmechanisms:machine_threefold_combiner",
            "y": 180,
            
            "textures": {
                "particle": "blocks/planks_oak"
            }
            
        },

Tried both, neither worked.

 

Was looking at what was going on, added some console prints:

	@Override
	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {

		System.out.println(state.getValue(TYPE));
		System.out.println(state.getValue(FACING));
		
		return super.getActualState(state, worldIn, pos);
		
	}

 

the blockstate changed as I break the block, don't know why.

Posted (edited)

Ok, then I don't know

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

k nvm, looked at how the anvil converted between state and meta data and used that instead of the crap i was trying to use here, ill have it fixed soon, that was the issue

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.