Jump to content

Recommended Posts

Posted

Well, I have this

 

package common.zeroquest.core.proxy;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFire;
import net.minecraft.block.properties.IProperty;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import common.zeroquest.ModBlocks;
import common.zeroquest.ModItems;
import common.zeroquest.block.portal.*;
import common.zeroquest.client.model.*;
import common.zeroquest.client.particle.*;
import common.zeroquest.client.render.*;
import common.zeroquest.client.render.entity.RenderJakan;
import common.zeroquest.client.render.entity.RenderKortor;
import common.zeroquest.client.render.entity.RenderKurr;
import common.zeroquest.client.render.entity.RenderProjectiles;
import common.zeroquest.client.render.entity.RenderRiggator;
import common.zeroquest.client.render.tileentity.RenderFoodBowl;
import common.zeroquest.client.render.tileentity.RenderNileTable;
import common.zeroquest.client.render.zertum.RenderDarkZertum;
import common.zeroquest.client.render.zertum.RenderDestroZertum;
import common.zeroquest.client.render.zertum.RenderForisZertum;
import common.zeroquest.client.render.zertum.RenderIceZertum;
import common.zeroquest.client.render.zertum.RenderMetalZertum;
import common.zeroquest.client.render.zertum.RenderRedZertum;
import common.zeroquest.client.render.zertum.RenderZertum;
import common.zeroquest.client.render.zertum.RenderZinogre;
import common.zeroquest.core.handlers.*;
import common.zeroquest.entity.*;
import common.zeroquest.entity.projectile.*;
import common.zeroquest.entity.tileentity.*;
import common.zeroquest.entity.zertum.*;
import common.zeroquest.entity.zertum.util.*;
import common.zeroquest.lib.Constants;

