Compare commits

..

No commits in common. "487a1aa6e0bc77143df5f17952e17863d25d8d31" and "fdcf3dc49ea80fe93a59e65871f2334cae401d35" have entirely different histories.

14 changed files with 5 additions and 240 deletions

View File

@ -2,7 +2,6 @@ package com.thebrokenrail.energonrelics;
import com.thebrokenrail.energonrelics.block.BlockBreakerBlock;
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
import com.thebrokenrail.energonrelics.block.LightningRodBlock;
import com.thebrokenrail.energonrelics.block.VeridiumBlockBlock;
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
import com.thebrokenrail.energonrelics.block.ThermalGlassBlock;
@ -71,8 +70,6 @@ public class EnergonRelics implements ModInitializer {
public static final Item VERIDIUM_POWDER_ITEM = new Item(new Item.Settings().group(ITEM_GROUP));
public static final LightningRodBlock LIGHTNING_ROD_BLOCK = new LightningRodBlock();
@Override
public void onInitialize() {
NETWORK_CHIP_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "network_chip"), new NetworkChipItem());
@ -109,7 +106,5 @@ public class EnergonRelics implements ModInitializer {
Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "veridium_powder"), VERIDIUM_POWDER_ITEM);
CustomPotions.register();
LIGHTNING_ROD_BLOCK.register("lightning_rod");
}
}

View File

@ -1,50 +0,0 @@
package com.thebrokenrail.energonrelics.block;
import com.thebrokenrail.energonrelics.block.entity.LightningRodBlockEntity;
import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import java.util.function.Function;
public class LightningRodBlock extends EnergyProviderBlock {
public LightningRodBlock() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.BLUE_TERRACOTTA).nonOpaque().allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false).emissiveLighting((state, world, pos) -> true).lightLevel(10).requiresTool().strength(1.5f, 6.0f));
}
@Override
@SuppressWarnings("deprecation")
@Environment(EnvType.CLIENT)
public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) {
return 1f;
}
@Override
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
return true;
}
@Override
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
return LightningRodBlockEntity::new;
}
private static final VoxelShape SHAPE = VoxelShapes.union(createCuboidShape(3d, 0d, 3d, 13d, 2d, 13d), createCuboidShape(7.5d, 2d, 7.5d, 8.5d, 26d, 8.5d));
@SuppressWarnings("deprecation")
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return SHAPE;
}
}

View File

@ -1,99 +0,0 @@
package com.thebrokenrail.energonrelics.block.entity;
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity;
import com.thebrokenrail.energonrelics.energy.core.util.Action;
import com.thebrokenrail.energonrelics.energy.helper.EnergyGenerator;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.LightType;
import java.util.Objects;
import java.util.Random;
public class LightningRodBlockEntity extends EnergyProviderBlockEntity implements EnergyGenerator {
public LightningRodBlockEntity(BlockEntityType<?> type) {
super(type);
}
private int getLight() {
if (hasWorld() && Objects.requireNonNull(getWorld()).getDimension().hasSkyLight() && getWorld().isThundering()) {
assert getWorld() != null;
return getWorld().getLightLevel(LightType.SKY, getPos());
} else {
return 0;
}
}
private int cooldown = 0;
private long energy = 0;
private final Random random = new Random();
@Override
public long getDisplayEnergy() {
return energy;
}
@Override
public long getEnergy() {
return energy;
}
@Override
public void setEnergy(long energy) {
this.energy = energy;
}
@Override
protected void serverTick() {
if (cooldown <= 0) {
energy = 0;
if (getLight() > 0) {
if (random.nextDouble() <= HardcodedConfig.LIGHTNING_ROD_CHANCE) {
LightningEntity entity = EntityType.LIGHTNING_BOLT.create(getWorld());
assert entity != null;
entity.updatePosition(getPos().getX() + 0.5d, getPos().getY() + 0.5d, getPos().getZ() + 0.5d);
entity.method_29498(true);
Objects.requireNonNull(getWorld()).spawnEntity(entity);
cooldown = HardcodedConfig.LIGHTNING_ROD_COOLDOWN;
energy = HardcodedConfig.LIGHTNING_ROD_ENERGY_OUTPUT;
}
}
} else {
cooldown--;
}
super.serverTick();
}
@Override
public CompoundTag toTag(CompoundTag tag) {
super.toTag(tag);
tag.putInt("Cooldown", cooldown);
tag.putLong("Energy", energy);
return tag;
}
@Override
public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag);
cooldown = tag.getInt("Cooldown");
energy = tag.getLong("Energy");
}
@Override
protected void handlePropagatedAction(Action.PropagatedAction action) {
super.handlePropagatedAction(action);
handlePropagatedActionWithGenerator(action);
}
@Override
public boolean isEnergyProvider() {
return true;
}
}

View File

@ -38,7 +38,7 @@ public class SolarPanelBlockEntity extends EnergyGeneratorBlockEntity {
@Override
protected void serverTick() {
setEnergy(getDisplayEnergy());
super.serverTick();
setEnergy(getDisplayEnergy());
}
}

View File

@ -33,6 +33,7 @@ public class ReactorControllerBlockEntity extends EnergyGeneratorBlockEntity {
@Override
protected void serverTick() {
super.serverTick();
if (getCachedState().get(ReactorControllerBlock.POWERED)) {
Reactor reactor = getReactor();
if (reactor != null && !reactor.core.isReacting()) {
@ -62,7 +63,6 @@ public class ReactorControllerBlockEntity extends EnergyGeneratorBlockEntity {
}
}
setEnergy(getDisplayEnergy());
super.serverTick();
}
@Override

View File

@ -23,8 +23,4 @@ public class HardcodedConfig {
public static final long BLOCK_BREAKER_ENERGY_REQUIRED_BREAK = 36;
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 = 50000;
public static final double LIGHTNING_ROD_CHANCE = 0.00005d;
public static final int LIGHTNING_ROD_COOLDOWN = 5;
}

View File

@ -38,6 +38,8 @@ public abstract class EnergyReceiverBlockEntity extends EnergyProviderBlockEntit
@Override
public void serverTick() {
super.serverTick();
ServerWorld world = (ServerWorld) getWorld();
assert world != null;
NetworkComponent component = NetworkComponent.getInstance(world);
@ -59,8 +61,6 @@ public abstract class EnergyReceiverBlockEntity extends EnergyProviderBlockEntit
pendingActions.clear();
tickEnergy();
super.serverTick();
for (Action.PropagatedAction action : pendingPropagatedActions) {
propagateAction(action);
}

View File

@ -23,9 +23,6 @@ public abstract class EnergyGeneratorBlockEntity extends EnergyProviderBlockEnti
@Override
public void setEnergy(long value) {
if (value < 0) {
throw new UnsupportedOperationException();
}
energy = value;
}

View File

@ -25,8 +25,6 @@ public class MultimeterItem extends Item {
String str;
if (value >= Long.MAX_VALUE) {
str = "\u221e";
} else if (value == -1) {
str = "N/A";
} else {
str = String.valueOf(value);
}

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "energonrelics:block/lightning_rod"
}
}
}

View File

@ -33,6 +33,5 @@
"item.minecraft.potion.effect.energonrelics.veridium_poison": "Potion of Degradation",
"item.minecraft.splash_potion.effect.energonrelics.veridium_poison": "Splash Potion of Degradation",
"item.minecraft.lingering_potion.effect.energonrelics.veridium_poison": "Lingering Potion of Degradation",
"item.minecraft.tipped_arrow.effect.energonrelics.veridium_poison": "Arrow of Degradation",
"block.energonrelics.lightning_rod": "Lightning Rod"
"item.minecraft.tipped_arrow.effect.energonrelics.veridium_poison": "Arrow of Degradation"
}

View File

@ -1,61 +0,0 @@
{
"parent": "minecraft:block/block",
"textures": {
"1": "energonrelics:block/lightning_rod",
"2": "minecraft:block/polished_blackstone_bricks",
"particle": "minecraft:block/polished_blackstone_bricks"
},
"elements": [
{
"from": [3, 0, 3],
"to": [13, 2, 13],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [3, 0, 13, 2], "texture": "#2"},
"east": {"uv": [3, 0, 13, 2], "texture": "#2"},
"south": {"uv": [3, 0, 13, 2], "texture": "#2"},
"west": {"uv": [3, 0, 13, 2], "texture": "#2"},
"up": {"uv": [0, 0, 16, 16], "texture": "#2"},
"down": {"uv": [0, 0, 16, 16], "texture": "#2"}
}
},
{
"from": [7.5, 2, 7.5],
"to": [8.5, 18, 8.5],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [0, 0, 1, 16], "texture": "#1"},
"east": {"uv": [0, 0, 1, 16], "texture": "#1"},
"south": {"uv": [0, 0, 1, 16], "texture": "#1"},
"west": {"uv": [0, 0, 1, 16], "texture": "#1"},
"up": {"uv": [0, 0, 0, 0], "texture": "#1"},
"down": {"uv": [0, 0, 0, 0], "texture": "#1"}
}
},
{
"from": [7.5, 18, 7.5],
"to": [8.5, 26, 8.5],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [1, 8, 2, 16], "texture": "#1"},
"east": {"uv": [1, 8, 2, 16], "texture": "#1"},
"south": {"uv": [1, 8, 2, 16], "texture": "#1"},
"west": {"uv": [1, 8, 2, 16], "texture": "#1"},
"up": {"uv": [1, 8, 2, 9], "texture": "#1"},
"down": {"uv": [0, 0, 0, 0], "texture": "#1"}
}
}
],
"display": {
"gui": {
"rotation": [30, 225, 0],
"translation": [0, -1.5, 0],
"scale": [0.46875, 0.46875, 0.46875]
},
"fixed": {
"rotation": [0, 0, 0],
"translation": [0, -2, 0],
"scale": [0.375, 0.375, 0.375]
}
}
}

View File

@ -1,3 +0,0 @@
{
"parent": "energonrelics:block/lightning_rod"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B