Skip to content

Commit

Permalink
Tractor now requires key press to have it till the ground
Browse files Browse the repository at this point in the history
Loader resized and textured inventory work. Also the loader can now
break blocks , pick them up with bucket down, it will also drop them
when the bucket is up all the way
  • Loading branch information
TechStack committed Jan 18, 2015
1 parent 9a67891 commit a4d65ad
Show file tree
Hide file tree
Showing 15 changed files with 4,889 additions and 2,105 deletions.
Binary file added Blender/Loader3.blend
Binary file not shown.
Binary file added Blender/Loader4.blend
Binary file not shown.
Binary file added Blender/Loader4.blend1
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected void drawGuiContainerBackgroundLayer(float par1, int par2,
//draw your Gui here, only thing you need to change is the path

GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(new ResourceLocation(Reference.MOD_ID , "textures/gui/dumptruck.png"));
this.mc.renderEngine.bindTexture(new ResourceLocation(Reference.MOD_ID , "textures/gui/loader.png"));
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public ContainerLoader(InventoryPlayer inventoryPlayer , EntityLoader loader){
this.loader=loader;


for (int i = 0; i <6; i++) {
for (int i = 0; i <1; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(loader, j + i * 9, 8+j * 18, 18 + i * 18));
}
Expand Down Expand Up @@ -58,13 +58,13 @@ public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
stack = stackInSlot.copy();

//merges the item into player inventory since its in the Entity
if (slot < 54) {
if (!this.mergeItemStack(stackInSlot, 54, this.inventorySlots.size(), true)) {
if (slot < 9) {
if (!this.mergeItemStack(stackInSlot, 9, this.inventorySlots.size(), true)) {
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 54, false)) {
else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;

import com.projectreddog.machinemod.MachineMod;
Expand All @@ -32,8 +34,8 @@ public class EntityLoader extends EntityMachineModRideable implements IInventory
public EntityLoader(World world){
super(world);

setSize(2.5f, 2);
inventory = new ItemStack[54];
setSize(2.8f, 2.5f);
inventory = new ItemStack[9];
}


Expand All @@ -42,11 +44,67 @@ public EntityLoader(World world){
public void onUpdate(){
super.onUpdate();
if (!worldObj.isRemote){
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox());
collidedEntitiesInList(list);
}
if (this.Attribute1 == this.getMaxAngle()){
//bucket Down
// break blocks first
int angle;
for (int i=-1;i <2;i++){
if (i ==0){
angle =0 ;
}
else
{
angle =90;
}
BlockPos bp ;
bp = new BlockPos(posX + calcTwoOffsetX(3.5,angle,i), posY , posZ + calcTwoOffsetZ(3.5,angle,i));

worldObj.getBlockState(bp).getBlock().dropBlockAsItem(worldObj, bp,worldObj.getBlockState(bp) , 0);
worldObj.setBlockToAir(bp);

}

AxisAlignedBB bucketboundingBox = new AxisAlignedBB(calcTwoOffsetX(3.5,90,-1)+posX-.5d, posY, calcTwoOffsetZ(3.5,90,-1)+posZ-.5d, calcTwoOffsetX(3.5,90,1)+posX+.5d, posY+1, calcTwoOffsetZ(3.5,90,1)+posZ+.5d);


List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, bucketboundingBox);
collidedEntitiesInList(list);
}
if (this.Attribute1 == this.getMinAngle()){
//bucket up
// Drop blocks
//TODO needs something to pace it a bit more now it drops everything way to fast.
for (int i = 0; i < this.getSizeInventory(); i++) {
ItemStack item = this.getStackInSlot(i);

if (item != null && item.stackSize > 0) {
;

EntityItem entityItem = new EntityItem(worldObj,
posX + calcOffsetX(3.5), posY +4, posZ + calcOffsetZ(3.5),
item);

if (item.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}

float factor = 0.05F;
//entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = 0;
//entityItem.motionZ = rand.nextGaussian() * factor;
entityItem.forceSpawn=true;
LogHelper.info( worldObj.spawnEntityInWorld(entityItem));
//item.stackSize = 0;
this.setInventorySlotContents(i, null);
}
}



}

}

}

public AxisAlignedBB getBoundingBox(){
Expand Down Expand Up @@ -109,7 +167,7 @@ private ItemStack addToinventory( ItemStack is)
setInventorySlotContents(j, new ItemStack(is.getItem(), is.stackSize) );
is =null;
}

}

}
Expand All @@ -124,10 +182,23 @@ private ItemStack addToinventory( ItemStack is)
*/
public double getMountedYOffset()
{
return (double)this.height * 0.35D;
return (double)this.height * .6D;
}


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



@Override
public boolean interactFirst(EntityPlayer player) // should be proper class
{
Expand Down Expand Up @@ -306,12 +377,12 @@ public void clear() {
inventory[i] = null;
}
}

@Override
public float getMaxAngle() {
return 0;
}

@Override
public float getMinAngle() {
return -90;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {

@Override
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {

// TODO Auto-generated method stub

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,24 @@ public void onUpdate(){
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 ;
if (this.isPlayerPushingSprintButton){
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());
}
}
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());
}
}


}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