public class ClientProxy extends CommonProxy {

@Override
public void registerRenderThings() {
	RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
	RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
	registerRender(EntityZertum.class, new RenderZertum(renderManager, new ModelZertum(), 0.5F));
	registerRender(EntityRedZertum.class, new RenderRedZertum(renderManager, new ModelZertum(), 0.5F));
	registerRender(EntityDarkZertum.class, new RenderDarkZertum(renderManager, new ModelZertum(), 0.5F));
	registerRender(EntityDestroZertum.class, new RenderDestroZertum(renderManager, new ModelZertum(), 0.5F));
	registerRender(EntityIceZertum.class, new RenderIceZertum(renderManager, new ModelZertum(), 0.5F));
	registerRender(EntityForisZertum.class, new RenderForisZertum(renderManager, new ModelZertum(), 0.5F));
	registerRender(EntityMetalZertum.class, new RenderMetalZertum(renderManager, new ModelZertum(), 0.5F));
	registerRender(EntityJakan.class, new RenderJakan(renderManager, new ModelJakan(), 1.0F));
	registerRender(EntityKurr.class, new RenderKurr(renderManager, new ModelKurr(), 1.0F));
	registerRender(EntityKortor.class, new RenderKortor(renderManager, new ModelKortor(), 1.0F));
	registerRender(EntityRiggator.class, new RenderRiggator(renderManager, new ModelRiggator(), 1.0F));
	registerRender(EntityZinogre.class, new RenderZinogre(renderManager, new ModelZinogre(), 1.0F));
	// registerRender(EntityRowarn.class, new RenderRowarn(renderManager, new ModelRowarn(), 1.0F));

	registerRender(EntityFlamingPoisonball.class, new RenderProjectiles(renderManager, ModItems.FPoisonball, renderItem));
	registerRender(EntityIceball.class, new RenderProjectiles(renderManager, ModItems.iceBall, renderItem));
	registerRender(EntityGrenade.class, new RenderProjectiles(renderManager, ModItems.nileGrenade, renderItem));
	registerRender(EntityZertumBeam.class, new RenderProjectiles(renderManager, Items.snowball, renderItem));

	bindTileEntitySpecialRenderer(TileEntityNileWorkbench.class, new RenderNileTable());
	bindTileEntitySpecialRenderer(TileEntityFoodBowl.class, new RenderFoodBowl());
}

@Override
public void registerMoreThings() {

	registerKeyBinding(KeyStateHandler.come);
	registerKeyBinding(KeyStateHandler.stay);
	registerKeyBinding(KeyStateHandler.ok);
	registerKeyBinding(KeyStateHandler.heel);
	registerFMLCommonEventBus(new KeyStateHandler());
}

@Override
public void registerStateMappings() {
	addStateMapperToIgnore(ModBlocks.nileFire, BlockNileFire.AGE);
	addStateMapperToIgnore(ModBlocks.nileFire, BlockFire.AGE);
}

@Override
public void registerStateMappingsForDark() {
	addStateMapperToIgnore(ModBlocks.darkFire, BlockDarkFire.AGE);
	addStateMapperToIgnore(ModBlocks.darkFire, BlockFire.AGE);
}

// Registers\\
public void registerFMLCommonEventBus(Object target) {
	FMLCommonHandler.instance().bus().register(target);
}

public void registerKeyBinding(KeyBinding key) {
	ClientRegistry.registerKeyBinding(key);
}

public void bindTileEntitySpecialRenderer(Class<? extends TileEntity> tileentity, TileEntitySpecialRenderer render) {
	ClientRegistry.bindTileEntitySpecialRenderer(tileentity, render);
}

public void registerRender(Class entityClass, Render render) {
	RenderingRegistry.registerEntityRenderingHandler(entityClass, render);
}

public static void addStateMapperToIgnore(Block block, IProperty property) {
	ModelLoader.setCustomStateMapper(block, (new StateMap.Builder()).addPropertiesToIgnore(new IProperty[] { property }).build());
}

// Client Objects\\
@Override
public EntityPlayer getClientPlayer() {
	return FMLClientHandler.instance().getClientPlayerEntity();
}

@Override
public void spawnCrit(World world, Entity entity) {
	FMLClientHandler.instance().getClient().effectRenderer.emitParticleAtEntity(entity, EnumParticleTypes.CRIT);
}

@Override
public void spawnRoar(World world, Entity entity) {
	FMLClientHandler.instance().getClient().effectRenderer.emitParticleAtEntity(entity, EnumParticleTypes.SPELL_WITCH);
	FMLClientHandler.instance().getClient().effectRenderer.emitParticleAtEntity(entity, EnumParticleTypes.CRIT);
}

public static void spawnForisParticle(EntityCustomTameable entity) {
	double d0 = entity.getRNG().nextGaussian() * 0.04D; // TODO
	double d1 = entity.getRNG().nextGaussian() * 0.04D;
	double d2 = entity.getRNG().nextGaussian() * 0.04D;
	EntityForisDustFX var20 = new EntityForisDustFX(entity.worldObj, entity.posX + entity.getRNG().nextFloat() * entity.width * 2.0F - entity.width, entity.posY + 0.5D + entity.getRNG().nextFloat() * entity.height, entity.posZ + entity.getRNG().nextFloat() * entity.width * 2.0F - entity.width, d0, d1, d2);

	for (int i = 0; i < 7; ++i) {
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(var20);
	}
}

public static void spawnIceParticle(Entity entity) {
	EntityIceDustFX var20 = new EntityIceDustFX(entity.worldObj, entity.posX, entity.posY, entity.posZ, 0.0D, 0.0D, 0.0D);
	FMLClientHandler.instance().getClient().effectRenderer.addEffect(var20);
}

public static void spawnDarkParticle(World worldIn, double d0, double d1, double d2, double d3, double d4, double d5) {
	EntityDarkPortalFX entityFX = new EntityDarkPortalFX(worldIn, d0, d1, d2, d3, d4, d5);
	FMLClientHandler.instance().getClient().effectRenderer.addEffect(entityFX);
}
}

 

What I'm trying to do is, and ONLY for the Zertums, add mulitple models for their evolution forms. At first, I had the two forms in one ModelBase class, and now I have 3 forms but in seperate classes since I was told that I can switch ModelBases based on an entity's state

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

  • Replies 78
  • Created
  • Last Reply

Top Posters In This Topic

Posted

You can make one entity class and one render class handle all the entity types and the models.

That would be the main point of 'can switch ModelBases based on an entity's state'.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

The thing is, all of my entities are using different renderers because they have different skins. And yes, I am using a superclass that of the Zertum types are using called EntityZertumEntity

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

The thing is, all of my entities are using different renderers because they have different skins. And yes, I am using a superclass that of the Zertum types are using called EntityZertumEntity

You dont need to make different renderers for them. You can have multiple models for a renderer.

To change model via entity type, change the RenderLivingEntity#mainModel field.

You can store the model you want there to display before rendering.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

What I meant was I had multiple renders for each entity, the renderers all used the same ModelBase. And is it possible to switch the mainModel by the entity state?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

And is it possible to switch the mainModel by the entity state?

That is what he just said you could do, and I have said before.

 

It is really not difficult, but for some reason you just cannot seem to understand the words that we write. Is it because English is not your native language? Is it because you do not understand Java? A combination of the two? Something else altogether?

 

Whatever it is, please stop spamming post after post and actually READ the replies that you have already received. All of the information you need has already been provided - it is now up to you to read, understand, and use that information.

Posted

What I meant was I had multiple renders for each entity, the renderers all used the same ModelBase. And is it possible to switch the mainModel by the entity state?

That is not possible, there should be many model. But you can do it with only one Renderer class.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I looked at what you guys said for a while and begin something like this:

 

package common.zeroquest.client.render.zertum;

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.lwjgl.opengl.GL11;

import common.zeroquest.client.model.ModelZertum2;
import common.zeroquest.client.model.ModelZertumEvo1;
import common.zeroquest.client.render.layers.LayersZertum;
import common.zeroquest.entity.zertum.EntityZertum;
import common.zeroquest.entity.zertum.EntityZertumEntity;
import common.zeroquest.lib.Constants;
import common.zeroquest.util.ResourceReference;

@SideOnly(Side.CLIENT)
public class RenderZertums extends RenderLiving {

public RenderZertums(RenderManager render, ModelBase base, float par1, EntityZertumEntity entity) {

	super(render, base, par1);
	if(entity.hasEvolved()){
		this.mainModel = new ModelZertum2();
	}else if(entity.hasEvolved()){
		this.mainModel = new ModelZertumEvo1();
	}
	//this.addLayer(new LayersZertum(this));
}

public void func_177135_a(EntityZertum entity, double par1, double par2, double par3, float par4, float par5) {
	if (entity.isWolfWet()) {
		float f2 = entity.getBrightness(par5) * entity.getShadingWhileWet(par5);
		GlStateManager.color(f2, f2, f2);
	}

	super.doRender(entity, par1, par2, par3, par4, par5);
}

protected ResourceLocation getEntityTexture(EntityZertum entity) {
	if (!entity.hasEvolved()) {
		if (entity.isTamed()) {
			return ResourceReference.getZTameSkins("");
		}
		else if (entity.isAngry()) {
			return ResourceReference.getZAngrySkins("");
		}
		else if (!entity.isTamed() && !entity.isAngry()) {
			return ResourceReference.getZWildSkins("");
		}
	}
	else if (entity.hasEvolved()) {
		if (entity.isTamed()) {
			return ResourceReference.getZEvoTamekins("");
		}
		else if (!entity.isTamed() && !entity.isAngry()) {
			return ResourceReference.getZEvoWildSkins("");
		}
	}
	return null;
}

@Override
public void doRender(EntityLiving entity, double par1, double par2, double par3, float par4, float par5) {
	this.func_177135_a((EntityZertum) entity, par1, par2, par3, par4, par5);
}

@Override
public void doRender(EntityLivingBase entity, double par1, double par2, double par3, float par4, float par5) {
	this.func_177135_a((EntityZertum) entity, par1, par2, par3, par4, par5);
}

@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
	return this.getEntityTexture((EntityZertum) p_110775_1_);
}

@Override
public void passSpecialRender(EntityLivingBase entityLivingBase, double par1, double par2, double par3) {
	EntityZertum dog = (EntityZertum) entityLivingBase;

	if (!dog.getPetName().isEmpty()) {
		super.passSpecialRender(entityLivingBase, par1, par2, par3);
	}
}

