smooth sailing on conveyor belts
8
src/main/java/api/hbm/conveyor/IConveyorItem.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package api.hbm.conveyor;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public interface IConveyorItem {
|
||||||
|
|
||||||
|
public ItemStack getItemStack();
|
||||||
|
}
|
||||||
9
src/main/java/api/hbm/conveyor/IEnterableBlock.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package api.hbm.conveyor;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public interface IEnterableBlock {
|
||||||
|
|
||||||
|
public boolean canEnter(IConveyorItem entity, ForgeDirection dir);
|
||||||
|
public void onEnter(IConveyorItem entity, ForgeDirection dir);
|
||||||
|
}
|
||||||
@ -2,6 +2,9 @@ package com.hbm.entity.item;
|
|||||||
|
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
|
|
||||||
|
import api.hbm.conveyor.IConveyorItem;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@ -12,11 +15,22 @@ import net.minecraft.util.DamageSource;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class EntityMovingItem extends Entity {
|
public class EntityMovingItem extends Entity implements IConveyorItem {
|
||||||
|
|
||||||
|
private int turnProgress;
|
||||||
|
private double syncPosX;
|
||||||
|
private double syncPosY;
|
||||||
|
private double syncPosZ;
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private double velocityX;
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private double velocityY;
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private double velocityZ;
|
||||||
|
|
||||||
public EntityMovingItem(World p_i1582_1_) {
|
public EntityMovingItem(World p_i1582_1_) {
|
||||||
super(p_i1582_1_);
|
super(p_i1582_1_);
|
||||||
this.setSize(0.5F, 0.25F);
|
this.setSize(0.5F, 0.5F);
|
||||||
this.noClip = true;
|
this.noClip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +90,18 @@ public class EntityMovingItem extends Entity {
|
|||||||
|
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
|
|
||||||
|
if(worldObj.isRemote) {
|
||||||
|
if(this.turnProgress > 0) {
|
||||||
|
double interpX = this.posX + (this.syncPosX - this.posX) / (double) this.turnProgress;
|
||||||
|
double interpY = this.posY + (this.syncPosY - this.posY) / (double) this.turnProgress;
|
||||||
|
double interpZ = this.posZ + (this.syncPosZ - this.posZ) / (double) this.turnProgress;
|
||||||
|
--this.turnProgress;
|
||||||
|
this.setPosition(interpX, interpY, interpZ);
|
||||||
|
} else {
|
||||||
|
this.setPosition(this.posX, this.posY, this.posZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!worldObj.isRemote) {
|
if(!worldObj.isRemote) {
|
||||||
|
|
||||||
if(worldObj.getBlock((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)) != ModBlocks.conveyor) {
|
if(worldObj.getBlock((int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ)) != ModBlocks.conveyor) {
|
||||||
@ -114,9 +140,28 @@ public class EntityMovingItem extends Entity {
|
|||||||
|
|
||||||
schedule--;
|
schedule--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.moveEntity(motionX, motionY, motionZ);
|
this.moveEntity(motionX, motionY, motionZ);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) {
|
||||||
|
this.velocityX = this.motionX = p_70016_1_;
|
||||||
|
this.velocityY = this.motionY = p_70016_3_;
|
||||||
|
this.velocityZ = this.motionZ = p_70016_5_;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int theNumberThree) {
|
||||||
|
this.syncPosX = x;
|
||||||
|
this.syncPosY = y;
|
||||||
|
this.syncPosZ = z;
|
||||||
|
this.turnProgress = theNumberThree + 7; //use 4-ply for extra smoothness
|
||||||
|
this.motionX = this.velocityX;
|
||||||
|
this.motionY = this.velocityY;
|
||||||
|
this.motionZ = this.velocityZ;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void entityInit() {
|
protected void entityInit() {
|
||||||
@ -145,5 +190,4 @@ public class EntityMovingItem extends Entity {
|
|||||||
|
|
||||||
nbt.setInteger("schedule", schedule);
|
nbt.setInteger("schedule", schedule);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 239 B |
|
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 199 B |
|
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 176 B |
|
Before Width: | Height: | Size: 134 B After Width: | Height: | Size: 162 B |