Skip to content

Commit

Permalink
entity damage, snow-proof and particles
Browse files Browse the repository at this point in the history
  • Loading branch information
MCTian-mi committed Sep 7, 2024
1 parent 99f5aae commit f712e20
Showing 1 changed file with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f712e20

Please sign in to comment.