initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
80
java/src/game/dispenser/BehaviorDefaultDispenseItem.java
Executable file
80
java/src/game/dispenser/BehaviorDefaultDispenseItem.java
Executable file
|
@ -0,0 +1,80 @@
|
|||
package game.dispenser;
|
||||
|
||||
import game.block.BlockDispenser;
|
||||
import game.entity.item.EntityItem;
|
||||
import game.item.ItemStack;
|
||||
import game.world.Facing;
|
||||
import game.world.World;
|
||||
|
||||
public class BehaviorDefaultDispenseItem implements IBehaviorDispenseItem
|
||||
{
|
||||
/**
|
||||
* Dispenses the specified ItemStack from a dispenser.
|
||||
*/
|
||||
public final ItemStack dispense(IBlockSource source, ItemStack stack)
|
||||
{
|
||||
ItemStack itemstack = this.dispenseStack(source, stack);
|
||||
this.playDispenseSound(source);
|
||||
this.spawnDispenseParticles(source, BlockDispenser.getFacing(source.getBlockMetadata()));
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
||||
{
|
||||
Facing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
|
||||
IPosition iposition = BlockDispenser.getDispensePosition(source);
|
||||
ItemStack itemstack = stack.splitStack(1);
|
||||
doDispense(source.getWorld(), itemstack, 6, enumfacing, iposition);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static void doDispense(World worldIn, ItemStack stack, int speed, Facing facing, IPosition position)
|
||||
{
|
||||
double d0 = position.getX();
|
||||
double d1 = position.getY();
|
||||
double d2 = position.getZ();
|
||||
|
||||
if (facing.getAxis() == Facing.Axis.Y)
|
||||
{
|
||||
d1 = d1 - 0.125D;
|
||||
}
|
||||
else
|
||||
{
|
||||
d1 = d1 - 0.15625D;
|
||||
}
|
||||
|
||||
EntityItem entityitem = new EntityItem(worldIn, d0, d1, d2, stack);
|
||||
double d3 = worldIn.rand.doublev() * 0.1D + 0.2D;
|
||||
entityitem.motionX = (double)facing.getFrontOffsetX() * d3;
|
||||
entityitem.motionY = 0.20000000298023224D;
|
||||
entityitem.motionZ = (double)facing.getFrontOffsetZ() * d3;
|
||||
entityitem.motionX += worldIn.rand.gaussian() * 0.007499999832361937D * (double)speed;
|
||||
entityitem.motionY += worldIn.rand.gaussian() * 0.007499999832361937D * (double)speed;
|
||||
entityitem.motionZ += worldIn.rand.gaussian() * 0.007499999832361937D * (double)speed;
|
||||
worldIn.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Play the dispense sound from the specified block.
|
||||
*/
|
||||
protected void playDispenseSound(IBlockSource source)
|
||||
{
|
||||
source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order clients to display dispense particles from the specified block and facing.
|
||||
*/
|
||||
protected void spawnDispenseParticles(IBlockSource source, Facing facingIn)
|
||||
{
|
||||
source.getWorld().playAuxSFX(2000, source.getBlockPos(), this.func_82488_a(facingIn));
|
||||
}
|
||||
|
||||
private int func_82488_a(Facing facingIn)
|
||||
{
|
||||
return facingIn.getFrontOffsetX() + 1 + (facingIn.getFrontOffsetZ() + 1) * 3;
|
||||
}
|
||||
}
|
49
java/src/game/dispenser/BehaviorProjectileDispense.java
Executable file
49
java/src/game/dispenser/BehaviorProjectileDispense.java
Executable file
|
@ -0,0 +1,49 @@
|
|||
package game.dispenser;
|
||||
|
||||
import game.block.BlockDispenser;
|
||||
import game.entity.Entity;
|
||||
import game.entity.types.IProjectile;
|
||||
import game.item.ItemStack;
|
||||
import game.world.Facing;
|
||||
import game.world.World;
|
||||
|
||||
public abstract class BehaviorProjectileDispense extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn particles.
|
||||
*/
|
||||
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
|
||||
{
|
||||
World world = source.getWorld();
|
||||
IPosition iposition = BlockDispenser.getDispensePosition(source);
|
||||
Facing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
|
||||
IProjectile iprojectile = this.getProjectileEntity(world, iposition, stack);
|
||||
iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.getVelocity(), this.getInaccuracy());
|
||||
world.spawnEntityInWorld((Entity)iprojectile);
|
||||
stack.splitStack(1);
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Play the dispense sound from the specified block.
|
||||
*/
|
||||
protected void playDispenseSound(IBlockSource source)
|
||||
{
|
||||
source.getWorld().playAuxSFX(1002, source.getBlockPos(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the projectile entity spawned by this dispense behavior.
|
||||
*/
|
||||
protected abstract IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack item);
|
||||
|
||||
protected float getInaccuracy()
|
||||
{
|
||||
return 6.0F;
|
||||
}
|
||||
|
||||
protected float getVelocity()
|
||||
{
|
||||
return 1.1F;
|
||||
}
|
||||
}
|
19
java/src/game/dispenser/IBehaviorDispenseItem.java
Executable file
19
java/src/game/dispenser/IBehaviorDispenseItem.java
Executable file
|
@ -0,0 +1,19 @@
|
|||
package game.dispenser;
|
||||
|
||||
import game.item.ItemStack;
|
||||
|
||||
public interface IBehaviorDispenseItem
|
||||
{
|
||||
IBehaviorDispenseItem itemDispenseBehaviorProvider = new IBehaviorDispenseItem()
|
||||
{
|
||||
public ItemStack dispense(IBlockSource source, ItemStack stack)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispenses the specified ItemStack from a dispenser.
|
||||
*/
|
||||
ItemStack dispense(IBlockSource source, ItemStack stack);
|
||||
}
|
19
java/src/game/dispenser/IBlockSource.java
Executable file
19
java/src/game/dispenser/IBlockSource.java
Executable file
|
@ -0,0 +1,19 @@
|
|||
package game.dispenser;
|
||||
|
||||
import game.tileentity.TileEntity;
|
||||
import game.world.BlockPos;
|
||||
|
||||
public interface IBlockSource extends ILocatableSource
|
||||
{
|
||||
double getX();
|
||||
|
||||
double getY();
|
||||
|
||||
double getZ();
|
||||
|
||||
BlockPos getBlockPos();
|
||||
|
||||
int getBlockMetadata();
|
||||
|
||||
<T extends TileEntity> T getBlockTileEntity();
|
||||
}
|
5
java/src/game/dispenser/ILocatableSource.java
Executable file
5
java/src/game/dispenser/ILocatableSource.java
Executable file
|
@ -0,0 +1,5 @@
|
|||
package game.dispenser;
|
||||
|
||||
public interface ILocatableSource extends ILocation
|
||||
{
|
||||
}
|
8
java/src/game/dispenser/ILocation.java
Executable file
8
java/src/game/dispenser/ILocation.java
Executable file
|
@ -0,0 +1,8 @@
|
|||
package game.dispenser;
|
||||
|
||||
import game.world.World;
|
||||
|
||||
public interface ILocation extends IPosition
|
||||
{
|
||||
World getWorld();
|
||||
}
|
10
java/src/game/dispenser/IPosition.java
Executable file
10
java/src/game/dispenser/IPosition.java
Executable file
|
@ -0,0 +1,10 @@
|
|||
package game.dispenser;
|
||||
|
||||
public interface IPosition
|
||||
{
|
||||
double getX();
|
||||
|
||||
double getY();
|
||||
|
||||
double getZ();
|
||||
}
|
30
java/src/game/dispenser/PositionImpl.java
Executable file
30
java/src/game/dispenser/PositionImpl.java
Executable file
|
@ -0,0 +1,30 @@
|
|||
package game.dispenser;
|
||||
|
||||
public class PositionImpl implements IPosition
|
||||
{
|
||||
protected final double x;
|
||||
protected final double y;
|
||||
protected final double z;
|
||||
|
||||
public PositionImpl(double xCoord, double yCoord, double zCoord)
|
||||
{
|
||||
this.x = xCoord;
|
||||
this.y = yCoord;
|
||||
this.z = zCoord;
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public double getZ()
|
||||
{
|
||||
return this.z;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue