Balloons :)

This commit is contained in:
Aidan Brady 2013-12-20 13:27:54 -05:00
parent 0367e62b34
commit 48af6f8fcc
11 changed files with 268 additions and 52 deletions

View file

@ -294,6 +294,7 @@ public class ClientProxy extends CommonProxy
MinecraftForgeClient.registerItemRenderer(Mekanism.PartTransmitter.itemID, handler);
MinecraftForgeClient.registerItemRenderer(Mekanism.GasMask.itemID, handler);
MinecraftForgeClient.registerItemRenderer(Mekanism.ScubaTank.itemID, handler);
MinecraftForgeClient.registerItemRenderer(Mekanism.Balloon.itemID, handler);
//Register block handlers
RenderingRegistry.registerBlockHandler(new MachineRenderingHandler());

View file

@ -1,9 +1,11 @@
package mekanism.client.render.entity;
import mekanism.api.EnumColor;
import mekanism.client.model.ModelBalloon;
import mekanism.common.EntityBalloon;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
@ -16,6 +18,8 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderBalloon extends Render
{
private Minecraft mc = Minecraft.getMinecraft();
public ModelBalloon model = new ModelBalloon();
@Override
@ -29,14 +33,20 @@ public class RenderBalloon extends Render
{
EntityBalloon balloon = (EntityBalloon)entity;
render(((EntityBalloon)entity).color, x, y, z);
}
public void render(EnumColor color, double x, double y, double z)
{
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
GL11.glRotatef(180, 1, 0, 0);
GL11.glTranslatef(0, 0.9F, 0);
bindTexture(getEntityTexture(entity));
model.render(0.0625F, balloon.color);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png"));
model.render(0.0625F, color);
GL11.glPopMatrix();
}

View file

@ -16,6 +16,7 @@ import mekanism.client.model.ModelRobit;
import mekanism.client.model.ModelScubaTank;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.entity.RenderBalloon;
import mekanism.client.render.tileentity.RenderBin;
import mekanism.common.IElectricChest;
import mekanism.common.IEnergyCube;
@ -23,6 +24,7 @@ import mekanism.common.Mekanism;
import mekanism.common.Tier.EnergyCubeTier;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.inventory.InventoryBin;
import mekanism.common.item.ItemBalloon;
import mekanism.common.item.ItemBlockBasic;
import mekanism.common.item.ItemBlockMachine;
import mekanism.common.item.ItemGasMask;
@ -31,7 +33,6 @@ import mekanism.common.item.ItemRobit;
import mekanism.common.item.ItemScubaTank;
import mekanism.common.item.ItemWalkieTalkie;
import mekanism.common.multipart.ItemPartTransmitter;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.block.Block;
@ -43,7 +44,6 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@ -71,7 +71,8 @@ public class ItemRenderingHandler implements IItemRenderer
public ModelGasMask gasMask = new ModelGasMask();
public ModelScubaTank scubaTank = new ModelScubaTank();
public RenderBin binRenderer = (RenderBin)TileEntityRenderer.instance.specialRendererMap.get(TileEntityBin.class);
public RenderBalloon balloonRenderer = new RenderBalloon();
public RenderBin binRenderer = new RenderBin();
private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
@Override
@ -343,6 +344,19 @@ public class ItemRenderingHandler implements IItemRenderer
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png"));
scubaTank.render(0.0625F);
}
else if(item.getItem() instanceof ItemBalloon)
{
if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON)
{
GL11.glScalef(2.5F, 2.5F, 2.5F);
GL11.glTranslatef(0.2F, 0, 0.1F);
GL11.glRotatef(15, -1, 0, 1);
balloonRenderer.render(((ItemBalloon)item.getItem()).getColor(item), 0, 1.9F, 0);
}
else {
balloonRenderer.render(((ItemBalloon)item.getItem()).getColor(item), 0, 1, 0);
}
}
else if(item.getItem() instanceof ItemPartTransmitter)
{
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

View file

@ -1,11 +1,13 @@
package mekanism.common;
import mekanism.api.EnumColor;
import mekanism.api.Object3D;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.particle.EntityReddustFX;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
@ -17,6 +19,7 @@ import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
{
public EnumColor color = EnumColor.DARK_BLUE;
public Object3D latched;
public EntityBalloon(World world)
{
@ -30,15 +33,31 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
motionY = 0.04;
}
public EntityBalloon(World world, double x, double y, double z)
public EntityBalloon(World world, double x, double y, double z, EnumColor c)
{
this(world);
setPosition(x + 0.5F, y + 3F, z + 0.5F);
prevPosX = x;
prevPosY = y;
prevPosZ = z;
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
color = c;
}
public EntityBalloon(World world, Object3D obj, EnumColor c)
{
this(world);
latched = obj;
setPosition(latched.xCoord + 0.5F, latched.yCoord + 3F, latched.zCoord + 0.5F);
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
color = c;
}
@Override
@ -48,55 +67,46 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
prevPosY = posY;
prevPosZ = posZ;
motionY = Math.min(motionY*1.02F, 0.2F);
moveEntity(motionX, motionY, motionZ);
motionX *= 0.98;
motionZ *= 0.98;
if(onGround)
if(posY > 255)
{
motionX *= 0.7;
motionZ *= 0.7;
pop();
return;
}
if(motionY == 0)
if(latched != null && latched.getBlockId(worldObj) == 0)
{
motionY = 0.04;
latched = null;
}
if(latched == null)
{
motionY = Math.min(motionY*1.02F, 0.2F);
moveEntity(motionX, motionY, motionZ);
motionX *= 0.98;
motionZ *= 0.98;
if(onGround)
{
motionX *= 0.7;
motionZ *= 0.7;
}
if(motionY == 0)
{
motionY = 0.04;
}
}
else {
motionX = 0;
motionY = 0;
motionZ = 0;
}
}
@Override
public boolean canBePushed()
{
return true;
}
@Override
public boolean canBeCollidedWith()
private void pop()
{
return !isDead;
}
@Override
protected boolean canTriggerWalking()
{
return false;
}
@Override
protected void entityInit() {}
@Override
protected void readEntityFromNBT(NBTTagCompound nbtTags)
{
color = EnumColor.values()[nbtTags.getInteger("color")];
}
@Override
public boolean hitByEntity(Entity entity)
{
worldObj.playSoundAtEntity(this, "mekanism:etc.Pop", 1, 1);
if(worldObj.isRemote)
@ -115,6 +125,44 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
}
setDead();
}
@Override
public boolean canBePushed()
{
return latched == null;
}
@Override
public boolean canBeCollidedWith()
{
return !isDead && latched == null;
}
@Override
protected boolean canTriggerWalking()
{
return false;
}
@Override
protected void entityInit() {}
@Override
protected void readEntityFromNBT(NBTTagCompound nbtTags)
{
color = EnumColor.values()[nbtTags.getInteger("color")];
if(nbtTags.hasKey("latched"))
{
latched = Object3D.read(nbtTags);
}
}
@Override
public boolean hitByEntity(Entity entity)
{
pop();
return true;
}
@ -122,6 +170,11 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
protected void writeEntityToNBT(NBTTagCompound nbtTags)
{
nbtTags.setInteger("color", color.ordinal());
if(latched != null)
{
latched.write(nbtTags);
}
}
@Override
@ -132,6 +185,18 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
data.writeDouble(posZ);
data.writeInt(color.ordinal());
if(latched != null)
{
data.writeBoolean(true);
data.writeInt(latched.xCoord);
data.writeInt(latched.yCoord);
data.writeInt(latched.zCoord);
}
else {
data.writeBoolean(false);
}
}
@Override
@ -140,5 +205,25 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
setPosition(data.readDouble(), data.readDouble(), data.readDouble());
color = EnumColor.values()[data.readInt()];
if(data.readBoolean())
{
latched = new Object3D(data.readInt(), data.readInt(), data.readInt());
}
else {
latched = null;
}
}
@Override
public boolean isInRangeToRenderDist(double dist)
{
return dist <= 64;
}
@Override
public boolean isInRangeToRenderVec3D(Vec3 par1Vec3)
{
return true;
}
}

