Jump to content

Issue with saving float in TileEntity


wog890

Recommended Posts

I have been using Universal Electricity to create an axle network to be able to use for things such as gates. I've been working on making the axles visually spin. The rotation of the axle is decided in updateEntity() off of the current rotation and the current RPS (revolutions per second). This seems to be working fine when I run debug in updateEntity(), but when I debug in the axle's renderer, it always shows rotation as 0.

 

Does anyone have any idea what might be wrong or how to fix it. I'm kinda blanking on this one. Below is the code for TileEntityAxle, which is what all axles extend and contains that code, and the renderer for the wooden axle.

 

 

 

 

package woggatemod.prefab.tile;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.network.INetworkManager;

import net.minecraft.network.packet.Packet;

import net.minecraft.network.packet.Packet250CustomPayload;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.AxisAlignedBB;

import net.minecraftforge.common.ForgeDirection;

import org.bouncycastle.util.Arrays;

import universalelectricity.core.vector.Vector3;

import universalelectricity.prefab.network.IPacketReceiver;

import universalelectricity.prefab.network.PacketManager;

import universalelectricity.prefab.tile.TileEntityAdvanced;

import woggatemod.core.block.IAxle;

import woggatemod.core.block.IKineticNetworkProvider;

import woggatemod.core.block.IWogConnector;

import woggatemod.core.kineticenergy.IKineticNetwork;

import woggatemod.core.kineticenergy.KineticNetwork;

import woggatemod.core.vector.WogVectorHelper;

 

import com.google.common.io.ByteArrayDataInput;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public abstract class TileEntityAxle extends TileEntityAdvanced implements IAxle, IPacketReceiver {

 

private IKineticNetwork network;

 

/**

* Used client side to render.

*/

public boolean[] visuallyConnected = {false, false, false, false, false, false};

 

public TileEntity[] connectedBlocks = {null, null, null, null, null, null};

 

protected String channel = "";

 

protected float rotation = 0;

protected double rps = 1;

 

public void updateConnection(TileEntity tile, ForgeDirection side) {

if (!worldObj.isRemote) {

if (tile instanceof IWogConnector) {

if (canConnectOnSide(side)) {

if (((IWogConnector) tile).canConnectWog(side.getOpposite())) {

connectedBlocks[side.ordinal()] = tile;

visuallyConnected[side.ordinal()] = true;

 

if (tile.getClass() == getClass() && tile instanceof IKineticNetworkProvider) {

getNetwork().mergeConnection(((IKineticNetworkProvider) tile).getNetwork());

}

 

return;

}

}

}

 

if (connectedBlocks[side.ordinal()] != null) {

// TODO - add functions here. Check tileEntityConductor

}

 

connectedBlocks[side.ordinal()] = null;

visuallyConnected[side.ordinal()] = false;

}

}

 

@Override

public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) {

if (worldObj.isRemote) {

visuallyConnected[0] = dataStream.readBoolean();

visuallyConnected[1] = dataStream.readBoolean();

visuallyConnected[2] = dataStream.readBoolean();

visuallyConnected[3] = dataStream.readBoolean();

visuallyConnected[4] = dataStream.readBoolean();

visuallyConnected[5] = dataStream.readBoolean();

rotation = dataStream.readFloat();

}

}

 

@Override

public void initiate() {

updateAdjacentWogConnections();

}

 

@Override

public void invalidate() {

if (!worldObj.isRemote) {

getNetwork().splitNetwork(this);

}

super.invalidate();

}

 

@Override

public void updateEntity() {

super.updateEntity();

 

if (!worldObj.isRemote) {

if (ticks % 8 == 0) {

updateAdjacentWogConnections();

}

 

if (getRPS() > 0) {

float addedRotation = (float) (360.0F * getRPS()) / 4;

setRotation(rotation + addedRotation);

}

 

if (getRotation() > 359) {

setRotation(rotation % 360);

}

}

}

 

