Так-что Начну я...
Предлагаю это добавить на Farm и Prometeus
mod_test
package net.minecraft.src;
import java.io.*;
import java.util.Map;
import java.util.Scanner;
import net.minecraft.client.Minecraft;
class mod_test extends BaseMod
{
public static int IDs[] =
{
151, 150, 149
};
public static Item car;
public static Item wheel;
public static Item engine;
public static boolean canCarDriveInWater = false;
public mod_test()
{
}
public String getVersion()
{
return "1.2.5";
}
public void addRenderer(Map map)
{
map.put(net.minecraft.src.EntityBasicCar.class, new RenderCar());
}
public void load()
{
try
{
FileWriter filewriter = null;
File file = new File((new StringBuilder()).append(ModLoader.getMinecraftInstance().getMinecraftDir().getPath()).append("/Car.txt").toString());
System.out.println(file.getAbsolutePath());
if (!file.exists())
{
file.createNewFile();
try
{
filewriter = new FileWriter(file);
filewriter.write("CanCarDriveInWater false carID 150 \n wheelID 149 \n engine ID 148");
}
finally
{
if (filewriter != null)
{
filewriter.close();
}
}
}
Scanner scanner = new Scanner(file);
scanner.next();
canCarDriveInWater = scanner.nextBoolean();
for (int i = 0; i ‹ 3; i++)
{
if (file.exists())
{
scanner.next();
IDs[i] = scanner.nextInt();
}
}
}
catch (Exception exception) { }
ModLoader.registerEntityID(net.minecraft.src.EntityBasicCar.class, "BasicCar", ModLoader.getUniqueEntityId());
ModLoader.addName(car, "Машина");
ModLoader.addName(wheel, "Колеса");
ModLoader.addName(engine, "Двигатель");
ModLoader.addRecipe(new ItemStack(engine, 1), new Object[]
{
"!X!", 'X', Block.stoneOvenIdle, '!', Item.ШЕСТЕРЕНКА,
});
ModLoader.addRecipe(new ItemStack(wheel, 1), new Object[]
{
"###", "#X#", "###", 'X', Item.[color=#f00]ШЕСТЕРЕНКА[/color], '#', Item.[color=#f00]РЕЗИНА[/color]
});
ModLoader.addRecipe(new ItemStack(car, 1), new Object[]
{
" X%", "# #", 'X', engine, '#', wheel, '%', Block.chest
});
}
static
{
car = (new ItemCar(IDs[0])).setIconIndex(ModLoader.addOverride("/gui/items.png", "car.png")).setItemName("car");
wheel = (new Item(IDs[1])).setIconIndex(ModLoader.addOverride("/gui/items.png", "coleso.png")).setItemName("wheels");
engine = (new Item(IDs[2])).setIconIndex(ModLoader.addOverride("/gui/items.png", "dvigatel.png")).setItemName("engine");
}
}
EntityBasicCar
package net.minecraft.src;
public class EntityBasicCar extends EntityCarBase implements IInventory
{
public EntityBasicCar(World world)
{
super(world);
cargoItems = new ItemStack[27];
accel = 0.2F;
turn = 3F;
maxSpeed = 2.0F;
speed = 0.0D;
texture = "carz.png";
setSize(1.7F, 1.4F);
yOffset = height / 2.0F + 0.2F;
stepHeight = 1.2F;
}
public EntityBasicCar(World world, double d, double d1, double d2)
{
this(world);
setPosition(d, d1 + (double)yOffset, d2);
texture = "carmodel.png";
}
public ModelBase getModel()
{
return new ModelCar();
}
}
EntityCarBase
package net.minecraft.src;
import java.util.Random;
import org.lwjgl.input.Keyboard;
public class EntityCarBase extends Entity implements IInventory
{
public int fuel;
public int boatCurrentDamage;
public int boatTimeSinceHit;
public int boatRockDirection;
public double speed;
float maxSpeed;
float accel;
float turn;
public String texture;
ItemStack cargoItems[];
public EntityCarBase(World world)
{
super(world);
cargoItems = new ItemStack[27];
fuel = 0;
boatCurrentDamage = 0;
boatTimeSinceHit = 0;
boatRockDirection = 1;
preventEntitySpawning = true;
}
public EntityCarBase(World world, double d, double d1, double d2)
{
this(world);
setPosition(d, d1 + (double)yOffset, d2);
}
public ModelBase getModel()
{
return null;
}
protected void entityInit()
{
}
protected boolean canTriggerWalking()
{
return false;
}
public AxisAlignedBB getCollisionBox(Entity entity)
{
return entity.boundingBox;
}
public AxisAlignedBB getBoundingBox()
{
return boundingBox;
}
public boolean canBePushed()
{
return false;
}
public double getMountedYOffset()
{
return (double)height * 0.0D - 0.29999999999999999D;
}
public boolean canBeCollidedWith()
{
return !isDead;
}
public void updateRiderPosition()
{
if (riddenByEntity == null)
{
return;
}
else
{
double d = Math.cos(((double)rotationYaw * Math.PI) / 180D) * 0.40000000000000002D;
double d1 = Math.sin(((double)rotationYaw * Math.PI) / 180D) * 0.40000000000000002D;
riddenByEntity.setPosition(posX + d, posY + getMountedYOffset() + riddenByEntity.getYOffset(), posZ + d1);
return;
}
}
public void performHurtAnimation()
{
boatRockDirection = -boatRockDirection;
boatTimeSinceHit = 10;
boatCurrentDamage += boatCurrentDamage * 5;
}
public boolean attackEntityFrom(DamageSource damagesource, int i)
{
if (isDead)
{
return true;
}
boatRockDirection = -boatRockDirection;
boatTimeSinceHit = 10;
boatCurrentDamage += i * 5;
setBeenAttacked();
if (boatCurrentDamage › 40)
{
if (riddenByEntity != null)
{
riddenByEntity.mountEntity(this);
}
dropItem(mod_test.car.shiftedIndex, 1);
for (int j = 0; j ‹ getSizeInventory(); j++)
{
ItemStack itemstack = getStackInSlot(j);
if (itemstack != null)
{
entityDropItem(itemstack, 0.0F);
}
}
setDead();
}
return true;
}
public void onUpdate()
{
super.onUpdate();
if (boatTimeSinceHit › 0)
{
boatTimeSinceHit--;
}
if (boatCurrentDamage › 0)
{
boatCurrentDamage--;
}
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
int i = 5;
double d = 0.0D;
for (int j = 0; j ‹ i; j++)
{
double d3 = (boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double)(j + 0)) / (double)i) - 0.125D;
double d5 = (boundingBox.minY + ((boundingBox.maxY - boundingBox.minY) * (double)(j + 1)) / (double)i) - 0.125D;
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBoxFromPool(boundingBox.minX, d3, boundingBox.minZ, boundingBox.maxX, d5, boundingBox.maxZ);
}
if (d ‹ 1.0D)
{
double d1 = d * 2D - 1.0D;
motionY += 0.040000000000000001D * d1;
}
else
{
if (motionY ‹ 0.0D)
{
motionY /= 2D;
}
motionY += 0.0070000000000000001D;
}
if (fuel ‹= 0)
{
for (int k = 0; k ‹ getSizeInventory(); k++)
{
ItemStack itemstack = getStackInSlot(k);
if (itemstack == null || itemstack.itemID != Item.coal.shiftedIndex)
{
continue;
}
decrStackSize(k, 1);
fuel += 1500;
if (riddenByEntity == null || !(riddenByEntity instanceof EntityPlayer))
{
continue;
}
EntityPlayer entityplayer1 = (EntityPlayer)riddenByEntity;
entityplayer1.addChatMessage("Бак заполнен");
break;
}
}
if (riddenByEntity != null && (!inWater || mod_test.canCarDriveInWater))
{
if (Keyboard.isKeyDown(30))
{
rotationYaw -= (double)turn * (1.0D + speed / 2D);
}
if (Keyboard.isKeyDown(32))
{
rotationYaw += (double)turn * (1.0D + speed / 2D);
}
if (Keyboard.isKeyDown(17) && fuel › 0)
{
speed += 0.02D;
}
if (Keyboard.isKeyDown(31) && fuel › 0)
{
speed -= 0.01D;
}
if (Keyboard.isKeyDown(42))
{
speed *= 0.75D;
}
fuel -= speed;
}
else
{
speed *= 0.90000000000000002D;
}
if (inWater && speed › 0.20000000000000001D && !mod_test.canCarDriveInWater)
{
worldObj.playSoundEffect((float)posX, (float)posY, (float)posZ, "random.fizz", 0.5F, 2.6F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.8F);
}
speed *= 0.97999999999999998D;
if (speed › (double)maxSpeed)
{
speed = maxSpeed;
}
if (isCollidedHorizontally)
{
speed = 0.0D;
}
if (ModLoader.isGUIOpen(null) && riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && Keyboard.isKeyDown(33))
{
EntityPlayer entityplayer = (EntityPlayer)riddenByEntity;
entityplayer.displayGUIChest(this);
}
motionX = -(speed * Math.cos(((double)rotationYaw * Math.PI) / 180D));
motionZ = -(speed * Math.sin(((double)rotationYaw * Math.PI) / 180D));
double d2 = Math.sqrt(motionX * motionX + motionZ * motionZ);
if (d2 › 0.14999999999999999D)
{
double d4 = Math.cos(((double)rotationYaw * Math.PI) / 180D);
double d6 = Math.sin(((double)rotationYaw * Math.PI) / 180D);
for (int l = 0; (double)l ‹ 1.0D + d2 * 60D; l++)
{
double d7 = rand.nextFloat() * 2.0F - 1.0F;
double d8 = (double)(rand.nextInt(2) * 2 - 1) * 0.69999999999999996D;
if (!rand.nextBoolean())
{
double d9 = posX + d4 + d6 * d7 * 0.69999999999999996D;
double d10 = (posZ + d6) - d4 * d7 * 0.69999999999999996D;
worldObj.spawnParticle("smoke", d9, posY - 0.125D, d10, motionX, motionY, motionZ);
}
}
}
moveEntity(motionX, motionY, motionZ);
}
protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
fuel = nbttagcompound.getInteger("Fuel");
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
cargoItems = new ItemStack[getSizeInventory()];
for (int i = 0; i ‹ nbttaglist.tagCount(); i++)
{
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
int j = nbttagcompound1.getByte("Slot") & 0xff;
if (j ›= 0 && j ‹ cargoItems.length)
{
cargoItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
}
protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
nbttagcompound.setInteger("fuel", fuel);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i ‹ cargoItems.length; i++)
{
if (cargoItems[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
cargoItems[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
nbttagcompound.setTag("Items", nbttaglist);
}
public int getSizeInventory()
{
return cargoItems.length;
}
public ItemStack getStackInSlot(int i)
{
return cargoItems[i];
}
public ItemStack decrStackSize(int i, int j)
{
if (cargoItems[i] != null)
{
if (cargoItems[i].stackSize ‹= j)
{
ItemStack itemstack = cargoItems[i];
cargoItems[i] = null;
return itemstack;
}
ItemStack itemstack1 = cargoItems[i].splitStack(j);
if (cargoItems[i].stackSize == 0)
{
cargoItems[i] = null;
}
return itemstack1;
}
else
{
return null;
}
}
public void setInventorySlotContents(int i, ItemStack itemstack)
{
cargoItems[i] = itemstack;
if (itemstack != null && itemstack.stackSize › getInventoryStackLimit())
{
itemstack.stackSize = getInventoryStackLimit();
}
}
public String getInvName()
{
return "Car";
}
public int getInventoryStackLimit()
{
return 64;
}
public void onInventoryChanged()
{
}
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return true;
}
public void openChest()
{
}
public void closeChest()
{
}
public boolean interact(EntityPlayer entityplayer)
{
ItemStack itemstack = entityplayer.inventory.getCurrentItem();
if (riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && riddenByEntity != entityplayer)
{
return true;
}
else
{
entityplayer.mountEntity(this);
return true;
}
}
public boolean canInteractWith(EntityPlayer entityplayer)
{
if (isDead)
{
return false;
}
else
{
return entityplayer.getDistanceSqToEntity(this) ‹= 64D;
}
}
public ItemStack getStackInSlotOnClosing(int i)
{
if (cargoItems[i] != null)
{
ItemStack itemstack = cargoItems[i];
cargoItems[i] = null;
return itemstack;
}
else
{
return null;
}
}
}
ItemCar
package net.minecraft.src;
public class ItemCar extends Item
{
public ItemCar(int i)
{
super(i);
maxStackSize = 1;
}
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
float f = 1.0F;
float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch) * f;
float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw) * f;
double d = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) * (double)f;
double d1 = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * (double)f + 1.6200000000000001D) - (double)entityplayer.yOffset;
double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * (double)f;
Vec3D vec3d = Vec3D.createVector(d, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.01745329F - (float)Math.PI);
float f4 = MathHelper.sin(-f2 * 0.01745329F - (float)Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.01745329F);
float f6 = MathHelper.sin(-f1 * 0.01745329F);
float f7 = f4 * f5;
float f8 = f6;
float f9 = f3 * f5;
double d3 = 5D;
Vec3D vec3d1 = vec3d.addVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3);
MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do(vec3d, vec3d1, true);
if (movingobjectposition == null)
{
return itemstack;
}
if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
{
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
if (world.getBlockId(i, j, k) == Block.snow.blockID)
{
j--;
}
world.spawnEntityInWorld(new EntityBasicCar(world, (float)i + 0.5F, (float)j + 1.0F, (float)k + 0.5F));
itemstack.stackSize--;
}
return itemstack;
}
}
ModelCar
package net.minecraft.src;
public class ModelCar extends ModelBase
{
//fields
ModelRenderer down_cuzov;
ModelRenderer cuzov;
ModelRenderer pered;
ModelRenderer zad;
ModelRenderer right;
ModelRenderer left;
ModelRenderer sedlodno;
ModelRenderer sedlospina;
ModelRenderer fara1;
ModelRenderer fara2;
public ModelCar()
{
textureWidth = 64;
textureHeight = 32;
down_cuzov = new ModelRenderer(this, 0, 0);
down_cuzov.addBox(0F, 0F, 0F, 16, 1, 31);
down_cuzov.setRotationPoint(-8F, 23F, -16F);
down_cuzov.setTextureSize(64, 32);
down_cuzov.mirror = true;
setRotation(down_cuzov, 0F, 0F, 0F);
cuzov = new ModelRenderer(this, 0, 0);
cuzov.addBox(0F, 0F, 0F, 16, 1, 29);
cuzov.setRotationPoint(-8F, 22F, -15F);
cuzov.setTextureSize(64, 32);
cuzov.mirror = true;
setRotation(cuzov, 0F, 0F, 0F);
pered = new ModelRenderer(this, 0, 0);
pered.addBox(0F, 0F, 0F, 14, 4, 3);
pered.setRotationPoint(-7F, 18F, -14F);
pered.setTextureSize(64, 32);
pered.mirror = true;
setRotation(pered, 0F, 0F, 0F);
zad = new ModelRenderer(this, 0, 0);
zad.addBox(0F, 0F, 0F, 14, 4, 3);
zad.setRotationPoint(-7F, 18F, 10F);
zad.setTextureSize(64, 32);
zad.mirror = true;
setRotation(zad, 0F, 0F, 0F);
right = new ModelRenderer(this, 0, 0);
right.addBox(0F, 0F, 0F, 2, 4, 21);
right.setRotationPoint(5F, 18F, -11F);
right.setTextureSize(64, 32);
right.mirror = true;
setRotation(right, 0F, 0F, 0F);
left = new ModelRenderer(this, 0, 0);
left.addBox(0F, 0F, 0F, 2, 4, 21);
left.setRotationPoint(-7F, 18F, -11F);
left.setTextureSize(64, 32);
left.mirror = true;
setRotation(left, 0F, 0F, 0F);
sedlodno = new ModelRenderer(this, 0, 0);
sedlodno.addBox(0F, 0F, 0F, 8, 2, 8);
sedlodno.setRotationPoint(-4F, 20F, -5F);
sedlodno.setTextureSize(64, 32);
sedlodno.mirror = true;
setRotation(sedlodno, 0F, 0F, 0F);
sedlospina = new ModelRenderer(this, 0, 0);
sedlospina.addBox(0F, 0F, 0F, 8, 4, 2);
sedlospina.setRotationPoint(-4F, 16F, 2F);
sedlospina.setTextureSize(64, 32);
sedlospina.mirror = true;
setRotation(sedlospina, 0F, 0F, 0F);
fara1 = new ModelRenderer(this, 0, 0);
fara1.addBox(0F, 0F, 0F, 2, 2, 1);
fara1.setRotationPoint(-6F, 19F, -15F);
fara1.setTextureSize(64, 32);
fara1.mirror = true;
setRotation(fara1, 0F, 0F, 0F);
fara2 = new ModelRenderer(this, 0, 0);
fara2.addBox(0F, 0F, 0F, 2, 2, 1);
fara2.setRotationPoint(4F, 19F, -15F);
fara2.setTextureSize(64, 32);
fara2.mirror = true;
setRotation(fara2, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5);
down_cuzov.render(f5);
cuzov.render(f5);
pered.render(f5);
zad.render(f5);
right.render(f5);
left.render(f5);
sedlodno.render(f5);
sedlospina.render(f5);
fara1.render(f5);
fara2.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5);
}
}
RenderCar
package net.minecraft.src;
import org.lwjgl.opengl.GL11;
public class RenderCar extends Render
{
protected ModelBase modelMinecart;
public RenderCar()
{
shadowSize = 0.5F;
}
public void func_152_a(EntityCarBase entitycarbase, double d, double d1, double d2, float f, float f1)
{
modelMinecart = entitycarbase.getModel();
GL11.glPushMatrix();
GL11.glTranslatef((float)d, (float)d1, (float)d2);
GL11.glRotatef(180F - f, 0.0F, 1.0F, 0.0F);
float f2 = (float)entitycarbase.boatTimeSinceHit - f1;
float f3 = (float)entitycarbase.boatCurrentDamage - f1;
if (f3 ‹ 0.0F)
{
f3 = 0.0F;
}
if (f2 › 0.0F)
{
GL11.glRotatef(((MathHelper.sin(f2) * f2 * f3) / 10F) * (float)entitycarbase.boatRockDirection, 1.0F, 0.0F, 0.0F);
}
loadTexture(entitycarbase.texture);
GL11.glScalef(-2F, -2F, 2.0F);
modelMinecart.render(entitycarbase, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
}
public void doRender(Entity entity, double d, double d1, double d2, float f, float f1)
{
func_152_a((EntityCarBase)entity, d, d1, d2, f, f1);
}
}
Сами текстуры
- car.png
- carmodel.png
- dvigatel.png
- coleso.png
Скриншоты работы
Тапками не кидать.
Питается углем, инвентарь открывается на "F"
P.S. кто умеет рисовать текстуры перерисуйте пожалуйста
Так-же я в дальнейшем хочу поменять питание углем на питание с помощью батареек, так-же встраивание некоторых модулей)