diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/primitive/MetaTileEntityPrimitiveSmelter.java b/src/main/java/supersymmetry/common/metatileentities/multi/primitive/MetaTileEntityPrimitiveSmelter.java index d8d05aa7f..6e66224c4 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/primitive/MetaTileEntityPrimitiveSmelter.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/primitive/MetaTileEntityPrimitiveSmelter.java @@ -4,6 +4,7 @@ import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; import com.codetaylor.mc.pyrotech.modules.core.ModuleCore; +import gregtech.api.GTValues; import gregtech.api.capability.impl.ItemHandlerList; import gregtech.api.gui.ModularUI; import gregtech.api.metatileentity.MetaTileEntity; @@ -14,14 +15,21 @@ import gregtech.api.pattern.FactoryBlockPattern; import gregtech.api.pattern.PatternMatchContext; import gregtech.api.pattern.TraceabilityPredicate; +import gregtech.api.util.GTUtility; +import gregtech.client.particle.VanillaParticleEffects; import gregtech.client.renderer.CubeRendererState; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.cclop.ColourOperation; import gregtech.client.renderer.cclop.LightMapOperation; import gregtech.client.renderer.texture.Textures; +import gregtech.common.ConfigHolder; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; +import net.minecraft.init.SoundEvents; +import net.minecraft.util.*; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.ArrayUtils; @@ -32,6 +40,9 @@ public class MetaTileEntityPrimitiveSmelter extends RecipeMapPrimitiveMultiblockController { + private static final TraceabilityPredicate SNOW_PREDICATE = new TraceabilityPredicate( + bws -> GTUtility.isBlockSnow(bws.getBlockState())); + public MetaTileEntityPrimitiveSmelter(ResourceLocation metaTileEntityId) { super(metaTileEntityId, SuSyRecipeMaps.PRIMITIVE_SMELTER); } @@ -62,7 +73,7 @@ protected void formStructure(PatternMatchContext context) { .where('C', selfPredicate()) .where('O', casingPredicate().or(abilities(SuSyMultiblockAbilities.PRIMITIVE_EXPORT_ITEMS).setMaxGlobalLimited(2))) .where('S', states(ModuleCore.Blocks.MASONRY_BRICK_SLAB.getDefaultState())) - .where(' ', air()) + .where(' ', air().or(SNOW_PREDICATE)) .build(); } @@ -97,6 +108,41 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, } } + @Override + public void update() { + super.update(); + + if (this.isActive() && !getWorld().isRemote) { + damageEntitiesAndBreakSnow(); + } + } + + private void damageEntitiesAndBreakSnow() { + BlockPos middlePos = this.getPos(); + middlePos = middlePos.offset(getFrontFacing().getOpposite()); + this.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(middlePos)) + .forEach(entity -> entity.attackEntityFrom(DamageSource.LAVA, 3.0f)); + + if (getOffsetTimer() % 10 == 0) { + IBlockState state = getWorld().getBlockState(middlePos); + GTUtility.tryBreakSnow(getWorld(), middlePos, state, true); + } + } + + @SideOnly(Side.CLIENT) + @Override + public void randomDisplayTick() { + if (this.isActive()) { + VanillaParticleEffects.defaultFrontEffect(this, 0.3F, EnumParticleTypes.SMOKE_LARGE, + EnumParticleTypes.FLAME); + if (ConfigHolder.machines.machineSounds && GTValues.RNG.nextDouble() < 0.1) { + BlockPos pos = getPos(); + getWorld().playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, + SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false); + } + } + } + @Override public boolean hasMaintenanceMechanics() { return false;