@Override

public void updateAdjacentWogConnections() {

if (worldObj != null) {

if (!worldObj.isRemote) {

boolean[] previousConnections = visuallyConnected.clone();

 

for (byte i = 0; i < 6; i++) {

updateConnection(WogVectorHelper.getConnectorFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(i)), ForgeDirection.getOrientation(i));

}

 

if (!Arrays.areEqual(previousConnections, visuallyConnected)) {

worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);

}

}

}

}

 

@Override

public Packet getDescriptionPacket() {

return PacketManager.getPacket(channel, this, visuallyConnected[0], visuallyConnected[1], visuallyConnected[2], visuallyConnected[3], visuallyConnected[4], visuallyConnected[5], rotation);

}

 

@Override

public IKineticNetwork getNetwork() {

if (network == null) {

setNetwork(new KineticNetwork(this));

}

 

return network;

}

 

@Override

public void setNetwork(IKineticNetwork network) {

this.network = network;

}

 

@Override

public TileEntity[] getAdjacentWogConnections() {

return connectedBlocks;

}

 

@Override

public boolean canConnectWog(ForgeDirection side) {

return true;

}

 

@Override

@SideOnly(Side.CLIENT)

public AxisAlignedBB getRenderBoundingBox() {

return AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);

}

 

public int getTotalConnections() {

int connections = 0;

for (int i = 0; i < visuallyConnected.length; i++) {

connections += visuallyConnected ? 1 : 0;

}

return connections;

}

 

public int getFirstConnection() {

for (int i = 0; i < visuallyConnected.length; i++) {

if (visuallyConnected) {

return i;

}

}

return -1;

}

 

public boolean canConnectOnSide(ForgeDirection side) {

return false;

}

 

public long getTicks() {

return ticks;

}

 

@Override

public float getRotation() {

return rotation;

}

 

@Override

public void setRotation(float rotate) {

rotation = rotate;

}

 

@Override

public double getRPS() {

return rps;

}

 

}

 

 

 

 

 

 

 

package woggatemod.components.client;

 

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

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.tileentity.TileEntity;

import org.lwjgl.opengl.GL11;

import woggatemod.components.common.WogComponents;

import woggatemod.components.common.tileentity.TileEntityWoodAxle;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

@SideOnly(Side.CLIENT)

public class RenderWoodAxle extends TileEntitySpecialRenderer {

 

private ModelWoodAxle model;

 

private long prevTick, tick = 0;

 

public RenderWoodAxle() {

model = new ModelWoodAxle();

}

 

public void renderAModelAt(TileEntityWoodAxle tile, double d, double d1, double d2, float f) {

bindTextureByName(WogComponents.MODEL_TEXTURE_DIRECTORY + "woodAxle.png");

GL11.glPushMatrix();

GL11.glTranslatef((float) d + 0.5F, (float) d1 - 0.5F, (float) d2 + 0.5F);

 

if (tile.visuallyConnected[0]) {

model.renderBottom();

}

 

if (tile.visuallyConnected[1]) {

model.renderTop();

}

 

if (tile.visuallyConnected[2]) {

model.renderFront();

}

 

if (tile.visuallyConnected[3]) {

model.renderBack();

}

 

if (tile.visuallyConnected[4]) {

model.renderLeft();

}

 

if (tile.visuallyConnected[5]) {

model.renderRight();

}

 

model.renderMiddle();

 

if (tile.getTotalConnections() > 0) {

 

int side = tile.getFirstConnection();

float rotateX = 0.0F, rotateY = 0.0F, rotateZ = 0.0F;

 

if (side == 0 || side == 1) {

rotateY = 1.0F;

}

else if (side == 2 || side == 3) {

rotateZ = 1.0F;

}

else {

rotateX = 1.0F;

}

 

float rotation = tile.getRotation();

 

GL11.glRotatef(rotation, rotateX, rotateY, rotateZ);

}

 

GL11.glPopMatrix();

}

 

@Override

public void renderTileEntityAt(TileEntity tile, double d, double d1, double d2, float f) {

renderAModelAt((TileEntityWoodAxle) tile, d, d1, d2, f);

}

 

}

 

 

 

Link to comment
Share on other sites

What value does rotate get at this line during debugg?

        float rotation = tile.getRotation();

 

Also all the renderAt methods ask for the TE as input, where do you call this from? During debug, what is the value for rotation inn the passed inn TE?

 

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

What value does rotate get at this line during debugg?

        float rotation = tile.getRotation();

 

Also all the renderAt methods ask for the TE as input, where do you call this from? During debug, what is the value for rotation inn the passed inn TE?

 

float rotation = tile.getRotation() always comes out to 0. I have checked at the actual tile entity in debug though and it seems to be calculating it fine.

 

I don't know where the tile entity is being passed for the renderAt method. I guess I always assumed it was fine since the visually connected part always works fine. I'm going to run a quick check to see if the tile entity being passed in the renderer is the tile entity for the axle.

 

I believe if I check the id of the tile entity it should match the id of the one in the renderer. I'll post back in just a second.

 

Update - The id's do not match, one is 63 the other is 109. This could be because I'm casting it though, I'm not sure.

 

Also, thank you for the help.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • java.lang.RuntimeException:null at net.minecraftforge.registries.GameData.postRegisterEvents(GameData.java:315) ~[forge-1.20.1-47.3.10-universal.jar%23329!/:?] {re:mixin,re:classloading,pl:mixin:APP:supermartijn642corelib.mixins.json:GameDataMixin,pl:mixin:A}at net.minecraftforge.common.ForgeStatesProvider.lambda$new$4(ForgeStatesProvider.java:25) ~[forge-1.20.1-47.3.10-universal.jar%23329!/:?] {re:classloading}at net.minecraftforge.fml.ModLoader.handleInlineTransition(ModLoader.java:217) ~[fmlcore-1.20.1-47.3.10.jar%23325!/:?] {}at net.minecraftforge.fml.ModLoader.lambda$dispatchAndHandleError$19(ModLoader.java:209) ~[fmlcore-1.20.1-47.3.10.jar%23325!/:?] {}at java.util.Optional.ifPresent(Optional.java:178) ~[?:?] {re:mixin}at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:209) ~[fmlcore-1.20.1-47.3.10.jar%23325!/:?] {}at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$13(ModLoader.java:183) ~[fmlcore-1.20.1-47.3.10.jar%23325!/:?] {}at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:mixin}at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:183) ~[fmlcore-1.20.1-47.3.10.jar%23325!/:?] {}at net.minecraftforge.client.loading.ClientModLoader.lambda$begin$1(ClientModLoader.java:69) ~[forge-1.20.1-47.3.10-universal.jar%23329!/:?] {re:classloading,pl:runtimedistcleaner:A}at net.minecraftforge.client.loading.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:89) ~[forge-1.20.1-47.3.10-universal.jar%23329!/:?] {re:classloading,pl:runtimedistcleaner:A}at net.minecraftforge.client.loading.ClientModLoader.begin(ClientModLoader.java:69) ~[forge-1.20.1-47.3.10-universal.jar%23329!/:?] {re:classloading,pl:runtimedistcleaner:A}at net.minecraft.client.Minecraft.                Size    Insert image from URL
    • My Bitcoin Recovery Experience With  The Hack Angels.     I highly recommend the service of The Hack Angels to everyone who wishes to recover lost money either bitcoin or other cryptocurrencies from these online scammers, wallet hackers, or if you ever sent bitcoins to the wrong wallet address. I was able to recover my lost bitcoins from online swindlers in less than two days after contacting them. They are the best professional hackers out there and I’m truly thankful for their help in recovering all I lost. If you need their service too, here is their contact information.   Mail Box; support@thehackangels. com    (Web: https://thehackangels.com) Whats Ap; +1 520) - 200, 23  20
    • Temu Coupon Code $50 off [taa85211] or [tad85211] for New and Existing Users To get Temu $50 off Coupon Code [taa85211] or [tad85211] as a new user enter the Coupon during checkout when making your first purchase at Temu You will receive the benefit once the Coupon applied. TEMU App is a shopping platform that provides us with the best-branded items at Cheap prices. You will also notice that TEMU offers users to save extra by applying the TEMU Coupon Code during checkout. You can get $50 off Temu by using the Coupon Code “taa85211} or {tad85211} ”. Existing customers can use this code. Temu existing user Coupon Code: [taa85211} or {tad85211} Using Temu’s Coupon Code [taa85211} or {tad85211] will get you $50 off, access to exclusive deals, and benefits for additional savings. Save $50 off with Temu Coupon Codes. New and existing customer offers. What is Temu $50 Coupon Bundle? New Temu $50 Coupon bundle includes $50 worth of Temu Coupon Codes. The Temu $50 Coupon Code [taa85211} or {tad85211] can be used by new and existing Temu users to get a Coupon on their purchases. Temu $50 Coupon Bundle Code [taa85211} or {tad85211] Temu Coupon $50 off for existing customers There are a number of Coupons and deals shoppers can take advantage of with the Teemu Coupon Bundle [taa85211} or {tad85211]. Temu Coupon $50 off for existing customers"taa85211} or {tad85211" will save you $100 on your order. To get a Coupon, click on the item to purchase and enter the code. You can think of it as a supercharged savings pack for all your shopping needs Temu Coupon Code $50 off free shipping You will save $50 when you use Temu’s $50 OFF Coupon Code [taa85211} or {tad85211]. Enter the Coupon Code when purchasing an item How Does Temu $50 Coupon Work Temu’s $50 Coupon Code isn’t just one big Coupon you use all at once. Instead, think of it as a welcome package filled with different Coupons and offers worth $50. New customers are welcome. Temu Coupon Code $50 off Temu $40 OFF Coupon Code “taa85211} or {tad85211” will save you $50 on your order. To get a Coupon, click on the item to purchase and enter the code. Yes, Temu offers $50 off Coupon Code “taa85211} or {tad85211” for first time users. You can get a $50 bonus plus 30% off any purchase at Temu with the $40 Coupon Bundle at Temu if you sign up with the Coupon Code [taa85211} or {tad85211] and make a first purchase of $50 or more. How Do Apply Temu Coupon Code [taa85211} or {tad85211]? 1.Download the TEMU app and create a new account. 2.Fill in basic details to complete account verification. 3. Select the item you want to purchase and add it to your cart Minimum of $100. 4.Click on the Coupon Code option and enter the TEMU Coupon Code. 5.Once the Coupon has been applied, you will see the final Coupon. 6.P rice Select your payment method and complete your purchase. Temu Coupon Code $50 off first time user yes, If you’re a first-time user, Temu offers $50 off with Coupon Code “taa85211} or {tad85211” Temu offers first-time users a $50 Coupon. Here are some Temu Coupons! The fact that new users can benefit from such generous Coupons is great. How do you redeem Temu $50 Coupon Code? Yes, To redeem the Temu $50 Coupon Code, follow these steps: 1.Sign Up: If you haven’t already, sign up for a Temu account on their website or app. 2.Add Items to Cart: Browse through the products you’d like to purchase. Add items worth $50 or more to your cart. 3.Apply Coupon Code: During checkout, enter the Coupon Code “taa85211} or {tad85211” in the designated field. This will unlock the $50 Coupon bundle. You can also use the Coupon Code “taa85211} or {tad85211” when signing up to receive the same benefit. 4.Enjoy Savings: The Coupon will be applied, and you’ll enjoy additional savings on your purchase. Plus, you can combine this with other available Coupons, such as the 50% off code for fashion, home, and beauty categories.
    • Temu Coupon Code $50 off [taa85211] or [tad85211] for New and Existing Users To get Temu $50 off Coupon Code [taa85211] or [tad85211] as a new user enter the Coupon during checkout when making your first purchase at Temu You will receive the benefit once the Coupon applied. TEMU App is a shopping platform that provides us with the best-branded items at Cheap prices. You will also notice that TEMU offers users to save extra by applying the TEMU Coupon Code during checkout. You can get $50 off Temu by using the Coupon Code “taa85211} or {tad85211} ”. Existing customers can use this code. Temu existing user Coupon Code: [taa85211} or {tad85211} Using Temu’s Coupon Code [taa85211} or {tad85211] will get you $50 off, access to exclusive deals, and benefits for additional savings. Save $50 off with Temu Coupon Codes. New and existing customer offers. What is Temu $50 Coupon Bundle? New Temu $50 Coupon bundle includes $50 worth of Temu Coupon Codes. The Temu $50 Coupon Code [taa85211} or {tad85211] can be used by new and existing Temu users to get a Coupon on their purchases. Temu $50 Coupon Bundle Code [taa85211} or {tad85211] Temu Coupon $50 off for existing customers There are a number of Coupons and deals shoppers can take advantage of with the Teemu Coupon Bundle [taa85211} or {tad85211]. Temu Coupon $50 off for existing customers"taa85211} or {tad85211" will save you $100 on your order. To get a Coupon, click on the item to purchase and enter the code. You can think of it as a supercharged savings pack for all your shopping needs Temu Coupon Code $50 off free shipping You will save $50 when you use Temu’s $50 OFF Coupon Code [taa85211} or {tad85211]. Enter the Coupon Code when purchasing an item How Does Temu $50 Coupon Work Temu’s $50 Coupon Code isn’t just one big Coupon you use all at once. Instead, think of it as a welcome package filled with different Coupons and offers worth $50. New customers are welcome. Temu Coupon Code $50 off Temu $40 OFF Coupon Code “taa85211} or {tad85211” will save you $50 on your order. To get a Coupon, click on the item to purchase and enter the code. Yes, Temu offers $50 off Coupon Code “taa85211} or {tad85211” for first time users. You can get a $50 bonus plus 30% off any purchase at Temu with the $40 Coupon Bundle at Temu if you sign up with the Coupon Code [taa85211} or {tad85211] and make a first purchase of $50 or more. How Do Apply Temu Coupon Code [taa85211} or {tad85211]? 1.Download the TEMU app and create a new account. 2.Fill in basic details to complete account verification. 3. Select the item you want to purchase and add it to your cart Minimum of $100. 4.Click on the Coupon Code option and enter the TEMU Coupon Code. 5.Once the Coupon has been applied, you will see the final Coupon. 6.P rice Select your payment method and complete your purchase. Temu Coupon Code $50 off first time user yes, If you’re a first-time user, Temu offers $50 off with Coupon Code “taa85211} or {tad85211” Temu offers first-time users a $50 Coupon. Here are some Temu Coupons! The fact that new users can benefit from such generous Coupons is great. How do you redeem Temu $50 Coupon Code? Yes, To redeem the Temu $50 Coupon Code, follow these steps: 1.Sign Up: If you haven’t already, sign up for a Temu account on their website or app. 2.Add Items to Cart: Browse through the products you’d like to purchase. Add items worth $50 or more to your cart. 3.Apply Coupon Code: During checkout, enter the Coupon Code “taa85211} or {tad85211” in the designated field. This will unlock the $50 Coupon bundle. You can also use the Coupon Code “taa85211} or {tad85211” when signing up to receive the same benefit. 4.Enjoy Savings: The Coupon will be applied, and you’ll enjoy additional savings on your purchase. Plus, you can combine this with other available Coupons, such as the 50% off code for fashion, home, and beauty categories.
    • Temu Coupon Code $50 off [taa85211] or [tad85211] for New and Existing Users To get Temu $50 off Coupon Code [taa85211] or [tad85211] as a new user enter the Coupon during checkout when making your first purchase at Temu You will receive the benefit once the Coupon applied. TEMU App is a shopping platform that provides us with the best-branded items at Cheap prices. You will also notice that TEMU offers users to save extra by applying the TEMU Coupon Code during checkout. You can get $50 off Temu by using the Coupon Code “taa85211} or {tad85211} ”. Existing customers can use this code. Temu existing user Coupon Code: [taa85211} or {tad85211} Using Temu’s Coupon Code [taa85211} or {tad85211] will get you $50 off, access to exclusive deals, and benefits for additional savings. Save $50 off with Temu Coupon Codes. New and existing customer offers. What is Temu $50 Coupon Bundle? New Temu $50 Coupon bundle includes $50 worth of Temu Coupon Codes. The Temu $50 Coupon Code [taa85211} or {tad85211] can be used by new and existing Temu users to get a Coupon on their purchases. Temu $50 Coupon Bundle Code [taa85211} or {tad85211] Temu Coupon $50 off for existing customers There are a number of Coupons and deals shoppers can take advantage of with the Teemu Coupon Bundle [taa85211} or {tad85211]. Temu Coupon $50 off for existing customers"taa85211} or {tad85211" will save you $100 on your order. To get a Coupon, click on the item to purchase and enter the code. You can think of it as a supercharged savings pack for all your shopping needs Temu Coupon Code $50 off free shipping You will save $50 when you use Temu’s $50 OFF Coupon Code [taa85211} or {tad85211]. Enter the Coupon Code when purchasing an item How Does Temu $50 Coupon Work Temu’s $50 Coupon Code isn’t just one big Coupon you use all at once. Instead, think of it as a welcome package filled with different Coupons and offers worth $50. New customers are welcome. Temu Coupon Code $50 off Temu $40 OFF Coupon Code “taa85211} or {tad85211” will save you $50 on your order. To get a Coupon, click on the item to purchase and enter the code. Yes, Temu offers $50 off Coupon Code “taa85211} or {tad85211” for first time users. You can get a $50 bonus plus 30% off any purchase at Temu with the $40 Coupon Bundle at Temu if you sign up with the Coupon Code [taa85211} or {tad85211] and make a first purchase of $50 or more. How Do Apply Temu Coupon Code [taa85211} or {tad85211]? 1.Download the TEMU app and create a new account. 2.Fill in basic details to complete account verification. 3. Select the item you want to purchase and add it to your cart Minimum of $100. 4.Click on the Coupon Code option and enter the TEMU Coupon Code. 5.Once the Coupon has been applied, you will see the final Coupon. 6.P rice Select your payment method and complete your purchase. Temu Coupon Code $50 off first time user yes, If you’re a first-time user, Temu offers $50 off with Coupon Code “taa85211} or {tad85211” Temu offers first-time users a $50 Coupon. Here are some Temu Coupons! The fact that new users can benefit from such generous Coupons is great. How do you redeem Temu $50 Coupon Code? Yes, To redeem the Temu $50 Coupon Code, follow these steps: 1.Sign Up: If you haven’t already, sign up for a Temu account on their website or app. 2.Add Items to Cart: Browse through the products you’d like to purchase. Add items worth $50 or more to your cart. 3.Apply Coupon Code: During checkout, enter the Coupon Code “taa85211} or {tad85211” in the designated field. This will unlock the $50 Coupon bundle. You can also use the Coupon Code “taa85211} or {tad85211” when signing up to receive the same benefit. 4.Enjoy Savings: The Coupon will be applied, and you’ll enjoy additional savings on your purchase. Plus, you can combine this with other available Coupons, such as the 50% off code for fashion, home, and beauty categories.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.