Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TileEntity + Block
package net.kubasz.kmod;
import java.util.Random;
import net.minecraft.src.Block;
import net.minecraft.src.BlockContainer;
import net.minecraft.src.EntityPig;
import net.minecraft.src.Material;
import net.minecraft.src.ModLoader;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.forge.ITextureProvider;
public class BlockPigRain extends BlockContainer implements ITextureProvider {
public BlockPigRain(int i) {
super(i, Material.circuits);
setBlockName("block.pigrain");
setHardness(0.0F);
setRequiresSelfNotify();
this.stepSound = soundMetalFootstep;
ModLoader.RegisterTileEntity(TilePigRain.class, "pigRainer");
blockIndexInTexture = 6;
}
@Override
public String getTextureFile() {
return "/kgfx/kblocks.png";
}
@Override
public TileEntity getBlockEntity() {
return new TilePigRain();
}
}
package net.kubasz.kmod;
import net.minecraft.src.EntityPig;
import net.minecraft.src.TileEntity;
public class TilePigRain extends TileEntity {
int cn;
public TilePigRain() {
cn = 0;
}
@Override
public void updateEntity() {
super.updateEntity();
if(!worldObj.multiplayerWorld)
{
cn++;
if(cn>=100)
{
cn = 0;
EntityPig pig = new EntityPig(worldObj);
pig.setSaddled(false);
pig.heal(-9);
pig.setPosition(this.xCoord,this.yCoord-2, this.zCoord);
worldObj.entityJoinedWorld(pig);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment