From 8ef7f2dc11c4bf71a12d2c1bb5254098f80c9570 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 29 Jul 2020 17:24:03 -0400 Subject: [PATCH] Rebalance Lightning Rod --- gradle.properties | 2 +- .../entity/LightningRodBaseBlockEntity.java | 21 ++++++++++++------- .../lightning/LightningRodBaseBlock.java | 6 +++++- .../block/lightning/LightningRodBlock.java | 7 ++++++- .../energonrelics/config/HardcodedConfig.java | 6 +++--- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index ad1bd6c..c2d701f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ org.gradle.jvmargs = -Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_api_version = 0.16.1+build.387-1.16 + fabric_api_version = 0.16.2+build.389-1.16 modmenu_version = 1.14.5+build.30 cloth_config_version = 4.7.0-unstable autoconfig_version = 3.2.0-unstable diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/entity/LightningRodBaseBlockEntity.java b/src/main/java/com/thebrokenrail/energonrelics/block/entity/LightningRodBaseBlockEntity.java index 81b7a47..9dec6f5 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/entity/LightningRodBaseBlockEntity.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/entity/LightningRodBaseBlockEntity.java @@ -14,7 +14,6 @@ import net.minecraft.world.LightType; import java.util.List; import java.util.Objects; -import java.util.Random; public class LightningRodBaseBlockEntity extends EnergyProviderBlockEntity implements EnergyGenerator { public LightningRodBaseBlockEntity(BlockEntityType type) { @@ -33,8 +32,6 @@ public class LightningRodBaseBlockEntity extends EnergyProviderBlockEntity imple private int cooldown = 0; private long energy = 0; - private final Random random = new Random(); - @Override public long getDisplayEnergy() { return energy; @@ -52,25 +49,35 @@ public class LightningRodBaseBlockEntity extends EnergyProviderBlockEntity imple @Override public List startTick() { + assert getWorld() != null; + if (cooldown <= 0) { - energy = 0; + if (energy != 0) { + energy = 0; + markDirty(); + } if (getLight() > 0) { - if (random.nextDouble() <= HardcodedConfig.LIGHTNING_ROD_CHANCE) { + if (getWorld().random.nextDouble() <= HardcodedConfig.LIGHTNING_ROD_CHANCE) { LightningEntity entity = EntityType.LIGHTNING_BOLT.create(getWorld()); assert entity != null; - entity.updatePosition(getPos().getX() + 0.5d, getPos().getY() + 1d, getPos().getZ() + 0.5d); + entity.updatePosition(getPos().getX() + 0.5d, getPos().getY() + 1d + (getWorld().random.nextDouble() * 1.5d), getPos().getZ() + 0.5d); entity.setCosmetic(true); Objects.requireNonNull(getWorld()).spawnEntity(entity); cooldown = HardcodedConfig.LIGHTNING_ROD_COOLDOWN; energy = HardcodedConfig.LIGHTNING_ROD_ENERGY_OUTPUT; + + markDirty(); } } } else { + energy = 0; + cooldown--; + markDirty(); } - markDirty(); + return super.startTick(); } diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/lightning/LightningRodBaseBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/lightning/LightningRodBaseBlock.java index f06ec39..cf6bb19 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/lightning/LightningRodBaseBlock.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/lightning/LightningRodBaseBlock.java @@ -8,6 +8,7 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.DoorBlock; import net.minecraft.block.Material; import net.minecraft.block.MaterialColor; import net.minecraft.block.ShapeContext; @@ -93,6 +94,9 @@ public class LightningRodBaseBlock extends EnergyBlock { public BlockState getPlacementState(ItemPlacementContext ctx) { BlockPos pos = ctx.getBlockPos(); World world = ctx.getWorld(); - return world.getBlockState(pos.up(1)).canReplace(ctx) && world.getBlockState(pos.up(2)).canReplace(ctx) ? super.getPlacementState(ctx) : null; + + BlockPos top = pos.up(2); + + return top.getY() < world.getHeight() && world.getBlockState(pos.up(1)).canReplace(ctx) && world.getBlockState(top).canReplace(ctx) ? super.getPlacementState(ctx) : null; } } diff --git a/src/main/java/com/thebrokenrail/energonrelics/block/lightning/LightningRodBlock.java b/src/main/java/com/thebrokenrail/energonrelics/block/lightning/LightningRodBlock.java index 5a98070..736aaca 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/block/lightning/LightningRodBlock.java +++ b/src/main/java/com/thebrokenrail/energonrelics/block/lightning/LightningRodBlock.java @@ -116,7 +116,12 @@ public class LightningRodBlock extends SimpleBlock { if (!world.isClient() && player.isCreative()) { int distance = state.get(HALF) == DoubleBlockHalf.LOWER ? 1 : 2; BlockPos targetPos = pos.down(distance); - world.breakBlock(targetPos, false, player); + + BlockState targetState = world.getBlockState(targetPos); + + if (targetState.getBlock() == EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) { + world.breakBlock(targetPos, false, player); + } } super.onBreak(world, pos, state, player); diff --git a/src/main/java/com/thebrokenrail/energonrelics/config/HardcodedConfig.java b/src/main/java/com/thebrokenrail/energonrelics/config/HardcodedConfig.java index 9ae7172..3f50750 100644 --- a/src/main/java/com/thebrokenrail/energonrelics/config/HardcodedConfig.java +++ b/src/main/java/com/thebrokenrail/energonrelics/config/HardcodedConfig.java @@ -24,9 +24,9 @@ public class HardcodedConfig { public static final int BLOCK_BREAKER_TIME = 48; public static final Item BLOCK_BREAKER_ITEM = Items.IRON_PICKAXE; - public static final long LIGHTNING_ROD_ENERGY_OUTPUT = 40000; - public static final double LIGHTNING_ROD_CHANCE = 0.00005d; - public static final int LIGHTNING_ROD_COOLDOWN = 5; + public static final long LIGHTNING_ROD_ENERGY_OUTPUT = 200000; + public static final double LIGHTNING_ROD_CHANCE = 0.00008d; + public static final int LIGHTNING_ROD_COOLDOWN = 240; public static final long FIELD_PROJECTOR_ENERGY_REQUIRED = 31; public static final int FIELD_MAX_SIZE = 12;