View file

@ -42,6 +42,7 @@ import mekanism.common.block.BlockObsidianTNT;
import mekanism.common.block.BlockOre;
import mekanism.common.block.BlockTransmitter;
import mekanism.common.item.ItemAtomicDisassembler;
import mekanism.common.item.ItemBalloon;
import mekanism.common.item.ItemBlockBasic;
import mekanism.common.item.ItemBlockEnergyCube;
import mekanism.common.item.ItemBlockGasTank;
@ -225,6 +226,7 @@ public class Mekanism
public static ItemScubaTank ScubaTank;
public static ItemGasMask GasMask;
public static Item Dictionary;
public static Item Balloon;
//Blocks
public static Block BasicBlock;
@ -641,6 +643,7 @@ public class Mekanism
Jetpack = (ItemJetpack)new ItemJetpack(configuration.getItem("Jetpack", 11223).getInt()).setUnlocalizedName("Jetpack");
WalkieTalkie = new ItemWalkieTalkie(configuration.getItem("WalkieTalkie", 11224).getInt()).setUnlocalizedName("WalkieTalkie");
PartTransmitter = new ItemPartTransmitter(configuration.getItem("MultipartTransmitter", 11225).getInt()).setUnlocalizedName("MultipartTransmitter");
Balloon = new ItemBalloon(configuration.getItem("Balloon", 11226).getInt()).setUnlocalizedName("Balloon");
configuration.save();
//TODO 1.7, fix item shifts
@ -670,6 +673,7 @@ public class Mekanism
GameRegistry.registerItem(Dictionary, "Dictionary");
GameRegistry.registerItem(GasMask, "GasMask");
GameRegistry.registerItem(ScubaTank, "ScubaTank");
GameRegistry.registerItem(Balloon, "Balloon");
}
/**

View file

@ -0,0 +1,82 @@
package mekanism.common.item;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.Object3D;
import mekanism.common.EntityBalloon;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBalloon extends ItemMekanism
{
public ItemBalloon(int id)
{
super(id);
setHasSubtypes(true);
}
public EnumColor getColor(ItemStack stack)
{
return EnumColor.values()[stack.getItemDamage()];
}
@Override
public void getSubItems(int i, CreativeTabs tabs, List list)
{
for(EnumColor color : EnumColor.values())
{
ItemStack stack = new ItemStack(this);
stack.setItemDamage(color.ordinal());
list.add(stack);
}
}
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
if(!world.isRemote)
{
Vector3 vec = new Vector3();
vec.z += 0.3;
vec.x -= 0.4;
vec.rotate(entityplayer.renderYawOffset);
vec.translate(new Vector3(entityplayer));
world.spawnEntityInWorld(new EntityBalloon(world, vec.x-0.5, vec.y-0.25, vec.z-0.5, getColor(itemstack)));
}
itemstack.stackSize--;
return itemstack;
}
@Override
public String getItemDisplayName(ItemStack stack)
{
return getColor(stack).getName() + " Balloon";
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
if(!world.isRemote)
{
world.spawnEntityInWorld(new EntityBalloon(world, new Object3D(x, y, z), getColor(stack)));
}
stack.stackSize--;
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister register) {}
}

View file

@ -63,7 +63,7 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
{
if(!world.isRemote)
{
world.spawnEntityInWorld(new EntityBalloon(world, x, y, z));
world.spawnEntityInWorld(new EntityBalloon(world, x, y, z, EnumColor.RED));
TileEntity tile = world.getBlockTileEntity(x, y, z);

View file

@ -4,6 +4,7 @@ import mekanism.client.render.ModelCustomArmor;
import mekanism.client.render.ModelCustomArmor.ArmorModel;
import mekanism.common.Mekanism;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemArmor;
@ -24,6 +25,10 @@ public class ItemGasMask extends ItemArmor
MinecraftForge.EVENT_BUS.register(this);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister register) {}
@Override
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
{

View file

@ -12,6 +12,7 @@ import mekanism.client.render.ModelCustomArmor.ArmorModel;
import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@ -36,6 +37,10 @@ public class ItemJetpack extends ItemArmor implements IGasItem
setNoRepair();
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister register) {}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{

View file

@ -11,6 +11,7 @@ import mekanism.client.render.ModelCustomArmor;
import mekanism.client.render.ModelCustomArmor.ArmorModel;
import mekanism.common.Mekanism;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@ -229,4 +230,8 @@ public class ItemScubaTank extends ItemArmor implements IGasItem
setGas(filled, new GasStack(GasRegistry.getGas("oxygen"), ((IGasItem)filled.getItem()).getMaxGas(filled)));
list.add(filled);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister register) {}
}

View file

@ -9,6 +9,7 @@ import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.ITransmitterNetwork;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -33,6 +34,10 @@ public class ItemPartTransmitter extends JItemMultiPart
setHasSubtypes(true);
setCreativeTab(Mekanism.tabMekanism);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister register) {}
@Override
public TMultiPart newPart(ItemStack stack, EntityPlayer player, World world, BlockCoord coord, int face, Vector3 vecHit)
@ -131,6 +136,6 @@ public class ItemPartTransmitter extends JItemMultiPart
@Override
public String getUnlocalizedName(ItemStack stack)
{
return getUnlocalizedName()+"."+TransmissionType.values()[stack.getItemDamage()].name().toLowerCase();
return getUnlocalizedName() + "." + TransmissionType.values()[stack.getItemDamage()].name().toLowerCase();
}
}