this and that
This commit is contained in:
parent
ca71a5cca1
commit
84a37bd1c5
6 changed files with 126 additions and 41 deletions
70
src/dark/api/events/FluidMixingEvent.java
Normal file
70
src/dark/api/events/FluidMixingEvent.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
package dark.api.events;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.Cancelable;
|
||||
import net.minecraftforge.fluids.FluidEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class FluidMixingEvent extends FluidEvent
|
||||
{
|
||||
|
||||
public FluidMixingEvent(FluidStack fluid, World world, Vector3 vec)
|
||||
{
|
||||
super(fluid, world, vec.intX(), vec.intY(), vec.intZ());
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
/**Called before a fluid is mixed with something else, normally another fluid. You can use this event to cancel the mixing or change its output */
|
||||
public static class PreMixEvent extends FluidMixingEvent
|
||||
{
|
||||
public final Object input;
|
||||
public Object output;
|
||||
|
||||
public PreMixEvent(World world, Vector3 vec, FluidStack fluid, Object input, Object output)
|
||||
{
|
||||
super(fluid, world, vec);
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
/**Called right when the fluid is mixed with an object. This is the last chance to cancel the mixing. As well this can be used to cause a different outcome */
|
||||
public static class MixEvent extends FluidMixingEvent
|
||||
{
|
||||
public final Object input;
|
||||
public Object output;
|
||||
|
||||
public MixEvent(World world, Vector3 vec, FluidStack fluid, Object input, Object output)
|
||||
{
|
||||
super(fluid, world, vec);
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Called when a mixer has gone threw all the recipes and not found one for the fluid and input.
|
||||
* Use this to hook into this can create a new recipe without registering it with the mixing
|
||||
* class */
|
||||
public static class MixingRecipeCall extends FluidMixingEvent
|
||||
{
|
||||
public final Object input;
|
||||
public Object output;
|
||||
|
||||
public MixingRecipeCall(World world, Vector3 vec, FluidStack fluid, Object input)
|
||||
{
|
||||
super(fluid, world, vec);
|
||||
this.input = input;
|
||||
}
|
||||
}
|
||||
|
||||
public static final void fireEvent(FluidMixingEvent event)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,7 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
/** Simple interface that allows an item to control how its salvaged, processed, or refined by a
|
||||
* processor. This is 100% optional as the processor by default can break down most items. The only
|
||||
* reason to use this is for more complex prossesing or were the item was created with NBT.
|
||||
* reason to use this is for more complex processing or were the item was created with NBT.
|
||||
*
|
||||
* @author Darkgaurdsman */
|
||||
public interface IProcessable
|
||||
|
|
|
@ -2,8 +2,7 @@ package dark.core.interfaces;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/** Useful for several diffrent things. Main use is to be called when a block or entity to trigger an
|
||||
* event inside the tileEntity */
|
||||
/** Used re relay an activation event from a block or entity to a tile or another entity */
|
||||
public interface IBlockActivated
|
||||
{
|
||||
/** Called when activated. Use angle from tile to get side. and getHeldItem to get the item the
|
||||
|
|
|
@ -56,7 +56,7 @@ public class PacketManagerEntity implements IPacketManager
|
|||
|
||||
}
|
||||
|
||||
public static void sendEntityUpdatePacket(Entity entity, boolean server, String id, Object... objects)
|
||||
public static void sendEntityUpdatePacket(Entity entity, boolean toServer, String id, Object... objects)
|
||||
{
|
||||
Object[] obj = new Object[2 + objects.length];
|
||||
obj[0] = entity.entityId;
|
||||
|
@ -66,7 +66,7 @@ public class PacketManagerEntity implements IPacketManager
|
|||
obj[2 + i] = objects[i];
|
||||
}
|
||||
Packet packet = PacketHandler.instance().getPacketWithID(DarkMain.CHANNEL, packetID, obj);
|
||||
if (server)
|
||||
if (toServer)
|
||||
{
|
||||
PacketDispatcher.sendPacketToServer(packet);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,12 @@ package dark.core.prefab.vehicles;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
@ -27,7 +30,7 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
|||
{
|
||||
//1m/tick is 80km/h or 50mi/h
|
||||
//0.5/tick is 40km/h
|
||||
public double speed = 0.0, maxSpeed = 0.32, turnRate = 3, acceration = .1;
|
||||
public double speed = 0.0, maxSpeed = 0.5, turnRate = 3, acceration = .1;
|
||||
|
||||
public double boatX, boatY, boatZ, boatYaw, boatPitch;
|
||||
public int boatPosRotationIncrements;
|
||||
|
@ -122,16 +125,15 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
|||
{
|
||||
double x;
|
||||
double y;
|
||||
double var12;
|
||||
double z;
|
||||
if (this.boatPosRotationIncrements > 0)
|
||||
{
|
||||
x = this.posX + (this.boatX - this.posX) / this.boatPosRotationIncrements;
|
||||
y = this.posY + (this.boatY - this.posY) / this.boatPosRotationIncrements;
|
||||
z = this.posZ + (this.boatZ - this.posZ) / this.boatPosRotationIncrements;
|
||||
var12 = MathHelper.wrapAngleTo180_double(this.boatYaw - this.rotationYaw);
|
||||
this.rotationYaw = (float) (this.rotationYaw + var12 / this.boatPosRotationIncrements);
|
||||
this.rotationPitch = (float) (this.rotationPitch + (this.boatPitch - this.rotationPitch) / this.boatPosRotationIncrements);
|
||||
x = this.posX + (this.boatX - this.posX) / (double) this.boatPosRotationIncrements;
|
||||
y = this.posY + (this.boatY - this.posY) / (double) this.boatPosRotationIncrements;
|
||||
z = this.posZ + (this.boatZ - this.posZ) / (double) this.boatPosRotationIncrements;
|
||||
|
||||
this.rotationYaw = (float) ((double) this.rotationYaw + MathHelper.wrapAngleTo180_double(this.boatYaw - (double) this.rotationYaw) / (double) this.boatPosRotationIncrements);
|
||||
this.rotationPitch = (float) ((double) this.rotationPitch + (this.boatPitch - (double) this.rotationPitch) / (double) this.boatPosRotationIncrements);
|
||||
--this.boatPosRotationIncrements;
|
||||
this.setPosition(x, y, z);
|
||||
this.setRotation(this.rotationYaw, this.rotationPitch);
|
||||
|
@ -141,10 +143,7 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
|||
x = this.posX + this.motionX;
|
||||
y = this.posY + this.motionY;
|
||||
z = this.posZ + this.motionZ;
|
||||
if (this.riddenByEntity != null)
|
||||
{
|
||||
this.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
if (this.onGround)
|
||||
{
|
||||
|
@ -157,28 +156,48 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
|||
this.motionY *= 0.949999988079071D;
|
||||
this.motionZ *= 0.9900000095367432D;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
double currentVel;
|
||||
|
||||
if (this.speed != 0.0D)
|
||||
{
|
||||
this.motionX = -Math.sin((double) (this.rotationYaw * (float) Math.PI / 180.0F)) * this.speed;
|
||||
this.motionZ = Math.cos((double) (this.rotationYaw * (float) Math.PI / 180.0F)) * this.speed;
|
||||
}
|
||||
|
||||
currentVel = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
|
||||
if (currentVel > this.maxSpeed)
|
||||
{
|
||||
double d = this.maxSpeed / currentVel;
|
||||
this.motionX *= d;
|
||||
this.motionZ *= d;
|
||||
currentVel = this.maxSpeed;
|
||||
}
|
||||
this.applyFriction();
|
||||
if (this.speed > this.maxSpeed)
|
||||
if (this.onGround)
|
||||
{
|
||||
this.speed = this.maxSpeed;
|
||||
}
|
||||
if (this.isCollidedHorizontally)
|
||||
{
|
||||
this.motionY = 0.1D;
|
||||
this.motionX *= 0.5D;
|
||||
this.motionY *= 0.5D;
|
||||
this.motionZ *= 0.5D;
|
||||
}
|
||||
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (this.canMove())
|
||||
{
|
||||
this.motionX = -(this.speed * Math.cos((this.rotationYaw - 90F) * Math.PI / 180.0D));
|
||||
this.motionZ = -(this.speed * Math.sin((this.rotationYaw - 90F) * Math.PI / 180.0D));
|
||||
}
|
||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
||||
|
||||
if (this.isCollidedHorizontally && this.speed > .1)
|
||||
{
|
||||
this.motionY = .1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.motionX *= 0.9900000095367432D;
|
||||
this.motionY *= 0.949999988079071D;
|
||||
this.motionZ *= 0.9900000095367432D;
|
||||
}
|
||||
|
||||
}
|
||||
if (ticks % 5 == 0)
|
||||
{
|
||||
PacketManagerEntity.sendEntityUpdatePacket(this, this.worldObj.isRemote, "Desc", this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch, this.motionX, this.motionY, this.motionZ);
|
||||
|
@ -188,9 +207,6 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
|
|||
this.updateClients();
|
||||
}
|
||||
}
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue