Jump to content

[1.7.10] Block can't be moved by piston


nidico100

Recommended Posts

Why can't the block be moved with a piston?

package net.bplaced.nidico100.Downgrade;

import scala.tools.nsc.ConsoleWriter;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.bplaced.nidico100.Downgrade.DowngradeMod;
import net.bplaced.nidico100.Downgrade.TileEntityBlockSlime;
import net.bplaced.nidico100.Downgrade.Proxis.DowngradeModClientProxy;


public class BlockSlime extends BlockContainer {

public BlockSlime(Material material) {
	super(material);

	this.slipperiness = 0.8F;
	this.setHardness(0F);
	this.setResistance(0F);
	this.setStepSound(soundTypeCloth);

}

//FUNCTION BOUNCING 


public void onFallenUpon (World worldIn, int x, int y, int z, Entity entityIn, float fallDistance) {
	if (entityIn.isSneaking()) {
		super.onFallenUpon(worldIn, x, y, z, entityIn, fallDistance);
	} else {			
		entityIn.moveEntity(0, fallDistance/2, 0);
		entityIn.fallDistance = 0.0F;
	}
} 

    public void onEntityCollidedWithBlock(World worldIn, int x, int y, int z, Entity entityIn) {
        if (Math.abs(entityIn.motionY) < 0.1D && !entityIn.isSneaking()) {
            double d0 = 0.4D + Math.abs(entityIn.motionY) * 0.2D;
            entityIn.motionX *= d0;
            entityIn.motionZ *= d0;
        }

        super.onEntityCollidedWithBlock(worldIn, x, y, z, entityIn);
    }
    
    //OVERRIDE
@Override	
public int getRenderBlockPass() {
            return 1;
}
@Override
public int getRenderType() {
	return -1;
}
@Override
public boolean isOpaqueCube() {
	return false;
}
@Override
public boolean renderAsNormalBlock() {
	return false;
}

@Override
public boolean canRenderInPass(int pass) {
		DowngradeModClientProxy.renderPass = pass;
	return true;
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
	return new TileEntityBlockSlime();
}

//BLOCK ICON

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
	this.blockIcon = iconRegister.registerIcon("downgrademod:slime");
}

}

Link to comment
Share on other sites

That is because your block has a TileEntity. You have to remove the TileEntity for it to be pushable by a piston.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Depends on the model. Does it have animations? Then yes you need a TE. Otherwise an ISBRH is enough.

no it doesn't

that's the model:

 

package net.bplaced.nidico100.Downgrade;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class BlockSlimeModel extends ModelBase {

 

public ModelRenderer innen;

    public ModelRenderer aussen;

 

    public BlockSlimeModel() {

        this.textureWidth = 16;

        this.textureHeight = 16;

        this.innen = new ModelRenderer(this, 0, 0);

        this.innen.mirror = true;

        this.innen.setRotationPoint(3.0F, 3.0F, 3.0F);

        this.innen.addBox(0.0F, 0.0F, 0.0F, 10, 10, 10, 0.0F);

        this.aussen = new ModelRenderer(this, 0, 0);

        this.aussen.setRotationPoint(0.0F, 0.0F, 0.0F);

        this.aussen.addBox(0.0F, 0.0F, 0.0F, 16, 16, 16, 0.0F);

    }

 

    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {

        this.innen.render(f5);

        this.aussen.render(f5);

    }

   

    public void renderModel(float f){

        this.innen.render(f);

        this.aussen.render(f);

    }

   

    public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {

        modelRenderer.rotateAngleX = x;

        modelRenderer.rotateAngleY = y;

        modelRenderer.rotateAngleZ = z;

    }

}

 

 

 

that's the block:

 

package net.bplaced.nidico100.Downgrade;

 

import scala.tools.nsc.ConsoleWriter;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.entity.Entity;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.IIcon;

import net.minecraft.world.World;

import net.bplaced.nidico100.Downgrade.DowngradeMod;

import net.bplaced.nidico100.Downgrade.TileEntityBlockSlime;

import net.bplaced.nidico100.Downgrade.Proxis.DowngradeModClientProxy;

 

 

public class BlockSlime extends BlockContainer {

 

public BlockSlime(Material material) {

super(material);

 

this.slipperiness = 0.8F;

this.setHardness(0F);

this.setResistance(0F);

this.setStepSound(soundTypeCloth);

 

}

 

//FUNKTION BOUNCING

 

 

public void onFallenUpon (World worldIn, int x, int y, int z, Entity entityIn, float fallDistance) {

if (entityIn.isSneaking()) {

super.onFallenUpon(worldIn, x, y, z, entityIn, fallDistance);

} else {

entityIn.moveEntity(0, fallDistance/2, 0);

entityIn.fallDistance = 0.0F;

}

}

 

    public void onEntityCollidedWithBlock(World worldIn, int x, int y, int z, Entity entityIn) {

        if (Math.abs(entityIn.motionY) < 0.1D && !entityIn.isSneaking()) {

            double d0 = 0.4D + Math.abs(entityIn.motionY) * 0.2D;

            entityIn.motionX *= d0;

            entityIn.motionZ *= d0;

        }

 

        super.onEntityCollidedWithBlock(worldIn, x, y, z, entityIn);

    }

   

    //OVERRIDE

@Override

public int getRenderBlockPass() {

            return 1;

}

@Override

public int getRenderType() {

return -1;

}

@Override

public boolean isOpaqueCube() {

return false;

}

@Override

public boolean renderAsNormalBlock() {

return false;

}

 

@Override

public boolean canRenderInPass(int pass) {

DowngradeModClientProxy.renderPass = pass;

return true;

}

@Override

public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {

return new TileEntityBlockSlime();

}

 

//BLOCK ICON

 

@SideOnly(Side.CLIENT)

public void registerBlockIcons(IIconRegister iconRegister) {

this.blockIcon = iconRegister.registerIcon("downgrademod:slime");

}

 

}

 

that's tileentity of slimeblock:

 

package net.bplaced.nidico100.Downgrade;

 

import net.minecraft.tileentity.TileEntity;

 

public class TileEntityBlockSlime extends TileEntity {

 

}

 

 

 

that's the renderer

 

package net.bplaced.nidico100.Downgrade;

 

import org.lwjgl.opengl.GL11;

 

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.ResourceLocation;

 

public class RenderBlockSlime extends TileEntitySpecialRenderer {

 

private static final ResourceLocation texture = new ResourceLocation("downgrademod", "textures/models/slime.png");

 

private BlockSlimeModel model;

 

public RenderBlockSlime(){

this.model = new BlockSlimeModel();

}

 

@Override

public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {

GL11.glPushMatrix();

GL11.glTranslatef((float)x+1.0F, (float)y+1.0F, (float)z+0.0F);

GL11.glRotatef(180, 0F, 0F, 1F);

   

GL11.glPushAttrib(GL11.GL_ENABLE_BIT);

 

    GL11.glEnable(GL11.GL_BLEND);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

 

    this.bindTexture(texture);

 

GL11.glPushMatrix();

this.model.renderModel(0.0625F);

GL11.glPopAttrib();

GL11.glPopMatrix();

GL11.glPopMatrix();

}

 

}

 

 

 

that's the item renderer

 

package net.bplaced.nidico100.Downgrade;

 

import org.lwjgl.opengl.GL11;

 

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

import net.minecraftforge.client.IItemRenderer;

 

public class ItemRenderBlockSlime implements IItemRenderer{

 

TileEntitySpecialRenderer render;

private TileEntity entity;

 

public ItemRenderBlockSlime(TileEntitySpecialRenderer render, TileEntity entity){

this.entity = entity;

this.render = render;

}

 

 

@Override

public boolean handleRenderType(ItemStack item, ItemRenderType type) {

return true;

}

 

@Override

public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,

ItemRendererHelper helper) {

return true;

}

 

@Override

public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

if (type == IItemRenderer.ItemRenderType.ENTITY)

GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);

 

}

 

}

 

 

Link to comment
Share on other sites

Why are you actually using a model? It only has 2 cubes... You should use an ISBRH. That way you don't need a TileEntity so it can be pushed by pistons.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

ISBRH is not available in 1.7.10 anymore.

 

That's funny.

 

public class RenderUnstableBlock implements ISimpleBlockRenderingHandler

 

I seem to be using it just fine.

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.

Link to comment
Share on other sites

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.