Jump to content

Recommended Posts

Posted

Hello, I'm back from my somewhat eternal hiatus and I've run into a problem already, sadly.

 

I have a block with a tile entity and a custom renderer. For some reason, the block is not appearing my custom tab. If I try searching for the block, it does not appear.

 

ServerProxy:

package simplyberries;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import simplyberries.block.BlockBerryBush;
import simplyberries.block.TileEntityBerryBush;
import cpw.mods.fml.common.registry.GameRegistry;

public class ServerProxySB {
public static Block berryBush = new BlockBerryBush();

public void initServer() {
	GameRegistry.registerTileEntity(TileEntityBerryBush.class, "tileEntityBerryBush");

	GameRegistry.registerBlock(berryBush, "berryBush");
}

public void initClient() {
}

public static CreativeTabs tab = new CreativeTabs("simplyBerries") {
	@Override
	public Item getTabIconItem() {
		return Item.getItemFromBlock(berryBush);
	}
};
}

 

ClientProxy:

package simplyberries;

import simplyberries.block.TileEntityBerryBush;
import simplyberries.client.render.TileEntityBerryBushRenderer;
import tlhpoeCore.TLHPoE;
import cpw.mods.fml.client.registry.ClientRegistry;

public class ClientProxySB extends ServerProxySB {
@Override
public void initClient() {
	TLHPoE.registerUpdateDetector(ReferenceSB.ID, ReferenceSB.NAME, ReferenceSB.VERSION, "0B6mhkrh-GwwwR2JjUUdDSWh3d0U");

	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBerryBush.class, new TileEntityBerryBushRenderer());
}
}

 

Block:

package simplyberries.block;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import simplyberries.ServerProxySB;

public class BlockBerryBush extends BlockContainer {
public BlockBerryBush() {
	super(Material.leaves);

	this.setBlockTextureName("leaves");
	this.setStepSound(Block.soundTypeGrass);
	this.setCreativeTab(ServerProxySB.tab);
	this.setBlockName("berryBush");
}

@Override
public TileEntity createNewTileEntity(World world, int meta) {
	return new TileEntityBerryBush();
}

@Override
public int getRenderType() {
	return -1;
}

@Override
public boolean isOpaqueCube() {
	return false;
}

@Override
public boolean renderAsNormalBlock() {
	return false;
}
}

 

TileEntity:

package simplyberries.block;

import net.minecraft.tileentity.TileEntity;

public class TileEntityBerryBush extends TileEntity {
}

 

Model:

package simplyberries.client.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelBerryBush extends ModelBase {
ModelRenderer mainStem;

ModelRenderer branch1;
ModelRenderer branch2;
ModelRenderer branch3;

ModelRenderer leaves;

ModelRenderer dirtPile;

public ModelBerryBush() {
	textureWidth = 64;
	textureHeight = 32;

	mainStem = new ModelRenderer(this, 4, 0);
	mainStem.addBox(0F, 0F, 0F, 2, 6, 2);
	mainStem.setRotationPoint(-1F, 18F, -1F);
	mainStem.setTextureSize(64, 32);
	mainStem.mirror = true;
	setRotation(mainStem, 0F, 0F, 0F);

	branch1 = new ModelRenderer(this, 0, 0);
	branch1.addBox(0F, 0F, 0F, 1, 5, 1);
	branch1.setRotationPoint(2.933333F, 15.66667F, -2.9F);
	branch1.setTextureSize(64, 32);
	branch1.mirror = true;
	setRotation(branch1, 0F, 0.669215F, 0.9294653F);

	branch2 = new ModelRenderer(this, 0, 0);
	branch2.addBox(0F, 0F, 0F, 1, 5, 1);
	branch2.setRotationPoint(-3.066667F, 14.8F, -2.4F);
	branch2.setTextureSize(64, 32);
	branch2.mirror = true;
	setRotation(branch2, -0.0743572F, -0.6320364F, -0.669215F);

	branch3 = new ModelRenderer(this, 0, 0);
	branch3.addBox(0F, 0F, 0F, 1, 5, 1);
	branch3.setRotationPoint(-0.6666667F, 15.93333F, 5F);
	branch3.setTextureSize(64, 32);
	branch3.mirror = true;
	setRotation(branch3, 0.1487144F, 1.673038F, -0.9294653F);

	leaves = new ModelRenderer(this, 0, ;
	leaves.addBox(0F, 0F, 0F, 10, 10, 10);
	leaves.setRotationPoint(-5F, 11.4F, -5F);
	leaves.setTextureSize(64, 32);
	leaves.mirror = true;
	setRotation(leaves, 0F, 0F, 0F);

	dirtPile = new ModelRenderer(this, 12, 0);
	dirtPile.addBox(0F, 0F, 0F, 3, 1, 3);
	dirtPile.setRotationPoint(-1.5F, 23.4F, -1.5F);
	dirtPile.setTextureSize(64, 32);
	dirtPile.mirror = true;
	setRotation(dirtPile, 0F, 0F, 0F);
}

@Override
public void render(Entity e, float f, float f1, float f2, float f3, float f4, float f5) {
	super.render(e, f, f1, f2, f3, f4, f5);

	setRotationAngles(f, f1, f2, f3, f4, f5, e);

	mainStem.render(f5);

	branch1.render(f5);
	branch2.render(f5);
	branch3.render(f5);

	leaves.render(f5);

	dirtPile.render(f5);
}

private void setRotation(ModelRenderer model, float x, float y, float z) {
	model.rotateAngleX = x;
	model.rotateAngleY = y;
	model.rotateAngleZ = z;
}
}

 

TileEntityRenderer:

package simplyberries.client.render;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import org.lwjgl.opengl.GL11;

import simplyberries.client.model.ModelBerryBush;
import tlhpoeCore.util.MCUtil;

public class TileEntityBerryBushRenderer extends TileEntitySpecialRenderer {
private static final ResourceLocation TEXTURE = MCUtil.newResource("simplyberries:textures/blocks/berryBush.png");
private static final ModelBerryBush MODEL = new ModelBerryBush();

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) {
	GL11.glPushMatrix();

	GL11.glTranslated(x, y, z);

	Minecraft mc = MCUtil.getMC();
	World world = mc.theWorld;

	int x2 = (int) x;
	int y2 = (int) y;
	int z2 = (int) z;

	adjustLightFixture(world, x2, y2, z2, world.getBlock(x2, y2, z2));

	mc.renderEngine.bindTexture(TEXTURE);

	MODEL.render(null, 0F, 0F, 0F, 0F, 0F, 0F);

	GL11.glPopMatrix();
}

private void adjustLightFixture(World world, int i, int j, int k, Block block) {
	Tessellator tess = Tessellator.instance;

	float brightness = block.getLightValue(world, i, j, k);

	int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);

	int modulousModifier = skyLight % 65536;
	int divModifier = skyLight / 65536;

	tess.setColorOpaque_F(brightness, brightness, brightness);

	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier);
}
}

 

I setup debug things at the registering parts, and they're all being called.

Kain

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.