pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -30,33 +29,29 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
public abstract class AEBaseEntityItem extends ItemEntity {
|
||||
|
||||
public abstract class AEBaseEntityItem extends ItemEntity
|
||||
{
|
||||
protected AEBaseEntityItem(EntityType<? extends AEBaseEntityItem> entityType, final World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
protected AEBaseEntityItem( EntityType<? extends AEBaseEntityItem> entityType, final World world )
|
||||
{
|
||||
super( entityType, world );
|
||||
}
|
||||
protected AEBaseEntityItem(EntityType<? extends AEBaseEntityItem> entityType, final World world, final double x,
|
||||
final double y, final double z, final ItemStack stack) {
|
||||
this(entityType, world);
|
||||
this.setPosition(x, y, z);
|
||||
this.rotationYaw = this.rand.nextFloat() * 360.0F;
|
||||
this.setMotion(this.rand.nextDouble() * 0.2D - 0.1D, 0.2D, this.rand.nextDouble() * 0.2D - 0.1D);
|
||||
this.setItem(stack);
|
||||
this.lifespan = stack.getEntityLifespan(world);
|
||||
}
|
||||
|
||||
protected AEBaseEntityItem( EntityType<? extends AEBaseEntityItem> entityType, final World world, final double x, final double y, final double z, final ItemStack stack )
|
||||
{
|
||||
this(entityType, world);
|
||||
this.setPosition(x, y, z);
|
||||
this.rotationYaw = this.rand.nextFloat() * 360.0F;
|
||||
this.setMotion(this.rand.nextDouble() * 0.2D - 0.1D, 0.2D, this.rand.nextDouble() * 0.2D - 0.1D);
|
||||
this.setItem(stack);
|
||||
this.lifespan = stack.getEntityLifespan(world);
|
||||
}
|
||||
protected List<Entity> getCheckedEntitiesWithinAABBExcludingEntity(final AxisAlignedBB region) {
|
||||
return this.world.getEntitiesWithinAABBExcludingEntity(this, region);
|
||||
}
|
||||
|
||||
protected List<Entity> getCheckedEntitiesWithinAABBExcludingEntity( final AxisAlignedBB region )
|
||||
{
|
||||
return this.world.getEntitiesWithinAABBExcludingEntity( this, region );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
@Override
|
||||
public IPacket<?> createSpawnPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -35,138 +34,117 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class EntityChargedQuartz extends AEBaseEntityItem {
|
||||
|
||||
public final class EntityChargedQuartz extends AEBaseEntityItem
|
||||
{
|
||||
public static EntityType<EntityChargedQuartz> TYPE;
|
||||
|
||||
public static EntityType<EntityChargedQuartz> TYPE;
|
||||
private int delay = 0;
|
||||
private int transformTime = 0;
|
||||
|
||||
private int delay = 0;
|
||||
private int transformTime = 0;
|
||||
public EntityChargedQuartz(EntityType<? extends EntityChargedQuartz> entityType, World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
public EntityChargedQuartz(EntityType<? extends EntityChargedQuartz> entityType, World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
public EntityChargedQuartz(final World w, final double x, final double y, final double z, final ItemStack is) {
|
||||
super(TYPE, w, x, y, z, is);
|
||||
}
|
||||
|
||||
public EntityChargedQuartz(final World w, final double x, final double y, final double z, final ItemStack is )
|
||||
{
|
||||
super( TYPE, w, x, y, z, is );
|
||||
}
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
super.tick();
|
||||
if (this.removed || !AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_FLUIX)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.removed || !AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_FLUIX ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (world.isRemote && this.delay > 30 && AEConfig.instance().isEnableEffects()) {
|
||||
AppEng.proxy.spawnEffect(EffectType.Lightning, this.world, this.getPosX(), this.getPosY(), this.getPosZ(),
|
||||
null);
|
||||
this.delay = 0;
|
||||
}
|
||||
|
||||
if( world.isRemote && this.delay > 30 && AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
AppEng.proxy.spawnEffect( EffectType.Lightning, this.world, this.getPosX(), this.getPosY(), this.getPosZ(), null );
|
||||
this.delay = 0;
|
||||
}
|
||||
this.delay++;
|
||||
|
||||
this.delay++;
|
||||
final int j = MathHelper.floor(this.getPosX());
|
||||
final int i = MathHelper.floor((this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D);
|
||||
final int k = MathHelper.floor(this.getPosZ());
|
||||
|
||||
final int j = MathHelper.floor( this.getPosX() );
|
||||
final int i = MathHelper.floor( ( this.getBoundingBox().minY + this.getBoundingBox().maxY ) / 2.0D );
|
||||
final int k = MathHelper.floor( this.getPosZ() );
|
||||
BlockState state = this.world.getBlockState(new BlockPos(j, i, k));
|
||||
final Material mat = state.getMaterial();
|
||||
|
||||
BlockState state = this.world.getBlockState( new BlockPos( j, i, k ) );
|
||||
final Material mat = state.getMaterial();
|
||||
if (Platform.isServer() && mat.isLiquid()) {
|
||||
this.transformTime++;
|
||||
if (this.transformTime > 60) {
|
||||
if (!this.transform()) {
|
||||
this.transformTime = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.transformTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( Platform.isServer() && mat.isLiquid() )
|
||||
{
|
||||
this.transformTime++;
|
||||
if( this.transformTime > 60 )
|
||||
{
|
||||
if( !this.transform() )
|
||||
{
|
||||
this.transformTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.transformTime = 0;
|
||||
}
|
||||
}
|
||||
private boolean transform() {
|
||||
final ItemStack item = this.getItem();
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
private boolean transform()
|
||||
{
|
||||
final ItemStack item = this.getItem();
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
if (materials.certusQuartzCrystalCharged().isSameAs(item)) {
|
||||
final AxisAlignedBB region = new AxisAlignedBB(this.getPosX() - 1, this.getPosY() - 1, this.getPosZ() - 1,
|
||||
this.getPosX() + 1, this.getPosY() + 1, this.getPosZ() + 1);
|
||||
final List<Entity> l = this.getCheckedEntitiesWithinAABBExcludingEntity(region);
|
||||
|
||||
if( materials.certusQuartzCrystalCharged().isSameAs( item ) )
|
||||
{
|
||||
final AxisAlignedBB region = new AxisAlignedBB( this.getPosX() - 1, this.getPosY() - 1, this
|
||||
.getPosZ() - 1, this.getPosX() + 1, this.getPosY() + 1, this.getPosZ() + 1 );
|
||||
final List<Entity> l = this.getCheckedEntitiesWithinAABBExcludingEntity( region );
|
||||
ItemEntity redstone = null;
|
||||
ItemEntity netherQuartz = null;
|
||||
|
||||
ItemEntity redstone = null;
|
||||
ItemEntity netherQuartz = null;
|
||||
for (final Entity e : l) {
|
||||
if (e instanceof ItemEntity && !e.removed) {
|
||||
final ItemStack other = ((ItemEntity) e).getItem();
|
||||
if (!other.isEmpty()) {
|
||||
if (ItemStack.areItemsEqual(other, new ItemStack(Items.REDSTONE))) {
|
||||
redstone = (ItemEntity) e;
|
||||
}
|
||||
|
||||
for( final Entity e : l )
|
||||
{
|
||||
if( e instanceof ItemEntity && !e.removed )
|
||||
{
|
||||
final ItemStack other = ( (ItemEntity) e ).getItem();
|
||||
if( !other.isEmpty() )
|
||||
{
|
||||
if( ItemStack.areItemsEqual( other, new ItemStack( Items.REDSTONE ) ) )
|
||||
{
|
||||
redstone = (ItemEntity) e;
|
||||
}
|
||||
if (ItemStack.areItemsEqual(other, new ItemStack(Items.QUARTZ))) {
|
||||
netherQuartz = (ItemEntity) e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ItemStack.areItemsEqual( other, new ItemStack( Items.QUARTZ ) ) )
|
||||
{
|
||||
netherQuartz = (ItemEntity) e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (redstone != null && netherQuartz != null) {
|
||||
this.getItem().grow(-1);
|
||||
redstone.getItem().grow(-1);
|
||||
netherQuartz.getItem().grow(-1);
|
||||
|
||||
if( redstone != null && netherQuartz != null )
|
||||
{
|
||||
this.getItem().grow( -1 );
|
||||
redstone.getItem().grow( -1 );
|
||||
netherQuartz.getItem().grow( -1 );
|
||||
if (this.getItem().getCount() <= 0) {
|
||||
this.remove();
|
||||
}
|
||||
|
||||
if( this.getItem().getCount() <= 0 )
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
if (redstone.getItem().getCount() <= 0) {
|
||||
redstone.remove();
|
||||
}
|
||||
|
||||
if( redstone.getItem().getCount() <= 0 )
|
||||
{
|
||||
redstone.remove();
|
||||
}
|
||||
if (netherQuartz.getItem().getCount() <= 0) {
|
||||
netherQuartz.remove();
|
||||
}
|
||||
|
||||
if( netherQuartz.getItem().getCount() <= 0 )
|
||||
{
|
||||
netherQuartz.remove();
|
||||
}
|
||||
materials.fluixCrystal().maybeStack(2).ifPresent(is -> {
|
||||
final ItemEntity entity = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(),
|
||||
is);
|
||||
|
||||
materials.fluixCrystal().maybeStack( 2 ).ifPresent( is ->
|
||||
{
|
||||
final ItemEntity entity = new ItemEntity( this.world, this.getPosX(), this.getPosY(), this.getPosZ(), is );
|
||||
this.world.addEntity(entity);
|
||||
});
|
||||
|
||||
this.world.addEntity( entity );
|
||||
} );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,62 +18,54 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
// This is not supposed to ever spawn on the server-side
|
||||
public final class EntityFloatingItem extends AEBaseEntityItem
|
||||
{
|
||||
public final class EntityFloatingItem extends AEBaseEntityItem {
|
||||
|
||||
public static EntityType<EntityFloatingItem> TYPE;
|
||||
public static EntityType<EntityFloatingItem> TYPE;
|
||||
|
||||
private ICanDie parent;
|
||||
private int superDeath = 0;
|
||||
private float progress = 0;
|
||||
private ICanDie parent;
|
||||
private int superDeath = 0;
|
||||
private float progress = 0;
|
||||
|
||||
public EntityFloatingItem(EntityType<? extends AEBaseEntityItem> entityType, World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
public EntityFloatingItem(EntityType<? extends AEBaseEntityItem> entityType, World world) {
|
||||
super(entityType, world);
|
||||
}
|
||||
|
||||
public EntityFloatingItem(final ICanDie parent, final World world, final double x, final double y, final double z, final ItemStack stack )
|
||||
{
|
||||
super( TYPE, world, x, y, z, stack );
|
||||
this.setMotion( 0, 0, 0 );
|
||||
this.rotationYaw = 0;
|
||||
this.parent = parent;
|
||||
}
|
||||
public EntityFloatingItem(final ICanDie parent, final World world, final double x, final double y, final double z,
|
||||
final ItemStack stack) {
|
||||
super(TYPE, world, x, y, z, stack);
|
||||
this.setMotion(0, 0, 0);
|
||||
this.rotationYaw = 0;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if( !this.removed && this.parent.isDead() )
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
@Override
|
||||
public void tick() {
|
||||
if (!this.removed && this.parent.isDead()) {
|
||||
this.remove();
|
||||
}
|
||||
|
||||
if( this.superDeath > 100 )
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
this.superDeath++;
|
||||
if (this.superDeath > 100) {
|
||||
this.remove();
|
||||
}
|
||||
this.superDeath++;
|
||||
|
||||
this.setNoDespawn();
|
||||
}
|
||||
this.setNoDespawn();
|
||||
}
|
||||
|
||||
public void setProgress( final float progress )
|
||||
{
|
||||
this.progress = progress;
|
||||
if( this.progress > 0.99 )
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
public void setProgress(final float progress) {
|
||||
this.progress = progress;
|
||||
if (this.progress > 0.99) {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
float getProgress()
|
||||
{
|
||||
return this.progress;
|
||||
}
|
||||
float getProgress() {
|
||||
return this.progress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
|
||||
import appeng.items.misc.ItemCrystalSeed;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityType;
|
||||
@@ -31,185 +29,157 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.implementations.items.IGrowableCrystal;
|
||||
import appeng.api.implementations.tiles.ICrystalGrowthAccelerator;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.items.misc.ItemCrystalSeed;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class EntityGrowingCrystal extends AEBaseEntityItem {
|
||||
|
||||
public final class EntityGrowingCrystal extends AEBaseEntityItem
|
||||
{
|
||||
public static EntityType<EntityGrowingCrystal> TYPE;
|
||||
|
||||
public static EntityType<EntityGrowingCrystal> TYPE;
|
||||
private int progress_1000 = 0;
|
||||
|
||||
private int progress_1000 = 0;
|
||||
public EntityGrowingCrystal(EntityType<? extends EntityGrowingCrystal> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
public EntityGrowingCrystal(EntityType<? extends EntityGrowingCrystal> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
public EntityGrowingCrystal(final World w, final double x, final double y, final double z, final ItemStack is) {
|
||||
super(TYPE, w, x, y, z, is);
|
||||
this.setNoDespawn();
|
||||
}
|
||||
|
||||
public EntityGrowingCrystal(final World w, final double x, final double y, final double z, final ItemStack is )
|
||||
{
|
||||
super( TYPE, w, x, y, z, is );
|
||||
this.setNoDespawn();
|
||||
}
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
super.tick();
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_PURIFICATION)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_PURIFICATION ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final ItemStack is = this.getItem();
|
||||
final Item gc = is.getItem();
|
||||
|
||||
final ItemStack is = this.getItem();
|
||||
final Item gc = is.getItem();
|
||||
if (gc instanceof IGrowableCrystal) // if it changes this just stops being an issue...
|
||||
{
|
||||
final int j = MathHelper.floor(this.getPosX());
|
||||
final int i = MathHelper.floor((this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D);
|
||||
final int k = MathHelper.floor(this.getPosZ());
|
||||
|
||||
if( gc instanceof IGrowableCrystal ) // if it changes this just stops being an issue...
|
||||
{
|
||||
final int j = MathHelper.floor( this.getPosX() );
|
||||
final int i = MathHelper.floor( ( this.getBoundingBox().minY + this.getBoundingBox().maxY ) / 2.0D );
|
||||
final int k = MathHelper.floor( this.getPosZ() );
|
||||
final BlockState state = this.world.getBlockState(new BlockPos(j, i, k));
|
||||
final Material mat = state.getMaterial();
|
||||
final IGrowableCrystal cry = (IGrowableCrystal) is.getItem();
|
||||
|
||||
final BlockState state = this.world.getBlockState( new BlockPos( j, i, k ) );
|
||||
final Material mat = state.getMaterial();
|
||||
final IGrowableCrystal cry = (IGrowableCrystal) is.getItem();
|
||||
final float multiplier = cry.getMultiplier(state.getBlock(), mat);
|
||||
final int speed = (int) Math.max(1, this.getSpeed(j, i, k) * multiplier);
|
||||
|
||||
final float multiplier = cry.getMultiplier( state.getBlock(), mat );
|
||||
final int speed = (int) Math.max( 1, this.getSpeed( j, i, k ) * multiplier );
|
||||
final boolean isClient = Platform.isClient();
|
||||
|
||||
final boolean isClient = Platform.isClient();
|
||||
if (mat.isLiquid()) {
|
||||
if (isClient) {
|
||||
this.progress_1000++;
|
||||
} else {
|
||||
this.progress_1000 += speed;
|
||||
}
|
||||
} else {
|
||||
this.progress_1000 = 0;
|
||||
}
|
||||
|
||||
if( mat.isLiquid() )
|
||||
{
|
||||
if( isClient )
|
||||
{
|
||||
this.progress_1000++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.progress_1000 += speed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.progress_1000 = 0;
|
||||
}
|
||||
if (isClient) {
|
||||
int len = 40;
|
||||
|
||||
if( isClient )
|
||||
{
|
||||
int len = 40;
|
||||
if (speed > 2) {
|
||||
len = 20;
|
||||
}
|
||||
|
||||
if( speed > 2 )
|
||||
{
|
||||
len = 20;
|
||||
}
|
||||
if (speed > 90) {
|
||||
len = 15;
|
||||
}
|
||||
|
||||
if( speed > 90 )
|
||||
{
|
||||
len = 15;
|
||||
}
|
||||
if (speed > 150) {
|
||||
len = 10;
|
||||
}
|
||||
|
||||
if( speed > 150 )
|
||||
{
|
||||
len = 10;
|
||||
}
|
||||
if (speed > 240) {
|
||||
len = 7;
|
||||
}
|
||||
|
||||
if( speed > 240 )
|
||||
{
|
||||
len = 7;
|
||||
}
|
||||
if (speed > 360) {
|
||||
len = 3;
|
||||
}
|
||||
|
||||
if( speed > 360 )
|
||||
{
|
||||
len = 3;
|
||||
}
|
||||
if (speed > 500) {
|
||||
len = 1;
|
||||
}
|
||||
|
||||
if( speed > 500 )
|
||||
{
|
||||
len = 1;
|
||||
}
|
||||
if (this.progress_1000 >= len) {
|
||||
this.progress_1000 = 0;
|
||||
AppEng.proxy.spawnEffect(EffectType.Vibrant, this.world, this.getPosX(), this.getPosY() + 0.2,
|
||||
this.getPosZ(), null);
|
||||
}
|
||||
} else {
|
||||
if (this.progress_1000 > 1000) {
|
||||
this.progress_1000 -= 1000;
|
||||
// We need to copy the stack or the change detection will not work and not sync
|
||||
// this new stack to the client
|
||||
ItemStack newItem = cry.triggerGrowth(is.copy());
|
||||
this.setItem(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.progress_1000 >= len )
|
||||
{
|
||||
this.progress_1000 = 0;
|
||||
AppEng.proxy.spawnEffect( EffectType.Vibrant, this.world, this.getPosX(), this.getPosY() + 0.2, this.getPosZ(), null );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.progress_1000 > 1000 )
|
||||
{
|
||||
this.progress_1000 -= 1000;
|
||||
// We need to copy the stack or the change detection will not work and not sync
|
||||
// this new stack to the client
|
||||
ItemStack newItem = cry.triggerGrowth(is.copy());
|
||||
this.setItem(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private int getSpeed(final int x, final int y, final int z) {
|
||||
final int per = 80;
|
||||
final float mul = 0.3f;
|
||||
|
||||
private int getSpeed( final int x, final int y, final int z )
|
||||
{
|
||||
final int per = 80;
|
||||
final float mul = 0.3f;
|
||||
int qty = 0;
|
||||
|
||||
int qty = 0;
|
||||
if (this.isAccelerated(x + 1, y, z)) {
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
|
||||
if( this.isAccelerated( x + 1, y, z ) )
|
||||
{
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
if (this.isAccelerated(x, y + 1, z)) {
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
|
||||
if( this.isAccelerated( x, y + 1, z ) )
|
||||
{
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
if (this.isAccelerated(x, y, z + 1)) {
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
|
||||
if( this.isAccelerated( x, y, z + 1 ) )
|
||||
{
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
if (this.isAccelerated(x - 1, y, z)) {
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
|
||||
if( this.isAccelerated( x - 1, y, z ) )
|
||||
{
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
if (this.isAccelerated(x, y - 1, z)) {
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
|
||||
if( this.isAccelerated( x, y - 1, z ) )
|
||||
{
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
if (this.isAccelerated(x, y, z - 1)) {
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
|
||||
if( this.isAccelerated( x, y, z - 1 ) )
|
||||
{
|
||||
qty += per + qty * mul;
|
||||
}
|
||||
return qty;
|
||||
}
|
||||
|
||||
return qty;
|
||||
}
|
||||
private boolean isAccelerated(final int x, final int y, final int z) {
|
||||
final TileEntity te = this.world.getTileEntity(new BlockPos(x, y, z));
|
||||
|
||||
private boolean isAccelerated( final int x, final int y, final int z )
|
||||
{
|
||||
final TileEntity te = this.world.getTileEntity( new BlockPos( x, y, z ) );
|
||||
return te instanceof ICrystalGrowthAccelerator && ((ICrystalGrowthAccelerator) te).isPowered();
|
||||
}
|
||||
|
||||
return te instanceof ICrystalGrowthAccelerator && ( (ICrystalGrowthAccelerator) te ).isPowered();
|
||||
}
|
||||
|
||||
// Don't let seeds "float" on water surface
|
||||
@Override
|
||||
protected void applyFloatMotion() {
|
||||
ItemStack item = getItem();
|
||||
if (item.getItem() instanceof ItemCrystalSeed) {
|
||||
return;
|
||||
}
|
||||
super.applyFloatMotion();
|
||||
}
|
||||
// Don't let seeds "float" on water surface
|
||||
@Override
|
||||
protected void applyFloatMotion() {
|
||||
ItemStack item = getItem();
|
||||
if (item.getItem() instanceof ItemCrystalSeed) {
|
||||
return;
|
||||
}
|
||||
super.applyFloatMotion();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,104 +32,86 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class EntitySingularity extends AEBaseEntityItem {
|
||||
|
||||
public final class EntitySingularity extends AEBaseEntityItem
|
||||
{
|
||||
public static EntityType<EntitySingularity> TYPE;
|
||||
|
||||
public static EntityType<EntitySingularity> TYPE;
|
||||
private static int randTickSeed = 0;
|
||||
|
||||
private static int randTickSeed = 0;
|
||||
public EntitySingularity(EntityType<? extends EntitySingularity> entityType, final World w) {
|
||||
super(entityType, w);
|
||||
}
|
||||
|
||||
public EntitySingularity(EntityType<? extends EntitySingularity> entityType, final World w )
|
||||
{
|
||||
super( entityType, w );
|
||||
}
|
||||
public EntitySingularity(final World w, final double x, final double y, final double z, final ItemStack is) {
|
||||
super(TYPE, w, x, y, z, is);
|
||||
}
|
||||
|
||||
public EntitySingularity( final World w, final double x, final double y, final double z, final ItemStack is )
|
||||
{
|
||||
super( TYPE, w, x, y, z, is );
|
||||
}
|
||||
@Override
|
||||
public boolean attackEntityFrom(final DamageSource src, final float dmg) {
|
||||
if (src.isExplosion()) {
|
||||
this.doExplosion();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityFrom( final DamageSource src, final float dmg )
|
||||
{
|
||||
if( src.isExplosion() )
|
||||
{
|
||||
this.doExplosion();
|
||||
return false;
|
||||
}
|
||||
return super.attackEntityFrom(src, dmg);
|
||||
}
|
||||
|
||||
return super.attackEntityFrom( src, dmg );
|
||||
}
|
||||
private void doExplosion() {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
private void doExplosion()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.IN_WORLD_SINGULARITY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.IN_WORLD_SINGULARITY ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final ItemStack item = this.getItem();
|
||||
|
||||
final ItemStack item = this.getItem();
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
if (materials.singularity().isSameAs(item)) {
|
||||
final AxisAlignedBB region = new AxisAlignedBB(this.getPosX() - 4, this.getPosY() - 4, this.getPosZ() - 4,
|
||||
this.getPosX() + 4, this.getPosY() + 4, this.getPosZ() + 4);
|
||||
final List<Entity> l = this.getCheckedEntitiesWithinAABBExcludingEntity(region);
|
||||
|
||||
if( materials.singularity().isSameAs( item ) )
|
||||
{
|
||||
final AxisAlignedBB region = new AxisAlignedBB( this.getPosX() - 4, this.getPosY() - 4, this.getPosZ() - 4, this.getPosX() + 4, this
|
||||
.getPosY() + 4, this.getPosZ() + 4 );
|
||||
final List<Entity> l = this.getCheckedEntitiesWithinAABBExcludingEntity( region );
|
||||
for (final Entity e : l) {
|
||||
if (e instanceof ItemEntity) {
|
||||
final ItemStack other = ((ItemEntity) e).getItem();
|
||||
if (!other.isEmpty()) {
|
||||
boolean matches = false;
|
||||
|
||||
for( final Entity e : l )
|
||||
{
|
||||
if( e instanceof ItemEntity )
|
||||
{
|
||||
final ItemStack other = ( (ItemEntity) e ).getItem();
|
||||
if( !other.isEmpty() )
|
||||
{
|
||||
boolean matches = false;
|
||||
if (matches) {
|
||||
while (item.getCount() > 0 && other.getCount() > 0) {
|
||||
other.grow(-1);
|
||||
;
|
||||
if (other.getCount() == 0) {
|
||||
e.remove();
|
||||
}
|
||||
|
||||
if( matches )
|
||||
{
|
||||
while( item.getCount() > 0 && other.getCount() > 0 )
|
||||
{
|
||||
other.grow( -1 );
|
||||
;
|
||||
if( other.getCount() == 0 )
|
||||
{
|
||||
e.remove();
|
||||
}
|
||||
materials.qESingularity().maybeStack(2).ifPresent(singularityStack -> {
|
||||
final CompoundNBT cmp = singularityStack.getOrCreateTag();
|
||||
cmp.putLong("freq", (new Date()).getTime() * 100 + (randTickSeed) % 100);
|
||||
randTickSeed++;
|
||||
item.grow(-1);
|
||||
|
||||
materials.qESingularity().maybeStack( 2 ).ifPresent( singularityStack ->
|
||||
{
|
||||
final CompoundNBT cmp = singularityStack.getOrCreateTag();
|
||||
cmp.putLong( "freq", ( new Date() ).getTime() * 100 + ( randTickSeed ) % 100 );
|
||||
randTickSeed++;
|
||||
item.grow( -1 );
|
||||
final EntitySingularity entity = new EntitySingularity(this.world, this.getPosX(),
|
||||
this.getPosY(), this.getPosZ(), singularityStack);
|
||||
this.world.addEntity(entity);
|
||||
});
|
||||
}
|
||||
|
||||
final EntitySingularity entity = new EntitySingularity( this.world, this.getPosX(), this.getPosY(), this
|
||||
.getPosZ(), singularityStack );
|
||||
this.world.addEntity( entity );
|
||||
} );
|
||||
}
|
||||
|
||||
if( item.getCount() <= 0 )
|
||||
{
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.getCount() <= 0) {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -42,161 +41,143 @@ import net.minecraft.world.Explosion.Mode;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.packets.PacketMockExplosion;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class EntityTinyTNTPrimed extends TNTEntity implements IEntityAdditionalSpawnData {
|
||||
|
||||
public final class EntityTinyTNTPrimed extends TNTEntity implements IEntityAdditionalSpawnData
|
||||
{
|
||||
public static EntityType<EntityTinyTNTPrimed> TYPE;
|
||||
|
||||
public static EntityType<EntityTinyTNTPrimed> TYPE;
|
||||
public EntityTinyTNTPrimed(EntityType<? extends EntityTinyTNTPrimed> type, World worldIn) {
|
||||
super(type, worldIn);
|
||||
this.preventEntitySpawning = true;
|
||||
}
|
||||
|
||||
public EntityTinyTNTPrimed( EntityType<? extends EntityTinyTNTPrimed> type, World worldIn )
|
||||
{
|
||||
super( type, worldIn );
|
||||
this.preventEntitySpawning = true;
|
||||
}
|
||||
public EntityTinyTNTPrimed(final World w, final double x, final double y, final double z,
|
||||
final LivingEntity igniter) {
|
||||
super(w, x, y, z, igniter);
|
||||
}
|
||||
|
||||
public EntityTinyTNTPrimed( final World w, final double x, final double y, final double z, final LivingEntity igniter )
|
||||
{
|
||||
super( w, x, y, z, igniter );
|
||||
}
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void tick() {
|
||||
this.handleWaterMovement();
|
||||
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
this.handleWaterMovement();
|
||||
this.prevPosX = this.getPosX();
|
||||
this.prevPosY = this.getPosY();
|
||||
this.prevPosZ = this.getPosZ();
|
||||
this.setMotion(this.getMotion().subtract(0, 0.03999999910593033D, 0));
|
||||
this.move(MoverType.SELF, this.getMotion());
|
||||
this.setMotion(this.getMotion().mul(0.9800000190734863D, 0.9800000190734863D, 0.9800000190734863D));
|
||||
|
||||
this.prevPosX = this.getPosX();
|
||||
this.prevPosY = this.getPosY();
|
||||
this.prevPosZ = this.getPosZ();
|
||||
this.setMotion( this.getMotion().subtract( 0, 0.03999999910593033D, 0 ) );
|
||||
this.move( MoverType.SELF, this.getMotion() );
|
||||
this.setMotion( this.getMotion().mul( 0.9800000190734863D, 0.9800000190734863D, 0.9800000190734863D ) );
|
||||
if (this.onGround) {
|
||||
this.setMotion(this.getMotion().mul(0.699999988079071D, 0.699999988079071D, -0.5D));
|
||||
}
|
||||
|
||||
if( this.onGround )
|
||||
{
|
||||
this.setMotion( this.getMotion().mul( 0.699999988079071D, 0.699999988079071D, -0.5D ) );
|
||||
}
|
||||
if (this.isInWater() && Platform.isServer()) // put out the fuse.
|
||||
{
|
||||
AEApi.instance().definitions().blocks().tinyTNT().maybeStack(1).ifPresent(tntStack -> {
|
||||
final ItemEntity item = new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(),
|
||||
tntStack);
|
||||
|
||||
if( this.isInWater() && Platform.isServer() ) // put out the fuse.
|
||||
{
|
||||
AEApi.instance().definitions().blocks().tinyTNT().maybeStack( 1 ).ifPresent( tntStack ->
|
||||
{
|
||||
final ItemEntity item = new ItemEntity( this.world, this.getPosX(), this.getPosY(), this.getPosZ(), tntStack );
|
||||
item.setMotion(this.getMotion());
|
||||
item.prevPosX = this.prevPosX;
|
||||
item.prevPosY = this.prevPosY;
|
||||
item.prevPosZ = this.prevPosZ;
|
||||
|
||||
item.setMotion( this.getMotion() );
|
||||
item.prevPosX = this.prevPosX;
|
||||
item.prevPosY = this.prevPosY;
|
||||
item.prevPosZ = this.prevPosZ;
|
||||
this.world.addEntity(item);
|
||||
this.remove();
|
||||
});
|
||||
}
|
||||
|
||||
this.world.addEntity( item );
|
||||
this.remove();
|
||||
} );
|
||||
}
|
||||
if (this.getFuse() <= 0) {
|
||||
this.remove();
|
||||
|
||||
if( this.getFuse() <= 0 )
|
||||
{
|
||||
this.remove();
|
||||
if (!this.world.isRemote) {
|
||||
this.explode();
|
||||
}
|
||||
} else {
|
||||
this.world.addParticle(ParticleTypes.SMOKE, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D,
|
||||
0.0D);
|
||||
}
|
||||
this.setFuse(this.getFuse() - 1);
|
||||
}
|
||||
|
||||
if( !this.world.isRemote )
|
||||
{
|
||||
this.explode();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.world.addParticle( ParticleTypes.SMOKE, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, 0.0D );
|
||||
}
|
||||
this.setFuse( this.getFuse() - 1 );
|
||||
}
|
||||
// override :P
|
||||
@Override
|
||||
protected void explode() {
|
||||
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_GENERIC_EXPLODE,
|
||||
SoundCategory.BLOCKS, 4.0F,
|
||||
(1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 32.9F);
|
||||
|
||||
// override :P
|
||||
@Override
|
||||
protected void explode()
|
||||
{
|
||||
this.world.playSound( null, this.getPosX(), this.getPosY(), this.getPosZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F,
|
||||
( 1.0F + ( this.world.rand.nextFloat() - this.world.rand.nextFloat() ) * 0.2F ) * 32.9F );
|
||||
if (this.isInWater()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.isInWater() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Explosion ex = new Explosion(this.world, this, this.getPosX(), this.getPosY(), this.getPosZ(), 0.2f,
|
||||
false, Mode.BREAK);
|
||||
final AxisAlignedBB area = new AxisAlignedBB(this.getPosX() - 1.5, this.getPosY() - 1.5f, this.getPosZ() - 1.5,
|
||||
this.getPosX() + 1.5, this.getPosY() + 1.5, this.getPosZ() + 1.5);
|
||||
final List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, area);
|
||||
|
||||
final Explosion ex = new Explosion( this.world, this, this.getPosX(), this.getPosY(), this.getPosZ(), 0.2f, false, Mode.BREAK );
|
||||
final AxisAlignedBB area = new AxisAlignedBB( this.getPosX() - 1.5, this.getPosY() - 1.5f, this
|
||||
.getPosZ() - 1.5, this.getPosX() + 1.5, this.getPosY() + 1.5, this.getPosZ() + 1.5 );
|
||||
final List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity( this, area );
|
||||
net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.world, ex, list, 0.2f * 2d);
|
||||
|
||||
net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate( this.world, ex, list, 0.2f * 2d );
|
||||
for (final Entity e : list) {
|
||||
e.attackEntityFrom(DamageSource.causeExplosionDamage(ex), 6);
|
||||
}
|
||||
|
||||
for( final Entity e : list )
|
||||
{
|
||||
e.attackEntityFrom( DamageSource.causeExplosionDamage( ex ), 6 );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.TINY_TNT_BLOCK_DAMAGE)) {
|
||||
this.setPosition(this.getPosX(), this.getPosY() - 0.25, this.getPosZ());
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.TINY_TNT_BLOCK_DAMAGE ) )
|
||||
{
|
||||
this.setPosition( this.getPosX(), this.getPosY() - 0.25, this.getPosZ() );
|
||||
for (int x = (int) (this.getPosX() - 2); x <= this.getPosX() + 2; x++) {
|
||||
for (int y = (int) (this.getPosY() - 2); y <= this.getPosY() + 2; y++) {
|
||||
for (int z = (int) (this.getPosZ() - 2); z <= this.getPosZ() + 2; z++) {
|
||||
final BlockPos point = new BlockPos(x, y, z);
|
||||
final BlockState state = this.world.getBlockState(point);
|
||||
final Block block = state.getBlock();
|
||||
|
||||
for( int x = (int) ( this.getPosX() - 2 ); x <= this.getPosX() + 2; x++ )
|
||||
{
|
||||
for( int y = (int) ( this.getPosY() - 2 ); y <= this.getPosY() + 2; y++ )
|
||||
{
|
||||
for( int z = (int) ( this.getPosZ() - 2 ); z <= this.getPosZ() + 2; z++ )
|
||||
{
|
||||
final BlockPos point = new BlockPos( x, y, z );
|
||||
final BlockState state = this.world.getBlockState( point );
|
||||
final Block block = state.getBlock();
|
||||
if (block != null && !block.isAir(state, this.world, point)) {
|
||||
float strength = (float) (2.3f
|
||||
- (((x + 0.5f) - this.getPosX()) * ((x + 0.5f) - this.getPosX())
|
||||
+ ((y + 0.5f) - this.getPosY()) * ((y + 0.5f) - this.getPosY())
|
||||
+ ((z + 0.5f) - this.getPosZ()) * ((z + 0.5f) - this.getPosZ())));
|
||||
|
||||
if( block != null && !block.isAir( state, this.world, point ) )
|
||||
{
|
||||
float strength = (float) ( 2.3f - ( ( ( x + 0.5f ) - this.getPosX() ) * ( ( x + 0.5f ) - this
|
||||
.getPosX() ) + ( ( y + 0.5f ) - this.getPosY() ) * ( ( y + 0.5f ) - this.getPosY() ) + ( ( z + 0.5f ) - this
|
||||
.getPosZ() ) * ( ( z + 0.5f ) - this.getPosZ() ) ) );
|
||||
final float resistance = block.getExplosionResistance(state, this.world, point, this, ex);
|
||||
strength -= (resistance + 0.3F) * 0.11f;
|
||||
|
||||
final float resistance = block.getExplosionResistance( state, this.world, point, this, ex );
|
||||
strength -= ( resistance + 0.3F ) * 0.11f;
|
||||
if (strength > 0.01) {
|
||||
if (block.getMaterial(state) != Material.AIR) {
|
||||
if (block.canDropFromExplosion(ex)) {
|
||||
block.spawnDrops(state, this.world, point);
|
||||
}
|
||||
|
||||
if( strength > 0.01 )
|
||||
{
|
||||
if( block.getMaterial( state ) != Material.AIR )
|
||||
{
|
||||
if( block.canDropFromExplosion( ex ) )
|
||||
{
|
||||
block.spawnDrops( state, this.world, point );
|
||||
}
|
||||
block.onBlockExploded(null, this.world, point, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
block.onBlockExploded( null, this.world, point, ex );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AppEng.proxy.sendToAllNearExcept(null, this.getPosX(), this.getPosY(), this.getPosZ(), 64, this.world,
|
||||
new PacketMockExplosion(this.getPosX(), this.getPosY(), this.getPosZ()));
|
||||
}
|
||||
|
||||
AppEng.proxy.sendToAllNearExcept( null, this.getPosX(), this.getPosY(), this.getPosZ(), 64, this.world,
|
||||
new PacketMockExplosion( this.getPosX(), this.getPosY(), this.getPosZ() ) );
|
||||
}
|
||||
@Override
|
||||
public void writeSpawnData(PacketBuffer buffer) {
|
||||
buffer.writeByte(this.getFuse());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData( PacketBuffer buffer )
|
||||
{
|
||||
buffer.writeByte( this.getFuse() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData( PacketBuffer additionalData )
|
||||
{
|
||||
this.setFuse( additionalData.readByte() );
|
||||
}
|
||||
@Override
|
||||
public void readSpawnData(PacketBuffer additionalData) {
|
||||
this.setFuse(additionalData.readByte());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
public interface ICanDie {
|
||||
|
||||
public interface ICanDie
|
||||
{
|
||||
|
||||
public boolean isDead();
|
||||
public boolean isDead();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -30,45 +29,36 @@ import net.minecraft.item.BlockItem;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RenderFloatingItem extends ItemRenderer {
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class RenderFloatingItem extends ItemRenderer
|
||||
{
|
||||
public RenderFloatingItem(final EntityRendererManager manager) {
|
||||
super(manager, Minecraft.getInstance().getItemRenderer());
|
||||
this.shadowOpaque = 0.0F;
|
||||
}
|
||||
|
||||
public RenderFloatingItem( final EntityRendererManager manager )
|
||||
{
|
||||
super( manager, Minecraft.getInstance().getItemRenderer() );
|
||||
this.shadowOpaque = 0.0F;
|
||||
}
|
||||
@Override
|
||||
public void render(ItemEntity entityIn, float entityYaw, float partialTicks, MatrixStack mStack,
|
||||
IRenderTypeBuffer buffers, int packedLightIn) {
|
||||
if (entityIn instanceof EntityFloatingItem) {
|
||||
final EntityFloatingItem efi = (EntityFloatingItem) entityIn;
|
||||
if (efi.getProgress() > 0.0) {
|
||||
mStack.push();
|
||||
|
||||
@Override
|
||||
public void render( ItemEntity entityIn, float entityYaw, float partialTicks, MatrixStack mStack, IRenderTypeBuffer buffers, int packedLightIn )
|
||||
{
|
||||
if( entityIn instanceof EntityFloatingItem )
|
||||
{
|
||||
final EntityFloatingItem efi = (EntityFloatingItem) entityIn;
|
||||
if( efi.getProgress() > 0.0 )
|
||||
{
|
||||
mStack.push();
|
||||
if (!(efi.getItem().getItem() instanceof BlockItem)) {
|
||||
mStack.translate(0, -0.3f, 0);
|
||||
} else {
|
||||
mStack.translate(0, -0.2f, 0);
|
||||
}
|
||||
|
||||
if( !( efi.getItem().getItem() instanceof BlockItem ) )
|
||||
{
|
||||
mStack.translate( 0, -0.3f, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
mStack.translate( 0, -0.2f, 0 );
|
||||
}
|
||||
super.render(entityIn, entityYaw, 0, mStack, buffers, packedLightIn);
|
||||
mStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.render( entityIn, entityYaw, 0, mStack, buffers, packedLightIn );
|
||||
mStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBob()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.entity;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -34,58 +33,52 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RenderTinyTNTPrimed extends EntityRenderer<EntityTinyTNTPrimed> {
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class RenderTinyTNTPrimed extends EntityRenderer<EntityTinyTNTPrimed>
|
||||
{
|
||||
public RenderTinyTNTPrimed(final EntityRendererManager manager) {
|
||||
super(manager);
|
||||
this.shadowSize = 0.5F;
|
||||
}
|
||||
|
||||
public RenderTinyTNTPrimed( final EntityRendererManager manager )
|
||||
{
|
||||
super( manager );
|
||||
this.shadowSize = 0.5F;
|
||||
}
|
||||
@Override
|
||||
public void render(EntityTinyTNTPrimed tnt, float entityYaw, float partialTicks, MatrixStack mStack,
|
||||
IRenderTypeBuffer buffers, int packedLight) {
|
||||
final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
mStack.push();
|
||||
mStack.translate(0, 0.25F, 0);
|
||||
float f2;
|
||||
|
||||
@Override
|
||||
public void render( EntityTinyTNTPrimed tnt, float entityYaw, float partialTicks, MatrixStack mStack, IRenderTypeBuffer buffers, int packedLight )
|
||||
{
|
||||
final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||
mStack.push();
|
||||
mStack.translate( 0, 0.25F, 0 );
|
||||
float f2;
|
||||
if (tnt.getFuse() - partialTicks + 1.0F < 10.0F) {
|
||||
f2 = 1.0F - (tnt.getFuse() - partialTicks + 1.0F) / 10.0F;
|
||||
|
||||
if( tnt.getFuse() - partialTicks + 1.0F < 10.0F )
|
||||
{
|
||||
f2 = 1.0F - ( tnt.getFuse() - partialTicks + 1.0F ) / 10.0F;
|
||||
if (f2 < 0.0F) {
|
||||
f2 = 0.0F;
|
||||
}
|
||||
|
||||
if( f2 < 0.0F )
|
||||
{
|
||||
f2 = 0.0F;
|
||||
}
|
||||
if (f2 > 1.0F) {
|
||||
f2 = 1.0F;
|
||||
}
|
||||
|
||||
if( f2 > 1.0F )
|
||||
{
|
||||
f2 = 1.0F;
|
||||
}
|
||||
f2 *= f2;
|
||||
f2 *= f2;
|
||||
final float f3 = 1.0F + f2 * 0.3F;
|
||||
mStack.scale(f3, f3, f3);
|
||||
}
|
||||
|
||||
f2 *= f2;
|
||||
f2 *= f2;
|
||||
final float f3 = 1.0F + f2 * 0.3F;
|
||||
mStack.scale( f3, f3, f3 );
|
||||
}
|
||||
mStack.scale(0.5f, 0.5f, 0.5f);
|
||||
f2 = (1.0F - (tnt.getFuse() - partialTicks + 1.0F) / 100.0F) * 0.8F;
|
||||
mStack.rotate(Vector3f.YP.rotationDegrees(-90.0F));
|
||||
mStack.translate(-0.5D, -0.5D, 0.5D);
|
||||
mStack.rotate(Vector3f.YP.rotationDegrees(90.0F));
|
||||
TNTMinecartRenderer.renderTntFlash(Blocks.TNT.getDefaultState(), mStack, buffers, packedLight,
|
||||
tnt.getFuse() / 5 % 2 == 0);
|
||||
mStack.pop();
|
||||
super.render(tnt, entityYaw, partialTicks, mStack, buffers, packedLight);
|
||||
}
|
||||
|
||||
mStack.scale( 0.5f, 0.5f, 0.5f );
|
||||
f2 = ( 1.0F - ( tnt.getFuse() - partialTicks + 1.0F ) / 100.0F ) * 0.8F;
|
||||
mStack.rotate( Vector3f.YP.rotationDegrees( -90.0F ) );
|
||||
mStack.translate( -0.5D, -0.5D, 0.5D );
|
||||
mStack.rotate( Vector3f.YP.rotationDegrees( 90.0F ) );
|
||||
TNTMinecartRenderer.renderTntFlash( Blocks.TNT.getDefaultState(), mStack, buffers, packedLight, tnt.getFuse() / 5 % 2 == 0 );
|
||||
mStack.pop();
|
||||
super.render( tnt, entityYaw, partialTicks, mStack, buffers, packedLight );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture( final EntityTinyTNTPrimed entity )
|
||||
{
|
||||
return AtlasTexture.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture(final EntityTinyTNTPrimed entity) {
|
||||
return AtlasTexture.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user