forked from Thorfusion/Mekanism-Community-Edition
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
198 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/main/java/mekanism/common/entity/EntityMekaSuitArmor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package mekanism.common.entity; | ||
|
||
import net.minecraft.block.material.Material; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.MoverType; | ||
import net.minecraft.entity.item.EntityItem; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.DamageSource; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
public class EntityMekaSuitArmor extends EntityItem { | ||
|
||
public EntityMekaSuitArmor(World world, Entity original, ItemStack stack) { | ||
this(world, original.posX, original.posY, original.posZ, stack); | ||
setPickupDelay(40); | ||
motionX = original.motionX; | ||
motionY = original.motionY; | ||
motionZ = original.motionZ; | ||
setItem(stack); | ||
} | ||
|
||
public EntityMekaSuitArmor(World world, double x, double y, double z, ItemStack stack) { | ||
super(world, x, y, z); | ||
setItem(stack); | ||
} | ||
|
||
@Override | ||
protected void dealFireDamage(int damage) { | ||
} | ||
|
||
@Override | ||
public boolean attackEntityFrom(DamageSource source, float damage) { | ||
return source.getDamageType().equals("outOfWorld"); | ||
} | ||
|
||
@Override | ||
public void onUpdate() { | ||
ItemStack stack = getDataManager().get(ITEM); | ||
if (!stack.isEmpty()) { | ||
if (stack.getItem().onEntityItemUpdate(this)) { | ||
return; | ||
} | ||
} | ||
if (getItem().isEmpty()) { | ||
setDead(); | ||
} else { | ||
super.onUpdate(); | ||
|
||
if (pickupDelay > 0) { | ||
--pickupDelay; | ||
} | ||
|
||
prevPosX = posX; | ||
prevPosY = posY; | ||
prevPosZ = posZ; | ||
motionY -= 0.03999999910593033D; | ||
noClip = pushOutOfBlocks(posX, (getEntityBoundingBox().minY + getEntityBoundingBox().maxY) / 2.0D, posZ); | ||
move(MoverType.SELF, motionX, motionY, motionZ); | ||
boolean flag = (int) prevPosX != (int) posX || (int) prevPosY != (int) posY || (int) prevPosZ != (int) posZ; | ||
|
||
if (flag || ticksExisted % 25 == 0) { | ||
if (world.getBlockState(new BlockPos(posX, posY, posZ)).getMaterial() == Material.LAVA) { | ||
motionY = 0.20000000298023224D; | ||
motionX = (rand.nextFloat() - rand.nextFloat()) * 0.2F; | ||
motionZ = (rand.nextFloat() - rand.nextFloat()) * 0.2F; | ||
//this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); | ||
} | ||
|
||
if (!world.isRemote) { | ||
searchForOtherItemsNearby(); | ||
} | ||
} | ||
|
||
float f = 0.98F; | ||
|
||
if (onGround) { | ||
f = world.getBlockState(new BlockPos(posX, getEntityBoundingBox().minY - 1, posZ)).getBlock().slipperiness * 0.98F; | ||
} | ||
|
||
motionX *= f; | ||
motionY *= 0.9800000190734863D; | ||
motionZ *= f; | ||
|
||
if (onGround) { | ||
motionY *= -0.5D; | ||
} | ||
|
||
++age; | ||
|
||
ItemStack item = getDataManager().get(ITEM); | ||
|
||
if (!world.isRemote && age >= lifespan) { | ||
if (item.isEmpty()) { | ||
setDead(); | ||
} | ||
|
||
} | ||
|
||
if (!item.isEmpty() && item.getCount() <= 0) { | ||
setDead(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters