Skip to content

Commit

Permalink
Tractor texture added & tractor now will till land behind it
Browse files Browse the repository at this point in the history
Improved EntityMachineModRidable to have helper methods to aid in
finding offset for 3 (or more) block wide positions in front of or
behind the machine
  • Loading branch information
TechStack committed Jan 17, 2015
1 parent e231f09 commit 9a67891
Show file tree
Hide file tree
Showing 8 changed files with 2,944 additions and 1,607 deletions.
Binary file modified Blender/Tractor.blend
Binary file not shown.
Binary file modified Blender/Tractor.blend1
Binary file not shown.
Binary file modified Blender/ref image/tractor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ group= "com.projectreddog.machinemod" // http://maven.apache.org/guides/mini/gui
archivesBaseName = "MachineMod"

minecraft {
version = "1.8-11.14.0.1285-1.8"
version = "1.8-11.14.0.1289-1.8"
runDir = "eclipse"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void updateServer() {

ModNetwork.sendPacketToAllAround( (new MachineModMessageEntityToClient( this.getEntityId(),this.posX,this.posY,this.posZ,this.yaw,this.Attribute1)), new TargetPoint(worldObj.provider.getDimensionId(), posX, posY, posZ, 80));

// ModNetwork.simpleNetworkWrapper.sendToAllAround((new MachineModMessageEntityToClient( this.getEntityId(),this.posX,this.posY,this.posZ,this.yaw,this.Attribute1)), new TargetPoint(worldObj.provider.getDimensionId(), posX, posY, posZ, 80));
// ModNetwork.simpleNetworkWrapper.sendToAllAround((new MachineModMessageEntityToClient( this.getEntityId(),this.posX,this.posY,this.posZ,this.yaw,this.Attribute1)), new TargetPoint(worldObj.provider.getDimensionId(), posX, posY, posZ, 80));
}


Expand Down Expand Up @@ -333,10 +333,47 @@ public float getMinAngle() {
return 0;
}
public double calcOffsetX(double distance){
return(distance * MathHelper.cos((float) ((this.yaw+90) * Math.PI / 180.0D)));
return(distance * MathHelper.cos((float) (clampAngelto360(this.yaw+90) * Math.PI / 180.0D)));
}
public double calcOffsetZ(double distance){
return (distance * MathHelper.sin((float) ((this.yaw+90)* Math.PI / 180.0D)));
return (distance * MathHelper.sin((float) (clampAngelto360(this.yaw+90)* Math.PI / 180.0D)));

}
public double calcTwoOffsetX(double distance, int secondOffsetAngle, double secondOffsetDistance)
{

if (secondOffsetAngle == 0){
return (calcOffsetX(distance) );
}
//calc first xPos
double firstX=calcOffsetX(distance);

return firstX + (secondOffsetDistance * MathHelper.cos((float) (clampAngelto360(this.yaw+secondOffsetAngle+90) * Math.PI / 180.0D)));
}



public double calcTwoOffsetZ(double distance, int secondOffsetAngle, double secondOffsetDistance)
{

if (secondOffsetAngle == 0){
return (calcOffsetZ(distance) );
}
//calc first xPos
double firstZ=calcOffsetZ(distance) ;

return firstZ + (secondOffsetDistance * MathHelper.sin((float) (clampAngelto360(this.yaw+secondOffsetAngle+90) * Math.PI / 180.0D)));
}
public float clampAngelto360(float inAngle){
while (inAngle> 360 )
{
inAngle -=360;
}

while (inAngle< 0 )
{
inAngle =360-inAngle;
}
return inAngle;
}
}
125 changes: 79 additions & 46 deletions src/main/java/com/projectreddog/machinemod/entity/EntityTractor.java
Original file line number Diff line number Diff line change
@@ -1,61 +1,94 @@
package com.projectreddog.machinemod.entity;

import com.projectreddog.machinemod.init.ModItems;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

import com.projectreddog.machinemod.init.ModItems;

public class EntityTractor extends EntityMachineModRideable {

public double bladeOffset = 2.0d;

public EntityTractor(World world){
super(world);
setSize (1.5F , 2F);
}

@Override
/**
* Returns the Y offset from the entity's position for any entity riding this one.
*/
public double getMountedYOffset()
{
return (double)this.height * 0.35D;
}

@Override
public Item getItemToBeDropped()
{
return ModItems.bulldozer;
}

@Override
public void onUpdate(){
super.onUpdate();
if (!worldObj.isRemote){
// digMethodA();

}
}



// /**
// * Sets the forward direction of the entity.
// */
// public void setForwardDirection(int value)
// {
// this.dataWatcher.updateObject(18, Integer.valueOf(value));
// }
//
// /**
// * Gets the forward direction of the entity.
// */
// public int getForwardDirection()
// {
// return this.dataWatcher.getWatchableObjectInt(18);
// }

@Override
/**
* Returns the Y offset from the entity's position for any entity riding this one.
*/
public double getMountedYOffset()
{
return (double)this.height * 0.55D;
}

@Override
public Item getItemToBeDropped()
{
return ModItems.bulldozer;
}

@Override
public void onUpdate(){
super.onUpdate();
if (!worldObj.isRemote){
// digMethodA();
BlockPos bp;
int angle = 0;
// this will calcl the offset for three positions behind the tractor (3 wide)
for (int i=-1;i <2;i++){
if (i ==0){
angle =0 ;
}
else
{
angle =90;
}
bp = new BlockPos(posX + calcTwoOffsetX(-3.5,angle,i), posY -1, posZ + calcTwoOffsetZ(-3.5,angle,i));
if ( worldObj.getBlockState(bp).getBlock() == Blocks.dirt||
worldObj.getBlockState(bp).getBlock()== Blocks.grass )
{
worldObj.setBlockState(bp, Blocks.farmland.getDefaultState());
}
}





}
}
@Override
public double getMountedXOffset()
{
return calcOffsetX(0.65d);
}
@Override
public double getMountedZOffset()
{
return calcOffsetZ(0.65d);
}



// /**
// * Sets the forward direction of the entity.
// */
// public void setForwardDirection(int value)
// {
// this.dataWatcher.updateObject(18, Integer.valueOf(value));
// }
//
// /**
// * Gets the forward direction of the entity.
// */
// public int getForwardDirection()
// {
// return this.dataWatcher.getWatchableObjectInt(18);
// }
}
Loading

0 comments on commit 9a67891

Please sign in to comment.