mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
96 lines
2.3 KiB
Java
96 lines
2.3 KiB
Java
package com.hbm.render.util;
|
|
|
|
import com.hbm.handler.MissileStruct;
|
|
import com.hbm.items.weapon.ItemMissile.PartType;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import io.netty.buffer.ByteBuf;
|
|
import net.minecraft.item.Item;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public class MissileMultipart {
|
|
|
|
public MissilePart warhead;
|
|
public MissilePart fuselage;
|
|
public MissilePart fins;
|
|
public MissilePart thruster;
|
|
|
|
public double getHeight() {
|
|
|
|
double height = 0;
|
|
|
|
if(warhead != null && warhead.type == PartType.WARHEAD)
|
|
height += warhead.height;
|
|
if(fuselage != null && fuselage.type == PartType.FUSELAGE)
|
|
height += fuselage.height;
|
|
if(thruster != null && thruster.type == PartType.THRUSTER)
|
|
height += thruster.height;
|
|
|
|
return height;
|
|
}
|
|
|
|
public static MissileMultipart loadFromStruct(MissileStruct struct) {
|
|
|
|
if(struct == null)
|
|
return null;
|
|
|
|
MissileMultipart multipart = new MissileMultipart();
|
|
|
|
multipart.warhead = MissilePart.getPart(struct.warhead);
|
|
multipart.fuselage = MissilePart.getPart(struct.fuselage);
|
|
multipart.fins = MissilePart.getPart(struct.fins);
|
|
multipart.thruster = MissilePart.getPart(struct.thruster);
|
|
|
|
return multipart;
|
|
}
|
|
|
|
/*public void writeToByteBuffer(ByteBuf buf) {
|
|
|
|
|
|
if(warhead != null && warhead.type == PartType.WARHEAD)
|
|
buf.writeInt(Item.getIdFromItem(warhead.part));
|
|
else
|
|
buf.writeInt(0);
|
|
|
|
if(fuselage != null && fuselage.type == PartType.FUSELAGE)
|
|
buf.writeInt(Item.getIdFromItem(fuselage.part));
|
|
else
|
|
buf.writeInt(0);
|
|
|
|
if(fins != null && fins.type == PartType.FINS)
|
|
buf.writeInt(Item.getIdFromItem(fins.part));
|
|
else
|
|
buf.writeInt(0);
|
|
|
|
if(thruster != null && thruster.type == PartType.THRUSTER)
|
|
buf.writeInt(Item.getIdFromItem(thruster.part));
|
|
else
|
|
buf.writeInt(0);
|
|
}
|
|
|
|
public static MissileMultipart readFromByteBuffer(ByteBuf buf) {
|
|
|
|
MissileMultipart multipart = new MissileMultipart();
|
|
|
|
int w = buf.readInt();
|
|
int f = buf.readInt();
|
|
int s = buf.readInt();
|
|
int t = buf.readInt();
|
|
|
|
if(w != 0)
|
|
multipart.warhead = MissilePart.getPart(Item.getItemById(w));
|
|
|
|
if(f != 0)
|
|
multipart.fuselage = MissilePart.getPart(Item.getItemById(f));
|
|
|
|
if(s != 0)
|
|
multipart.fins = MissilePart.getPart(Item.getItemById(s));
|
|
|
|
if(t != 0)
|
|
multipart.thruster = MissilePart.getPart(Item.getItemById(t));
|
|
|
|
return multipart;
|
|
}*/
|
|
}
|