14 mai 2016, 20:48

Bonjour,
Alors j’ai un block avec plusieurs variantes et orientable (verticalement), quand je le pose, avec un variante en particulier, un autre block est posé, j’ai mis des print dans la fonction “onBlockPlacedBy” et je trouve ça un peu bizarre…

@Override
    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
    {
EnumFacing face = WorldUtil.getVerticalFacingFromEntity(placer, pos);
Energy.log.info("Before : " + worldIn.getBlockState(pos) + " ; Given by function : " + state);
worldIn.setBlockState(pos, state.withProperty(onGround, Boolean.valueOf(face.equals(EnumFacing.DOWN))), 3);
Energy.log.info("State added in world : " + state.withProperty(onGround, Boolean.valueOf(face.equals(EnumFacing.DOWN))));
Energy.log.info("Current state in world : " + worldIn.getBlockState(pos));

    try
{
TileEntityEntityDetector te = (TileEntityEntityDetector) worldIn.getTileEntity(pos);
if(placer instanceof EntityPlayer) te.setOwner((EntityPlayer) placer);
}
catch (Exception e)
{
//Je ne veux pas que ça crash (comme c'est pas le bon block, pas le bon tile entity...)
}
}

Et voici les logs qui vont avec :

[22:33:18] [Server thread/INFO] [Energy/]: Before : energy:EntityDetector[detectionRange=range_5,killMods=false,onGround=false] ; Given by function : energy:EntityDetector[detectionRange=range_5,killMods=false,onGround=false] Les states avant que l'on change quelque chose
[22:33:18] [Server thread/INFO] [Energy/]: State added in world : energy:EntityDetector[detectionRange=range_5,killMods=false,onGround=true] //Le state donné à setBlockState
[22:33:18] [Server thread/INFO] [Energy/]: Current state in world : energy:Computer[facing=south] //Après l'ajout dans le world obtenu avec getBlockState

C’est un peu bizarre…