@Override
protected void renderOffsetLivingLabel(Entity entity, double x, double y, double z, String displayName, float scale, double distanceFromPlayer) {
	super.renderOffsetLivingLabel(entity, x, y, z, displayName, scale, distanceFromPlayer);

	EntityZertum dog = (EntityZertum) entity;

	if (distanceFromPlayer < 100.0D) {

		y += this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.016666668F * 0.7F;

		String tip = dog.mode.getMode().getTip();

		String label = String.format("%s[%d]", tip, dog.getZertumHunger());

		if (dog.isPlayerSleeping()) {
			this.renderLivingLabel(dog, label, x, y - 0.5D, z, 64, 0.7F);
		}
		else {
			this.renderLivingLabel(dog, label, x, y, z, 64, 0.7F);
		}
	}

	if (distanceFromPlayer < 100.0D) {
		y += this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.016666668F * 0.5F;

		if (this.renderManager.livingPlayer.isSneaking()) {
			EntityLivingBase owner = dog.getOwnerEntity();
			if (owner != null) {
				this.renderLivingLabel(dog, owner.getDisplayName().getUnformattedText(), x, y, z, 5, 0.5F);
			}
			else {
				this.renderLivingLabel(dog, dog.getOwnerName(), x, y, z, 5, 0.5F);
			}
		}
	}
}

protected void renderLivingLabel(Entity p_147906_1_, String p_147906_2_, double p_147906_3_, double p_147906_5_, double p_147906_7_, int p_147906_9_, float scale) {
	double d3 = p_147906_1_.getDistanceSqToEntity(this.renderManager.livingPlayer);

	if (d3 <= p_147906_9_ * p_147906_9_) {
		FontRenderer fontrenderer = this.getFontRendererFromRenderManager();
		float f1 = 0.016666668F * scale;
		GlStateManager.pushMatrix();
		GlStateManager.translate((float) p_147906_3_ + 0.0F, (float) p_147906_5_ + p_147906_1_.height + 0.5F, (float) p_147906_7_);
		GL11.glNormal3f(0.0F, 1.0F, 0.0F);
		GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
		GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
		GlStateManager.scale(-f1, -f1, f1);
		GlStateManager.disableLighting();
		GlStateManager.depthMask(false);
		GlStateManager.disableDepth();
		GlStateManager.enableBlend();
		GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
		Tessellator tessellator = Tessellator.getInstance();
		WorldRenderer worldrenderer = tessellator.getWorldRenderer();
		byte b0 = 0;

		if (p_147906_2_.equals("deadmau5")) {
			b0 = -10;
		}

		GlStateManager.disableTexture2D();
		worldrenderer.startDrawingQuads();
		int j = fontrenderer.getStringWidth(p_147906_2_) / 2;
		worldrenderer.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
		worldrenderer.addVertex(-j - 1, -1 + b0, 0.0D);
		worldrenderer.addVertex(-j - 1, 8 + b0, 0.0D);
		worldrenderer.addVertex(j + 1, 8 + b0, 0.0D);
		worldrenderer.addVertex(j + 1, -1 + b0, 0.0D);
		tessellator.draw();
		GlStateManager.enableTexture2D();
		fontrenderer.drawString(p_147906_2_, -fontrenderer.getStringWidth(p_147906_2_) / 2, b0, 553648127);
		GlStateManager.enableDepth();
		GlStateManager.depthMask(true);
		fontrenderer.drawString(p_147906_2_, -fontrenderer.getStringWidth(p_147906_2_) / 2, b0, -1);
		GlStateManager.enableLighting();
		GlStateManager.disableBlend();
		GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
		GlStateManager.popMatrix();
	}
}

}

 

Now the question is, should I put the Entity in the constructor or do I just make a new variable like EntityZertum zertum = new EntityZertum(); for the entity to get the state or is there another way to do this?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

What I meant was I had multiple renders for each entity, the renderers all used the same ModelBase. And is it possible to switch the mainModel by the entity state?

That is not possible, there should be many model. But you can do it with only one Renderer class.

 

Wait, I can use the same renderer for multiple models?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Wait, I can use the same renderer for multiple models?

That's what I've been trying to tell you this whole time. Pass or create as many models as you want in your renderer constructor, then in the actual doRender method, switch to whatever model you want based on the entity's current state.

 

E.g.

public class YourRenderClass extends RenderLiving {
private final ModelBase model1, model2, model3;
public YourRenderClass(whatever arguments you want) {
super(whatever arguments are needed);
model1 = arg1; // assign from the arguments
model2 = new ModelWhatever(); // or create new ones directly
}

public void doRender(EntityLiving entity, other arguments) {
int state = ((YourEntity) entity).getState();
if (state == 1) {
this.mainModel = model1;
} else {
this.mainModel = model2.
}
super.doRender(args);
}

That's all there is to it, at its most fundamental level.

Posted

What I meant was I had multiple renders for each entity, the renderers all used the same ModelBase. And is it possible to switch the mainModel by the entity state?

That is not possible, there should be many model. But you can do it with only one Renderer class.

 

Wait, I can use the same renderer for multiple models?

Yes, and you can't have one model render multiple shapes, as far as I know.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

*Facepalm* I misread myself.. I meant to say was this: "You can use the same renderer for multiple entities?" And I didn't realize you can have multiple fields like "private final ModelBase model1, model2, model3;"

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Oh, and I got a question, Minecraft has 4 methods that use the same datawatcher but do two different things: its the and angry methods that vanilla wolves use. I'm not sure how Minecraft is doing these but I have something like this

 

	public boolean hasEvolved() // TODO
{
	return (this.dataWatcher.getWatchableObjectByte(DataValues.evolve) & 1) != 0;
}

public boolean isFinalStage() {
	return (this.dataWatcher.getWatchableObjectByte(DataValues.evolve) & 2) != 0;
}

public void setFinalStage(boolean finalStage) {
	byte b0 = this.dataWatcher.getWatchableObjectByte(DataValues.evolve);

	if (finalStage) {
		this.dataWatcher.updateObject(DataValues.evolve, Byte.valueOf((byte) (b0 | 2)));
	}
	else {
		this.dataWatcher.updateObject(DataValues.evolve, Byte.valueOf((byte) (b0 & -3)));
	}
}

public void setEvolved(boolean evolved) {
	byte b0 = this.dataWatcher.getWatchableObjectByte(DataValues.evolve);

	if (evolved) {
		this.dataWatcher.updateObject(DataValues.evolve, Byte.valueOf((byte) (b0 | 1)));
	}
	else {
		this.dataWatcher.updateObject(DataValues.evolve, Byte.valueOf((byte) (b0 & -5)));
	}

	if (evolved) {
		if (!this.isChild() && !this.hasEvolved()) {
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.tamedHealth() + this.effectiveLevel());
			this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(this.tamedDamage());
		}
		else if (!this.isChild() && this.hasEvolved()) {
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.evoHealth());
		}
		else {
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.babyHealth());
			this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(this.babyDamage());
		}
	}
	else {
		if (this.isChild()) {
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.babyHealth());
			this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(this.babyDamage());
		}
	}
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

What do you mean? Are you using same datawatcher with the vanilla?

Or vanilla uses same datawatcher in 2 different ways?

For latter case, it is possible if the coder is well aware of the effect. There was Union concept, which is similar with this case.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

No, I'm not using the same datawatcher as vanilla and it appears that vanilla uses the same datawatcher in 2 different ways. The code that vanilla uses looks like this

 

/**
* Determines whether this wolf is angry or not.
*/
public boolean isAngry()
{
    return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}

/**
* Sets whether this wolf is angry or not.
*/
public void setAngry(boolean angry)
{
    byte b0 = this.dataWatcher.getWatchableObjectByte(16);

    if (angry)
    {
        this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
    }
    else
    {
        this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
    }
}

public boolean isTamed()
{
    return (this.dataWatcher.getWatchableObjectByte(16) & 4) != 0;
}

public void setTamed(boolean tamed)
{
    byte b0 = this.dataWatcher.getWatchableObjectByte(16);

    if (tamed)
    {
        this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 4)));
    }
    else
    {
        this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -5)));
    }

    this.setupTamedAI();
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Bro/Gurl - learn about bitwise operations.

 

I don't know what vanilla does and I don't care, but yes - it is possible to ship lots of info in just one DataWatcher value.

 

