Rebalance Lightning Rod
All checks were successful
EnergonRelics/pipeline/head This commit looks good
All checks were successful
EnergonRelics/pipeline/head This commit looks good
This commit is contained in:
parent
08f609e6c4
commit
8ef7f2dc11
@ -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
|
||||
|
@ -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<EnergyTickable> startTick() {
|
||||
assert getWorld() != null;
|
||||
|
||||
if (cooldown <= 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();
|
||||
}
|
||||
|
||||
return super.startTick();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -116,8 +116,13 @@ public class LightningRodBlock extends SimpleBlock {
|
||||
if (!world.isClient() && player.isCreative()) {
|
||||
int distance = state.get(HALF) == DoubleBlockHalf.LOWER ? 1 : 2;
|
||||
BlockPos targetPos = pos.down(distance);
|
||||
|
||||
BlockState targetState = world.getBlockState(targetPos);
|
||||
|
||||
if (targetState.getBlock() == EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) {
|
||||
world.breakBlock(targetPos, false, player);
|
||||
}
|
||||
}
|
||||
|
||||
super.onBreak(world, pos, state, player);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user