Hello people, I have a really easy question, I have read some other post but somehow this piece of code doesn't work.
I just want to place a block when some simple conditions happens, the entity part is okay , but the block is not placed, what am I doing wrong?
Here is the code:
package com.zeldem.pobladosmod.objects.items;
import com.zeldem.pobladosmod.PobladosMod;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.TurtleEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class House_generator extends Item{
public static int count=0;
public House_generator(Properties properties) {
super(properties);
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World mundo, BlockState state, BlockPos pos,LivingEntity entityLiving) {
PobladosMod.LOGGER.debug("Item has destroyed "+(++count)+" blocks");
if(count%6==0) {
if(!mundo.isRemote) {
// entity spawning example
PobladosMod.LOGGER.debug("creando tortuga");
TurtleEntity t= new TurtleEntity( EntityType.TURTLE,mundo);
t.setPosition(pos.getX(),pos.getY()+2,pos.getZ() );
mundo.addEntity(t);//entity is created succesfully :D
//block placement example, BLOCK IS NOT PLACED :(
mundo.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState(), 0);
}
}
return true;
}
}
Thanks in advice