e.g. byte has 8 bits. Each of those can be used as boolean, or combination of booleans.

 

You can even send long in which you can store int, or few shorts and booleans - whatever.

1.7.10 is no longer supported by forge, you are on your own.

Posted

Alrighty, I fixed it after doing some research on what I was doing wrong. And I have I think my final question, how do I extend the entity bounding box on the Z axis?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

I believe you are looking for setSize(float width, float height).

Posted

Alrighty, I fixed it after doing some research on what I was doing wrong. And I have I think my final question, how do I extend the entity bounding box on the Z axis?

There is no way (in Minecraft, without heroic coding skills) to specifically extend the bounding box along one axis only, as bounding boxes are defined by only 2 variables: height, and width, centered around the entity.

 

The width is used for both the x and z axis, making a square, with the height being the y axis turning it into a rectangle. Nothing you can do to make x and z different.

Posted

What about this

this.setEntityBoundingBox(new AxisAlignedBB(x1, y1, z1, x2, y2, z2));

Ok, yes, that technically gives it a rectangle with different x and z, but it won't rotate, which is what I was trying to get at but didn't explain.

 

You end up with a long rectangular bounding box, but when your entity turns, it's now mostly outside of the bounding box because the entity turns, but the box does not, make sense?

Posted

I'm trying to make the sizes switch based on my entity's state, the sizes won't switch for some reason when the creature is evolved

 

		if (!this.inFinalStage()) {
		this.setSize(0.6F, 1.5F);
	}
	else if (this.inFinalStage()) {
		this.setEntityBoundingBox(new AxisAlignedBB(3.0, 3.0, 3.0, 3.0, 3.0, 3.0));
	}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Er... I'm not sure what I did wrong here but I did this

		if (!this.inFinalStage()) {
		this.setEntityBoundingBox(new AxisAlignedBB(0.6, 1.5, 1.5, 0.0, 0.0, 0.0));
		// this.setSize(0.6F, 1.5F);
	}
	else if (this.inFinalStage()) {
		// this.setSize(2F, 4F);
		this.setEntityBoundingBox(new AxisAlignedBB(2.0, 5.0, 5.0, 0.0, 0.0, 0.0));
	}

 

And when I enter the game, it appears that the box is completely gone and the entities are dying from suffocation.

 

Debug

[22:16:27] [Client thread/INFO] [sTDOUT]: [common.zeroquest.entity.zertum.EntityZertumEntity:<init>:126]: box[0.0, 0.0, 0.0 -> 0.6, 1.5, 1.5]
[22:16:27] [Client thread/INFO] [sTDOUT]: [common.zeroquest.entity.zertum.EntityZertumEntity:<init>:126]: box[0.0, 0.0, 0.0 -> 0.6, 1.5, 1.5]
[22:16:27] [Client thread/INFO] [sTDOUT]: [common.zeroquest.entity.zertum.EntityZertumEntity:<init>:126]: box[0.0, 0.0, 0.0 -> 0.6, 1.5, 1.5]
[22:16:27] [Client thread/INFO] [sTDOUT]: [common.zeroquest.entity.zertum.EntityZertumEntity:<init>:126]: box[0.0, 0.0, 0.0 -> 0.6, 1.5, 1.5]
[22:16:27] [Client thread/INFO] [sTDOUT]: [common.zeroquest.entity.zertum.EntityZertumEntity:<init>:126]: box[0.0, 0.0, 0.0 -> 0.6, 1.5, 1.5]
[22:16:27] [Client thread/INFO] [sTDOUT]: [common.zeroquest.entity.zertum.EntityZertumEntity:<init>:126]: box[0.0, 0.0, 0.0 -> 0.6, 1.5, 1.5]
[22:16:31] [Client thread/INFO] [sTDOUT]: [common.zeroquest.entity.zertum.EntityZertumEntity:<init>:126]: box[0.0, 0.0, 0.0 -> 0.6, 1.5, 1.5]
[22:16:31] [Client thread/INFO] [sTDOUT]: [common.zeroquest.entity.zertum.EntityZertumEntity:<init>:126]: box[0.0, 0.0, 0.0 -> 0.6, 1.5, 1.5]

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

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.