Misc fixes, mostly related to sound and the "broken parts" entities
This commit is contained in:
parent
3f08c47a73
commit
eb7f73464f
|
@ -30,7 +30,7 @@ sourceCompatibility = 1.8
|
|||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = "14.23.1.2555"
|
||||
version = "14.23.3.2655"
|
||||
runDir = "run"
|
||||
|
||||
replace '${version}', project.version
|
||||
|
@ -70,11 +70,11 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
|
||||
compileOnly 'net.industrial-craft:industrialcraft-2:2.8.+'
|
||||
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+:deobf"
|
||||
compileOnly "TechReborn:TechReborn-1.12:2.6.+:dev"
|
||||
compileOnly "RebornCore:RebornCore-1.12:3.2.+:dev"
|
||||
deobfCompile 'com.elytradev:mirage:2.0.1-SNAPSHOT'
|
||||
compileOnly 'com.elytradev:mirage:2.0.1-SNAPSHOT'
|
||||
compileOnly "mezz.jei:jei_1.12:4.+"
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.+"
|
||||
}
|
||||
|
|
|
@ -84,8 +84,7 @@ public abstract class CommonProxy implements IGuiHandler {
|
|||
|
||||
public void playMarxBang(TileEntityMarx tileEntityMarx, Vec3d vec3d, float energy) {}
|
||||
|
||||
public void playMechMBBang(TileEntityMechMB te, float volume) {}
|
||||
|
||||
public void updateMechMBTurningSound(TileEntityMechMB te, MechEnergy energy) {}
|
||||
|
||||
public void stopAllSoundsExcept(BlockPos pos, Set<ISound> excluded) {}
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public class IndustrialWires {
|
|||
GameRegistry.registerTileEntity(TileEntityComponentPanel.class, MODID + ":single_component_panel");
|
||||
GameRegistry.registerTileEntity(TileEntityDischargeMeter.class, MODID + ":discharge_meter");
|
||||
EntityRegistry.registerModEntity(new ResourceLocation(MODID, "broken_part"), EntityBrokenPart.class,
|
||||
"broken_part", 0, this, 64, 1, true);
|
||||
"broken_part", 0, this, 64, 5, true);
|
||||
|
||||
proxy.preInit();
|
||||
Compat.preInit();
|
||||
|
|
|
@ -68,13 +68,17 @@ public abstract class TileEntityIWBase extends TileEntity {
|
|||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
IndustrialWires.proxy.stopAllSoundsExcept(pos, ImmutableSet.of());
|
||||
if (world.isRemote) {
|
||||
IndustrialWires.proxy.stopAllSoundsExcept(pos, ImmutableSet.of());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
IndustrialWires.proxy.stopAllSoundsExcept(pos, ImmutableSet.of());
|
||||
if (world.isRemote) {
|
||||
IndustrialWires.proxy.stopAllSoundsExcept(pos, ImmutableSet.of());
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void writeNBT(NBTTagCompound out, boolean updatePacket);
|
||||
|
|
|
@ -38,9 +38,7 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
@ -411,9 +409,8 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
|
|||
}
|
||||
}
|
||||
|
||||
private static ResourceLocation mmbBang = new ResourceLocation(IndustrialWires.MODID, "mech_mb_breaking");
|
||||
private void disassemble(Set<MechMBPart> failed) {
|
||||
if (world.isRemote)
|
||||
IndustrialWires.proxy.playMechMBBang(this, failed.size()*2);//TODO this doesn't run client-side
|
||||
if (!world.isRemote && formed) {
|
||||
formed = false;
|
||||
world.setBlockState(pos,
|
||||
|
@ -431,6 +428,9 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
|
|||
}
|
||||
}
|
||||
}
|
||||
if (failed.contains(mech)) {
|
||||
world.playSound(null, mech.world.getOrigin(), new SoundEvent(mmbBang), SoundCategory.BLOCKS, 1, 1);
|
||||
}
|
||||
}
|
||||
BlockPos otherEnd = offset(pos, facing.getOpposite(), mirrored, 0,
|
||||
offsets[offsets.length - 1] + mechanical[mechanical.length - 1].getLength(), 0);
|
||||
|
@ -598,4 +598,4 @@ public class TileEntityMechMB extends TileEntityIWMultiblock implements ITickabl
|
|||
}
|
||||
return aabb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ public class ClientProxy extends CommonProxy {
|
|||
m.entryRenderPost();
|
||||
m.fontRenderer.setUnicodeFlag(uni);
|
||||
List<ManualPages> marxEntry = splitter.toManualEntry();
|
||||
m.addEntry("industrialwires.marx", IndustrialWires.MODID, marxEntry.toArray(new ManualPages[marxEntry.size()]));
|
||||
m.addEntry("industrialwires.marx", IndustrialWires.MODID, marxEntry.toArray(new ManualPages[0]));
|
||||
ClientCommandHandler.instance.registerCommand(new CommandIWClient());
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,6 @@ public class ClientProxy extends CommonProxy {
|
|||
private static ResourceLocation jacobsEnd = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_end");//~210 ms ~= 4 ticks
|
||||
private static ResourceLocation marxBang = new ResourceLocation(IndustrialWires.MODID, "marx_bang");
|
||||
private static ResourceLocation marxPop = new ResourceLocation(IndustrialWires.MODID, "marx_pop");
|
||||
private static ResourceLocation mmbBang = new ResourceLocation(IndustrialWires.MODID, "mech_mb_breaking");
|
||||
private static ResourceLocation turnFast = new ResourceLocation(IndustrialWires.MODID, "mech_mb_fast");
|
||||
private static ResourceLocation turnSlow = new ResourceLocation(IndustrialWires.MODID, "mech_mb_slow");
|
||||
|
||||
|
@ -360,15 +359,6 @@ public class ClientProxy extends CommonProxy {
|
|||
addSound(te.getPos(), sound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMechMBBang(TileEntityMechMB te, float volume) {
|
||||
PositionedSoundRecord sound = new PositionedSoundRecord(mmbBang, SoundCategory.BLOCKS, volume, 1,
|
||||
false, 0, ISound.AttenuationType.LINEAR, te.getPos().getX(), te.getPos().getY(),
|
||||
te.getPos().getZ());
|
||||
ClientUtils.mc().getSoundHandler().playSound(sound);
|
||||
//This won't be added to the list since it's short and will play while the TE is being destroyed
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMechMBTurningSound(TileEntityMechMB te, MechEnergy energy) {
|
||||
final double MIN_SPEED = 5;
|
||||
|
@ -377,7 +367,8 @@ public class ClientProxy extends CommonProxy {
|
|||
boolean adjusting = energy.isAdjusting();
|
||||
double speedToUse = energy.getSpeed()-MIN_SPEED;//Volume should be zero by the time the sound stops
|
||||
float lambda = MathHelper.clamp((float) speedToUse / 20 - .5F, 0, 1);
|
||||
float totalVolume = (float) (energy.weight / 50e3 * Math.sqrt(speedToUse));
|
||||
float totalVolume = (float) (energy.weight / 20e3 * Math.sqrt(speedToUse));
|
||||
totalVolume = Math.min(totalVolume, 2);
|
||||
float pitch = (float) Math.min(Math.sqrt(speedToUse), 3);
|
||||
if (lambda > 0) {
|
||||
PositionedSoundRecord sound = new PositionedSoundRecord(turnFast, SoundCategory.BLOCKS, lambda * totalVolume, pitch,
|
||||
|
|
|
@ -24,7 +24,6 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public enum Material {
|
||||
//TODO max speed
|
||||
COPPER(8.96, 220, "blocks/storage_copper"),
|
||||
ALUMINUM(2.7, 45, "blocks/storage_aluminum"),
|
||||
LEAD(11.34, 12, "blocks/storage_lead"),
|
||||
|
@ -33,7 +32,8 @@ public enum Material {
|
|||
GOLD(19.3, 100, new ResourceLocation("minecraft", "blocks/gold_block")),
|
||||
URANIUM(19.1, 400, "blocks/storage_uranium_side"),// This is a bit silly. But why not.
|
||||
CONSTANTAN(8.885, 600, "blocks/storage_constantan"),
|
||||
ELECTRUM((SILVER.density + GOLD.density) / 2, (SILVER.tensileStrength + GOLD.tensileStrength) / 2, "blocks/storage_electrum"),//Tensile strength is a guess ((GOLD+SILVER)/2), if anyone has better data I'll put it in
|
||||
//Tensile strength is a guess ((GOLD+SILVER)/2), if anyone has better data I'll put it in
|
||||
ELECTRUM((SILVER.density + GOLD.density) / 2, (SILVER.tensileStrength + GOLD.tensileStrength) / 2, "blocks/storage_electrum"),
|
||||
STEEL(7.874, 1250, "blocks/storage_steel"),
|
||||
IRON(7.874, 350, new ResourceLocation("minecraft", "blocks/iron_block")),
|
||||
DIAMOND(3.5, 2800, new ResourceLocation("minecraft", "blocks/diamond_block"));
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package malte0811.industrialWires.converter;
|
||||
|
||||
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -70,7 +69,6 @@ public final class MechEnergy {
|
|||
public void setTargetSpeed(double speed) {
|
||||
targetSpeed = speed;
|
||||
oldSpeed = getSpeed();
|
||||
IndustrialWires.logger.info(targetSpeed+" from "+oldSpeed);
|
||||
ticksTillReached = TICKS_FOR_ADJUSTMENT;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,12 +17,15 @@ package malte0811.industrialWires.converter;
|
|||
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.converter.MechanicalMBBlockType;
|
||||
import malte0811.industrialWires.blocks.converter.TileEntityMechMB;
|
||||
import malte0811.industrialWires.client.render.TileRenderMBConverter;
|
||||
import malte0811.industrialWires.entities.EntityBrokenPart;
|
||||
import malte0811.industrialWires.util.LocalSidedWorld;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -33,6 +36,7 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -205,6 +209,24 @@ public abstract class MechMBPart {
|
|||
pos.release();
|
||||
}
|
||||
|
||||
protected void spawnBrokenParts(int count, MechEnergy energy, ResourceLocation texture) {
|
||||
Matrix4 mat = new Matrix4();
|
||||
mat.rotate(Utils.RAND.nextDouble(), 0, 0, 1);
|
||||
Vec3d baseVec = new Vec3d(0, 1.5, 0);
|
||||
for (int i = 0;i<count;i++) {
|
||||
mat.rotate(2*Math.PI / count, 0, 0, 1);
|
||||
Vec3d pos = mat.apply(baseVec);
|
||||
EntityBrokenPart e = new EntityBrokenPart(world.getWorld(), texture);
|
||||
e.setPosition(pos.x, pos.y, -.5);
|
||||
double speed = (energy.getSpeed() / getMaxSpeed()) / 1.5;
|
||||
e.motionX = pos.y * speed;
|
||||
e.motionY = -pos.x * speed;
|
||||
e.motionZ = (Utils.RAND.nextDouble() - .5) * speed / 10;
|
||||
world.spawnEntity(e);
|
||||
e.breakBlocks(speed * speed * 1.5 * 1.5);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -15,11 +15,8 @@
|
|||
|
||||
package malte0811.industrialWires.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import blusunrize.immersiveengineering.common.util.chickenbones.Matrix4;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.converter.MechanicalMBBlockType;
|
||||
import malte0811.industrialWires.entities.EntityBrokenPart;
|
||||
import malte0811.industrialWires.util.LocalSidedWorld;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -34,7 +31,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
@ -147,21 +143,7 @@ public class MechPartFlywheel extends MechMBPart {
|
|||
}
|
||||
}
|
||||
if (failed) {
|
||||
Matrix4 mat = new Matrix4();
|
||||
mat.rotate(Utils.RAND.nextDouble(), 0, 0, 1);
|
||||
Vec3d baseVec = new Vec3d(0, 1.5, 0);
|
||||
for (int i = 0;i<8;i++) {
|
||||
mat.rotate(Math.PI/4, 0, 0, 1);
|
||||
Vec3d pos = mat.apply(baseVec);
|
||||
EntityBrokenPart e = new EntityBrokenPart(world.getWorld(), material.blockTexture);
|
||||
e.setPosition(pos.x, pos.y, -.5);
|
||||
double speed = (energy.getSpeed()/ getMaxSpeed())/1.5;
|
||||
e.motionX = pos.y*speed;
|
||||
e.motionY = -pos.x*speed;
|
||||
e.motionZ = (Utils.RAND.nextDouble()-.5)*speed/10;
|
||||
world.spawnEntity(e);
|
||||
e.breakBlocks(speed*speed*1.5*1.5);
|
||||
}
|
||||
spawnBrokenParts(8, energy, material.blockTexture);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
package malte0811.industrialWires.converter;
|
||||
|
||||
import blusunrize.immersiveengineering.ImmersiveEngineering;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.converter.MechanicalMBBlockType;
|
||||
|
@ -91,7 +92,7 @@ public class MechPartSingleCoil extends MechMBPart implements IMBPartElectric {
|
|||
|
||||
@Override
|
||||
public double getMaxSpeed() {
|
||||
return 200;
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,6 +155,8 @@ public class MechPartSingleCoil extends MechMBPart implements IMBPartElectric {
|
|||
return 0b111_111_111;
|
||||
}
|
||||
|
||||
private static final ResourceLocation COIL_TEXTURE = new ResourceLocation(ImmersiveEngineering.MODID,
|
||||
"blocks/metal_decoration0_coil_lv_side");
|
||||
@Override
|
||||
public void disassemble(boolean failed, MechEnergy energy) {
|
||||
setDefaultShaft(BlockPos.ORIGIN);
|
||||
|
@ -161,6 +164,9 @@ public class MechPartSingleCoil extends MechMBPart implements IMBPartElectric {
|
|||
for (int i = -1;i<=1;i+=2) {
|
||||
setCoil(BlockPos.ORIGIN.up(i));
|
||||
}
|
||||
} else {
|
||||
int count = has4Phases()?8:2;
|
||||
spawnBrokenParts(count, energy, COIL_TEXTURE);
|
||||
}
|
||||
for (int i = -1; i <= 1; i+=2) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
package malte0811.industrialWires.entities;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
|
@ -27,9 +25,9 @@ import net.minecraft.network.datasync.DataSerializer;
|
|||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -39,7 +37,7 @@ import java.util.List;
|
|||
|
||||
import static malte0811.industrialWires.util.NBTKeys.TEXTURE;
|
||||
|
||||
public class EntityBrokenPart extends EntityArrow {
|
||||
public class EntityBrokenPart extends /*EntityArrow*/ Entity {
|
||||
public static final DataSerializer<ResourceLocation> RES_LOC_SERIALIZER = new DataSerializer<ResourceLocation>() {
|
||||
@Override
|
||||
public void write(@Nonnull PacketBuffer buf, @Nonnull ResourceLocation value) {
|
||||
|
@ -67,20 +65,24 @@ public class EntityBrokenPart extends EntityArrow {
|
|||
}
|
||||
};
|
||||
private static DataParameter<ResourceLocation> MARKER_TEXTURE;
|
||||
|
||||
static {
|
||||
DataSerializers.registerSerializer(RES_LOC_SERIALIZER);
|
||||
MARKER_TEXTURE = EntityDataManager.createKey(EntityBrokenPart.class, RES_LOC_SERIALIZER);
|
||||
}
|
||||
|
||||
private static final double HARDNESS_MAX = 15;
|
||||
private static final double DESPAWN_DELAY = 400;
|
||||
private static final double DESPAWN_DELAY_GROUND = 400;
|
||||
private static final double DESPAWN_DELAY_AIR = 60*20;
|
||||
|
||||
public ResourceLocation texture = new ResourceLocation("blocks/stone");
|
||||
private static final ResourceLocation DEFAULT_TEXTURE = new ResourceLocation("blocks/stone");
|
||||
public ResourceLocation texture = DEFAULT_TEXTURE;
|
||||
private int timeUnmoved = 0;
|
||||
|
||||
public EntityBrokenPart(World worldIn) {
|
||||
super(worldIn);
|
||||
setSize(.5F, .5F);
|
||||
preventEntitySpawning = true;
|
||||
}
|
||||
|
||||
public EntityBrokenPart(World worldIn, ResourceLocation texture) {
|
||||
|
@ -89,46 +91,109 @@ public class EntityBrokenPart extends EntityArrow {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (firstUpdate &&!world.isRemote && texture != null) {
|
||||
public void onEntityUpdate() {
|
||||
if (firstUpdate && !world.isRemote && texture != null) {
|
||||
dataManager.set(MARKER_TEXTURE, texture);
|
||||
}
|
||||
onEntityUpdate();
|
||||
|
||||
|
||||
//movement logic, modified to simulate higher speed than MC is happy about
|
||||
{
|
||||
this.motionY -= 0.02;
|
||||
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
|
||||
this.motionX *= 0.98;
|
||||
this.motionY *= 0.98;
|
||||
this.motionZ *= 0.98;
|
||||
|
||||
if (this.onGround) {
|
||||
this.motionX *= .7;
|
||||
this.motionZ *= .7;
|
||||
this.motionY *= -0.5D;
|
||||
}
|
||||
}
|
||||
if (world.isRemote) {
|
||||
super.onEntityUpdate();
|
||||
if (world.isRemote && DEFAULT_TEXTURE.equals(texture)) {
|
||||
texture = dataManager.get(MARKER_TEXTURE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
double speedSq = motionX * motionX + motionY * motionY + motionZ * motionZ;
|
||||
breakBlocks(speedSq);
|
||||
if (speedSq>.25) {
|
||||
List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, getEntityBoundingBox());
|
||||
for (EntityLivingBase e:entities) {
|
||||
e.attackEntityFrom(DamageSource.FALLING_BLOCK, 7);
|
||||
//Taken from EntityIEProjectile and modified afterwards
|
||||
private int ticksOnGround;
|
||||
private int ticksInAir;
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
this.onEntityUpdate();
|
||||
|
||||
if (this.onGround) {
|
||||
++this.ticksOnGround;
|
||||
if (this.ticksOnGround >= DESPAWN_DELAY_GROUND) {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
if (speedSq<1e-3) {
|
||||
timeUnmoved++;
|
||||
if (timeUnmoved>DESPAWN_DELAY) {
|
||||
setDead();
|
||||
} else {
|
||||
++this.ticksInAir;
|
||||
|
||||
if (ticksInAir >= DESPAWN_DELAY_AIR) {
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3d currentPos = new Vec3d(this.posX, this.posY, this.posZ);
|
||||
Vec3d nextPos = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
RayTraceResult mop = this.world.rayTraceBlocks(currentPos, nextPos, false, true, false);
|
||||
|
||||
currentPos = new Vec3d(this.posX, this.posY, this.posZ);
|
||||
|
||||
if (mop != null)
|
||||
nextPos = new Vec3d(mop.hitVec.x, mop.hitVec.y, mop.hitVec.z);
|
||||
else
|
||||
nextPos = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
|
||||
if (mop == null || mop.entityHit == null) {
|
||||
Entity entity = null;
|
||||
List<Entity> list = this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1), Entity::canBeCollidedWith);
|
||||
double d0 = 0.0D;
|
||||
for (Entity e : list) {
|
||||
if (e.canBeCollidedWith()) {
|
||||
float f = 0.3F;
|
||||
AxisAlignedBB axisalignedbb = e.getEntityBoundingBox().grow((double) f, (double) f, (double) f);
|
||||
RayTraceResult movingobjectposition1 = axisalignedbb.calculateIntercept(currentPos, nextPos);
|
||||
|
||||
if (movingobjectposition1 != null) {
|
||||
double d1 = currentPos.distanceTo(movingobjectposition1.hitVec);
|
||||
if (d1 < d0 || d0 == 0.0D) {
|
||||
entity = e;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entity != null)
|
||||
mop = new RayTraceResult(entity);
|
||||
}
|
||||
|
||||
if (mop != null) {
|
||||
if (mop.entityHit != null) {
|
||||
this.attackEntity(mop.entityHit);
|
||||
}
|
||||
}
|
||||
|
||||
float motion = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
|
||||
this.rotationPitch = (float) (Math.atan2(this.motionY, (double) motion) * 180.0D / Math.PI);
|
||||
while (this.rotationPitch - this.prevRotationPitch < -180.0F) {
|
||||
this.prevRotationPitch -= 360.0F;
|
||||
}
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
|
||||
this.prevRotationPitch += 360.0F;
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
|
||||
this.prevRotationYaw += 360.0F;
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
}
|
||||
float movementDecay = onGround?.5F:.99F;
|
||||
|
||||
if (this.isInWater()) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
float f3 = 0.25F;
|
||||
this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double) f3,
|
||||
this.posY - this.motionY * (double) f3, this.posZ - this.motionZ * (double) f3, this.motionX, this.motionY, this.motionZ);
|
||||
}
|
||||
movementDecay *= 0.8F;
|
||||
}
|
||||
this.motionX *= movementDecay;
|
||||
this.motionY *= movementDecay;
|
||||
this.motionZ *= movementDecay;
|
||||
this.motionY -= .05;
|
||||
breakBlocks(getSpeedSq());
|
||||
this.doBlockCollisions();
|
||||
move(MoverType.SELF, motionX, motionY, motionZ);
|
||||
}
|
||||
|
||||
public void breakBlocks(double speedSq) {
|
||||
|
@ -151,17 +216,13 @@ public class EntityBrokenPart extends EntityArrow {
|
|||
if (speed < 0) {
|
||||
speed = Math.sqrt(speedSq);
|
||||
}
|
||||
if (hardness>0&&hardness < HARDNESS_MAX*speed) {
|
||||
if (hardness > 0 && hardness < HARDNESS_MAX * speed) {
|
||||
world.setBlockToAir(iter);
|
||||
double factor = (HARDNESS_MAX*speed - hardness) / (HARDNESS_MAX*speed);
|
||||
double factor = (HARDNESS_MAX * speed - hardness) / (HARDNESS_MAX * speed);
|
||||
motionX *= factor;
|
||||
motionY *= factor;
|
||||
motionZ *= factor;
|
||||
speed *= factor;
|
||||
} else {
|
||||
motionX = 0;
|
||||
motionY = 0;
|
||||
motionZ = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +237,7 @@ public class EntityBrokenPart extends EntityArrow {
|
|||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
dataManager.register(MARKER_TEXTURE, new ResourceLocation("blocks/stone"));
|
||||
dataManager.register(MARKER_TEXTURE, DEFAULT_TEXTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,9 +257,21 @@ public class EntityBrokenPart extends EntityArrow {
|
|||
return getEntityBoundingBox();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private void attackEntity(Entity e) {
|
||||
e.attackEntityFrom(DamageSource.FALLING_BLOCK, 20*getSpeedSq());
|
||||
}
|
||||
|
||||
private float getSpeedSq() {
|
||||
return (float) (motionX*motionX+motionY*motionY+motionZ*motionZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getArrowStack() {
|
||||
return ItemStack.EMPTY;
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePushed() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
package malte0811.industrialWires.util;
|
||||
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -61,7 +60,6 @@ public class LocalSidedWorld {
|
|||
|
||||
public void spawnEntity(Entity e) {
|
||||
Vec3d pos = getRealPos(e.getPositionVector());
|
||||
IndustrialWires.logger.info("Spawning at {} (relative), {} (absolute)", e.getPositionVector(), pos);
|
||||
e.setPosition(pos.x, pos.y, pos.z);
|
||||
Vec3d motion = getRealDirection(new Vec3d(e.motionX, e.motionY, e.motionZ));
|
||||
e.motionX = motion.x;
|
||||
|
|
Loading…
Reference in a new issue