Skip to content

Commit

Permalink
Ice bomb improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed Jan 10, 2025
1 parent 98bd003 commit 9127237
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 147 deletions.
22 changes: 15 additions & 7 deletions src/main/java/twilightforest/compat/TConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void preInit() {
new ArrowShaftMaterialStats(1.4f, 20)
);
TinkerRegistry.integrate(TConstruct.nagascale).preInit();

TinkerRegistry.addMaterialStats(TConstruct.ironwood,
new HeadMaterialStats(450, 6f, 5f, HarvestLevels.DIAMOND),
new HandleMaterialStats(1.1f, 100),
Expand Down Expand Up @@ -82,7 +82,7 @@ static void preInit() {
new FletchingMaterialStats(0.95f, 1.15f)
);
TinkerRegistry.integrate(TConstruct.ravenFeather).preInit();

TinkerRegistry.addMaterialStats(TConstruct.regal,
new HeadMaterialStats(950, 8f, 7f, HarvestLevels.COBALT),
new HandleMaterialStats(1.3f, 200),
Expand All @@ -100,22 +100,26 @@ static void preInit() {
static void init() {
TConstruct.nagascale.addItem(TFItems.naga_scale, 1, Material.VALUE_Ingot);
TConstruct.nagascale
.addTrait(TConstruct.twilit, MaterialTypes.HEAD)
.addTrait(TConstruct.twilit)
.addTrait(TConstruct.precipitate, MaterialTypes.HEAD)
.addTrait(TConstruct.precipitate)
.setCraftable(true).setCastable(false)
.setRepresentativeItem(TFItems.naga_scale);

TConstruct.ironwood.addCommonItems("Ironwood");
TConstruct.ironwood
.addTrait(TConstruct.twilit, MaterialTypes.HEAD)
.addTrait(TConstruct.twilit)
.addTrait(TinkerTraits.stiff, MaterialTypes.HEAD)
.addTrait(TinkerTraits.ecological, MaterialTypes.HEAD)
.addTrait(TinkerTraits.ecological)
.setCraftable(true).setCastable(false)
.setRepresentativeItem(TFItems.ironwood_ingot);

TConstruct.steeleaf.addCommonItems("Steeleaf");
TConstruct.steeleaf
.addTrait(TConstruct.twilit, MaterialTypes.HEAD)
.addTrait(TConstruct.twilit)
.addTrait(TConstruct.synergy, MaterialTypes.HEAD)
.addTrait(TConstruct.synergy)
Expand All @@ -125,6 +129,7 @@ static void init() {
TConstruct.fierymetal.addCommonItems("Fiery");
TConstruct.fierymetal
.addTrait(TinkerTraits.superheat)
.addTrait(TConstruct.twilit, MaterialTypes.HEAD)
.addTrait(TConstruct.twilit)
.addTrait(TinkerTraits.autosmelt, MaterialTypes.HEAD)
//.addTrait(TinkerTraits.superheat, MaterialTypes.HEAD)
Expand All @@ -136,6 +141,7 @@ static void init() {
TConstruct.knightmetal.addItem(TFItems.armor_shard, 1, Material.VALUE_Nugget);
TConstruct.knightmetal.addItem(TFItems.block_and_chain, 1, (Material.VALUE_Ingot * 7) + Material.VALUE_Block);
TConstruct.knightmetal
.addTrait(TConstruct.twilit, MaterialTypes.HEAD)
.addTrait(TConstruct.twilit)
.addTrait(TConstruct.stalwart, MaterialTypes.HEAD)
.addTrait(TConstruct.stalwart)
Expand All @@ -144,15 +150,17 @@ static void init() {

TConstruct.ravenFeather.addItem(TFItems.raven_feather, 1, Material.VALUE_Ingot);
TConstruct.ravenFeather
.addTrait(TConstruct.twilit, MaterialTypes.HEAD)
.addTrait(TConstruct.twilit)
.addTrait(TConstruct.veiled, MaterialTypes.HEAD)
.addTrait(TConstruct.veiled)
.setCraftable(true).setCastable(false)
.setRepresentativeItem(TFItems.raven_feather);

TConstruct.regal.addCommonItems("Regal");
TConstruct.regal.addItem(TFItems.regal_shard, 1, Material.VALUE_Nugget);
TConstruct.regal
.addTrait(TConstruct.twilit, MaterialTypes.HEAD)
.addTrait(TConstruct.twilit)
.addTrait(TinkerTraits.shocking, MaterialTypes.HEAD)
.addTrait(TinkerTraits.shocking)
Expand All @@ -162,8 +170,8 @@ static void init() {

static void postInit() {
TinkerRegistry.registerSmelteryFuel(new FluidStack(RegisterBlockEvent.essenceFiery, 50), 1000);
TinkerRegistry.registerMelting(TFItems.fiery_blood, RegisterBlockEvent.essenceFiery, Material.VALUE_Ingot);
TinkerRegistry.registerMelting(TFItems.fiery_tears, RegisterBlockEvent.essenceFiery, Material.VALUE_Ingot);

TinkerRegistry.registerMelting(TFItems.fiery_blood, RegisterBlockEvent.essenceFiery, Material.VALUE_Ingot);
TinkerRegistry.registerMelting(TFItems.fiery_tears, RegisterBlockEvent.essenceFiery, Material.VALUE_Ingot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, b
if (stack.getItem() == TFItems.steeleaf_ingot) {
healPower += 1;
} else if (stack.getItem() == TFItems.block_storage && stack.getMetadata() == CompressedVariant.STEELLEAF.ordinal()) {
healPower += 2;
healPower += 9;
} else if (TFItemStackUtils.hasToolMaterial(stack, TFItems.TOOL_STEELEAF)) {
healPower += 1;
healPower += 2;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public List<String> getExtraInfo(ItemStack tool, NBTTagCompound modifierTag) {
String outside = String.format(LOC_Extra + ".outside", getModifierIdentifier());

return ImmutableList.of(
Util.translateFormatted(inside, Util.df.format(1.0F)),
Util.translateFormatted(outside, Util.df.format(2.0F))
Util.translateFormatted(inside, Util.df.format(2.0F)),
Util.translateFormatted(outside, Util.df.format(1.0F))
);
}
}
265 changes: 133 additions & 132 deletions src/main/java/twilightforest/entity/boss/EntityTFIceBomb.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,136 +19,137 @@
import java.util.List;

public class EntityTFIceBomb extends EntityTFThrowable {

private int zoneTimer = 80;
private boolean hasHit;

public EntityTFIceBomb(World world) {
super(world);
}

public EntityTFIceBomb(World world, EntityLivingBase thrower) {
super(world, thrower);
}

@Override
protected void onImpact(RayTraceResult ray) {
this.motionY = 0;
this.hasHit = true;

if (!world.isRemote)
this.doTerrainEffects();
}

private void doTerrainEffects() {

final int range = 3;

int ix = MathHelper.floor(this.lastTickPosX);
int iy = MathHelper.floor(this.lastTickPosY);
int iz = MathHelper.floor(this.lastTickPosZ);

for (int x = -range; x <= range; x++) {
for (int y = -range; y <= range; y++) {
for (int z = -range; z <= range; z++) {
this.doTerrainEffect(new BlockPos(ix + x, iy + y, iz + z));
}
}
}
}

/**
* Freeze water, put snow on snowable surfaces
*/
private void doTerrainEffect(BlockPos pos) {
IBlockState state = world.getBlockState(pos);
if (state.getMaterial() == Material.WATER) {
this.world.setBlockState(pos, Blocks.ICE.getDefaultState());
}
if (state.getMaterial() == Material.LAVA) {
this.world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState());
}
if (this.world.isAirBlock(pos) && Blocks.SNOW_LAYER.canPlaceBlockAt(this.world, pos)) {
this.world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState());
}
}

@Override
public void onUpdate() {
super.onUpdate();

if (this.hasHit) {
this.motionX *= 0.1D;
this.motionY *= 0.1D;
this.motionZ *= 0.1D;

this.zoneTimer--;
makeIceZone();

if (!world.isRemote && this.zoneTimer <= 0) {
world.playEvent(2001, new BlockPos(this), Block.getStateId(Blocks.ICE.getDefaultState()));
setDead();
}
} else {
makeTrail();
}
}

public void makeTrail() {
int stateId = Block.getStateId(Blocks.SNOW.getDefaultState());
for (int i = 0; i < 10; i++) {
double dx = posX + 0.75F * (rand.nextFloat() - 0.5F);
double dy = posY + 0.75F * (rand.nextFloat() - 0.5F);
double dz = posZ + 0.75F * (rand.nextFloat() - 0.5F);

world.spawnParticle(EnumParticleTypes.FALLING_DUST, dx, dy, dz, -motionX, -motionY, -motionZ, stateId);
}
}

private void makeIceZone() {
if (this.world.isRemote) {
// sparkles
int stateId = Block.getStateId(Blocks.SNOW.getDefaultState());
for (int i = 0; i < 20; i++) {
double dx = this.posX + (rand.nextFloat() - rand.nextFloat()) * 3.0F;
double dy = this.posY + (rand.nextFloat() - rand.nextFloat()) * 3.0F;
double dz = this.posZ + (rand.nextFloat() - rand.nextFloat()) * 3.0F;

world.spawnParticle(EnumParticleTypes.FALLING_DUST, dx, dy, dz, 0, 0, 0, stateId);
}
} else {
if (this.zoneTimer % 10 == 0) {
hitNearbyEntities();
}
}
}

private void hitNearbyEntities() {
List<EntityLivingBase> nearby = this.world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().grow(3, 2, 3));

for (EntityLivingBase entity : nearby) {
if (entity != this.getThrower()) {
if (entity instanceof EntityTFYeti) {
// TODO: make "frozen yeti" entity?
BlockPos pos = new BlockPos(entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ);
world.setBlockState(pos, Blocks.ICE.getDefaultState());
world.setBlockState(pos.up(), Blocks.ICE.getDefaultState());

entity.setDead();
} else {
entity.attackEntityFrom(DamageSource.MAGIC, 1);
entity.addPotionEffect(new PotionEffect(TFPotions.frosty, 20 * 5, 2));
}
}
}
}

public IBlockState getBlock() {
return Blocks.PACKED_ICE.getDefaultState();
}

@Override
protected float getGravityVelocity() {
return this.hasHit ? 0F : 0.025F;
}
private int zoneTimer = 101;
private boolean hasHit;

public EntityTFIceBomb(World world) {
super(world);
}

public EntityTFIceBomb(World world, EntityLivingBase thrower) {
super(world, thrower);
}

@Override
protected void onImpact(RayTraceResult ray) {
this.motionY = 0;
this.hasHit = true;

if (!world.isRemote)
this.doTerrainEffects();
}

private void doTerrainEffects() {

final int range = 2;

int ix = MathHelper.floor(this.lastTickPosX);
int iy = MathHelper.floor(this.lastTickPosY);
int iz = MathHelper.floor(this.lastTickPosZ);

for (int x = -range; x <= range; x++) {
for (int z = -range; z <= range; z++) {
if (Math.abs(x) == range && Math.abs(z) == range) continue;
for (int y = -range; y <= range; y++) {
this.doTerrainEffect(new BlockPos(ix + x, iy + y, iz + z));
}
}
}
}

/**
* Freeze water, put snow on snowable surfaces
*/
private void doTerrainEffect(BlockPos pos) {
IBlockState state = world.getBlockState(pos);
if (state.getMaterial() == Material.WATER) {
this.world.setBlockState(pos, Blocks.ICE.getDefaultState());
}
if (state.getMaterial() == Material.LAVA) {
this.world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState());
}
if (this.world.isAirBlock(pos) && Blocks.SNOW_LAYER.canPlaceBlockAt(this.world, pos)) {
this.world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState());
}
}

@Override
public void onUpdate() {
super.onUpdate();

if (this.hasHit) {
this.motionX *= 0.1D;
this.motionY *= 0.1D;
this.motionZ *= 0.1D;

this.zoneTimer--;
makeIceZone();

if (!world.isRemote && this.zoneTimer <= 0) {
world.playEvent(2001, new BlockPos(this), Block.getStateId(Blocks.ICE.getDefaultState()));
setDead();
}
} else {
makeTrail();
}
}

public void makeTrail() {
int stateId = Block.getStateId(Blocks.SNOW.getDefaultState());
for (int i = 0; i < 10; i++) {
double dx = posX + 0.5D * (rand.nextDouble() - rand.nextDouble());
double dy = posY + 0.5D * (rand.nextDouble() - rand.nextDouble()) + 0.5D;
double dz = posZ + 0.5D * (rand.nextDouble() - rand.nextDouble());

world.spawnParticle(EnumParticleTypes.FALLING_DUST, dx, dy, dz, -motionX, -motionY, -motionZ, stateId);
}
}

private void makeIceZone() {
if (this.world.isRemote) {
// sparkles
int stateId = Block.getStateId(Blocks.SNOW.getDefaultState());
for (int i = 0; i < 20; i++) {
double dx = this.posX + (rand.nextFloat() - rand.nextFloat()) * 3.5F;
double dy = this.posY + (rand.nextFloat() - rand.nextFloat()) * 3.5F;
double dz = this.posZ + (rand.nextFloat() - rand.nextFloat()) * 3.5F;

world.spawnParticle(EnumParticleTypes.FALLING_DUST, dx, dy, dz, 0, 0, 0, stateId);
}
} else {
if (this.zoneTimer == 99) this.doTerrainEffects();
if (this.zoneTimer % 20 == 0) {
hitNearbyEntities();
}
}
}

private void hitNearbyEntities() {
List<EntityLivingBase> nearby = this.world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().grow(3, 2, 3));

for (EntityLivingBase entity : nearby) {
if (entity != this.getThrower()) {
if (entity instanceof EntityTFYeti) {
// TODO: make "frozen yeti" entity?
BlockPos pos = new BlockPos(entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ);
world.setBlockState(pos, Blocks.ICE.getDefaultState());
world.setBlockState(pos.up(), Blocks.ICE.getDefaultState());

entity.setDead();
} else {
entity.attackEntityFrom(DamageSource.MAGIC, 1);
entity.addPotionEffect(new PotionEffect(TFPotions.frosty, 20 * 5, 2));
}
}
}
}

public IBlockState getBlock() {
return Blocks.PACKED_ICE.getDefaultState();
}

@Override
protected float getGravityVelocity() {
return this.hasHit ? 0F : 0.025F;
}
}
Loading

0 comments on commit 9127237

Please sign in to comment.