import com.projectreddog.machinemod.MachineMod;
import com.projectreddog.machinemod.entity.EntityDumpTruck;
import com.projectreddog.machinemod.entity.EntityLoader;
import com.projectreddog.machinemod.entity.EntityMachineModRideable;
import com.projectreddog.machinemod.reference.Reference;

Expand All @@ -27,7 +29,12 @@ public IMessage onMessage(MachineModMessageInputToServerOpenGui message, Message
//its ridden by this player (avoid some hacks)
if (message.isOpenGui){


if (entity instanceof EntityDumpTruck){
((EntityPlayer)entity.riddenByEntity).openGui(MachineMod.instance, Reference.GUI_DUMP_TRUCK, entity.worldObj, (int) entity.getEntityId(), (int) 0,(int) 0);
}else if (entity instanceof EntityLoader){
((EntityPlayer)entity.riddenByEntity).openGui(MachineMod.instance, Reference.GUI_LOADER, entity.worldObj, (int) entity.getEntityId(), (int) 0,(int) 0);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Reference {

public static final String MODEL_DRILLINGRIG_TEXTURE_LOCATION = "models/drillingrig.png";
public static final String MODEL_DUMPTRUCK_TEXTURE_LOCATION = "models/dumptruck.png";
public static final String MODEL_LOADER_TEXTURE_LOCATION = "models/dumptruck.png";
public static final String MODEL_LOADER_TEXTURE_LOCATION = "models/modelloader.png";

public static final int GUI_DUMP_TRUCK = 0;
public static final int GUI_LOADER = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ public void doRender(Entity entity, double x, double y, double z, float yaw, flo
this.modelLoader.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

((ModelLoader) this.modelLoader).renderGroupObject("LoaderBody_Cube");
GL11.glTranslatef(0f, -1.5f, -0.5f);
//GL11.glTranslatef(0f, -1.5f, -0.5f);
GL11.glTranslatef(0f, -2.25f, -1.05f);
GL11.glRotatef(((EntityLoader) entity).Attribute1, 1,0, 0);
((ModelLoader) this.modelLoader).renderGroupObject("Arm2_Cube.002");
GL11.glTranslatef(0f, 1.2f, -1.2f);
//GL11.glTranslatef(0f, 1.2f, -1.2f);
GL11.glTranslatef(0f, 1.8f, -1.9f);
if (((EntityLoader) entity).Attribute1 < -30){
GL11.glRotatef((((EntityLoader) entity).Attribute1 +30) *-2f, 1,0, 0);
}
Expand Down
Loading

0 comments on commit a4d65ad

Please sign in to comment.