this and that

This commit is contained in:
DarkGuardsman 2013-11-11 09:51:21 -05:00
parent ca71a5cca1
commit 84a37bd1c5
6 changed files with 126 additions and 41 deletions

View 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);
}
}

View file

@ -4,8 +4,8 @@ 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
{
@ -13,7 +13,7 @@ public interface IProcessable
public boolean canProcess(ProcessorType type, ItemStack stack);
/** Gets the output array of items when this item is processed by a processor machine
*
*
* @param type - type of machine see ProcessorTypes enum for info
* @param stack - ItemStack of this item or block
* @return Array of all item outputed, Make sure to return less than or equal to the amount of

View file

@ -25,10 +25,10 @@ import dark.core.interfaces.IExtraInfo.IExtraBlockInfo;
import dark.core.prefab.fluids.EnumGas;
/** Gas that is designed to generate underground in the same way as an ore
*
*
* TODO code actual gas behavior such as expanding to fill an area but at the same time losing
* volume
*
*
* @author DarkGuardsman */
public class BlockGasOre extends BlockTile implements IGasBlock, IExtraBlockInfo
{

View file

@ -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

View file

@ -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);
}

View file

@ -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);
}
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;
}
this.applyFriction();
if (this.speed > this.maxSpeed)
else
{
this.speed = this.maxSpeed;
}
if (this.isCollidedHorizontally)
{
this.motionY = 0.1D;
}
double currentVel;
if (this.worldObj.isRemote)
{
if (this.canMove())
if (this.speed != 0.0D)
{
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.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;
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
}
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.onGround)
{
this.motionX *= 0.5D;
this.motionY *= 0.5D;
this.motionZ *= 0.5D;
}
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;
}
@ -277,7 +293,7 @@ public abstract class EntityVehicle extends EntityAdvanced implements IControlRe
}
/** Increases the speed by a determined amount per tick the player holds the forward key down
*
*
* @param forward */
public void accelerate(boolean forward)
{