Improve Lightning Rod Model
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-07-28 21:46:04 -04:00
parent 03be2d58cd
commit 8c60881c32
16 changed files with 367 additions and 126 deletions

View File

@ -4,7 +4,7 @@ import com.thebrokenrail.energonrelics.block.BlockBreakerBlock;
import com.thebrokenrail.energonrelics.block.CreativeEnergySourceBlock;
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
import com.thebrokenrail.energonrelics.block.HolographicSkyBlock;
import com.thebrokenrail.energonrelics.block.LightningRodBlock;
import com.thebrokenrail.energonrelics.block.lightning.LightningRodBaseBlock;
import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldProjectorBlock;
import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserProjectorBlock;
import com.thebrokenrail.energonrelics.block.forcefield.laser.IndustrialLaserBlock;
@ -12,6 +12,7 @@ import com.thebrokenrail.energonrelics.block.forcefield.beam.RepulsorBeamBlock;
import com.thebrokenrail.energonrelics.block.forcefield.beam.TractorBeamBlock;
import com.thebrokenrail.energonrelics.block.forcefield.beam.TractorBeamProjectorBlock;
import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldBlock;
import com.thebrokenrail.energonrelics.block.lightning.LightningRodBlock;
import com.thebrokenrail.energonrelics.block.misc.VeridiumBlockBlock;
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
import com.thebrokenrail.energonrelics.block.misc.ThermalGlassBlock;
@ -87,6 +88,7 @@ public class EnergonRelics implements ModInitializer {
public static final Item VERIDIUM_POWDER_ITEM = new Item(new Item.Settings().group(ITEM_GROUP));
public static final LightningRodBaseBlock LIGHTNING_ROD_BASE_BLOCK = new LightningRodBaseBlock();
public static final LightningRodBlock LIGHTNING_ROD_BLOCK = new LightningRodBlock();
public static final SpecialRecipeSerializer<DuplicateNetworkChipRecipe> DUPLICATE_NETWORK_CHIP_RECIPE = new SpecialRecipeSerializer<>(DuplicateNetworkChipRecipe::new);
@ -148,6 +150,7 @@ public class EnergonRelics implements ModInitializer {
CustomPotions.register();
LIGHTNING_ROD_BASE_BLOCK.register("lightning_rod_base");
LIGHTNING_ROD_BLOCK.register("lightning_rod");
Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "duplicate_network_chip"), DUPLICATE_NETWORK_CHIP_RECIPE);

View File

@ -1,54 +0,0 @@
package com.thebrokenrail.energonrelics.block;
import com.thebrokenrail.energonrelics.block.entity.LightningRodBlockEntity;
import com.thebrokenrail.energonrelics.block.util.energy.EnergyBlock;
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;
@SuppressWarnings("deprecation")
public class LightningRodBlock extends EnergyBlock {
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).blockVision((state, world, pos) -> false));
}
@Override
@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
public VoxelShape getVisualShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return VoxelShapes.empty();
}
@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));
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return SHAPE;
}
}

View File

@ -16,8 +16,8 @@ import java.util.List;
import java.util.Objects;
import java.util.Random;
public class LightningRodBlockEntity extends EnergyProviderBlockEntity implements EnergyGenerator {
public LightningRodBlockEntity(BlockEntityType<?> type) {
public class LightningRodBaseBlockEntity extends EnergyProviderBlockEntity implements EnergyGenerator {
public LightningRodBaseBlockEntity(BlockEntityType<?> type) {
super(type);
}
@ -59,7 +59,7 @@ public class LightningRodBlockEntity extends EnergyProviderBlockEntity implement
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(), getPos().getZ() + 0.5d);
entity.updatePosition(getPos().getX() + 0.5d, getPos().getY() + 1d, getPos().getZ() + 0.5d);
entity.setCosmetic(true);
Objects.requireNonNull(getWorld()).spawnEntity(entity);

View File

@ -0,0 +1,98 @@
package com.thebrokenrail.energonrelics.block.lightning;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.entity.LightningRodBaseBlockEntity;
import com.thebrokenrail.energonrelics.block.util.energy.EnergyBlock;
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.Blocks;
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.block.enums.DoubleBlockHalf;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import java.util.function.Function;
@SuppressWarnings("deprecation")
public class LightningRodBaseBlock extends EnergyBlock {
public LightningRodBaseBlock() {
super(FabricBlockSettings.of(Material.STONE, MaterialColor.CLEAR).nonOpaque().allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false).requiresTool().strength(1.5f, 6.0f).blockVision((state, world, pos) -> false));
}
@Override
@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
public VoxelShape getVisualShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return VoxelShapes.empty();
}
@Override
public PistonBehavior getPistonBehavior(BlockState state) {
return PistonBehavior.DESTROY;
}
@Override
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
return LightningRodBaseBlockEntity::new;
}
private static final VoxelShape SHAPE = VoxelShapes.union(createCuboidShape(3d, 0d, 3d, 13d, 4d, 13d), createCuboidShape(4d, 4d, 4d, 12d, 8d, 12d), createCuboidShape(5d, 8d, 5d, 11d, 12d, 11d), createCuboidShape(6d, 12d, 6d, 10d, 16d, 10d));
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return SHAPE;
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
boolean valid = true;
if (direction == Direction.UP && (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(LightningRodBlock.HALF) != DoubleBlockHalf.LOWER)) {
valid = false;
}
if (valid) {
return super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
} else {
return Blocks.AIR.getDefaultState();
}
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
super.onPlaced(world, pos, state, placer, itemStack);
world.setBlockState(pos.up(2), EnergonRelics.LIGHTNING_ROD_BLOCK.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.UPPER));
world.setBlockState(pos.up(1), EnergonRelics.LIGHTNING_ROD_BLOCK.getDefaultState().with(LightningRodBlock.HALF, DoubleBlockHalf.LOWER));
}
@Override
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;
}
}

View File

@ -0,0 +1,124 @@
package com.thebrokenrail.energonrelics.block.lightning;
import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.util.SimpleBlock;
import com.thebrokenrail.energonrelics.util.MissingCaseException;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.enums.DoubleBlockHalf;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
@SuppressWarnings("deprecation")
public class LightningRodBlock extends SimpleBlock {
public static final EnumProperty<DoubleBlockHalf> HALF = Properties.DOUBLE_BLOCK_HALF;
public LightningRodBlock() {
super(FabricBlockSettings.copy(EnergonRelics.LIGHTNING_ROD_BASE_BLOCK).dropsNothing().emissiveLighting((state, world, pos) -> true).lightLevel(state -> 10));
setDefaultState(getDefaultState().with(HALF, DoubleBlockHalf.LOWER));
}
@Override
@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
public VoxelShape getVisualShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return VoxelShapes.empty();
}
@Override
public PistonBehavior getPistonBehavior(BlockState state) {
return PistonBehavior.DESTROY;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(HALF);
}
@Override
protected boolean registerItem() {
return false;
}
private static final VoxelShape LOWER_SHAPE = createCuboidShape(7.5d, 0d, 7.5d, 8.5d, 16d, 8.5d);
private static final VoxelShape UPPER_SHAPE = createCuboidShape(7.5d, 0d, 7.5d, 8.5d, 8d, 8.5d);
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
DoubleBlockHalf half = state.get(HALF);
switch (half) {
case LOWER: {
return LOWER_SHAPE;
}
case UPPER: {
return UPPER_SHAPE;
}
default: {
throw new MissingCaseException(half);
}
}
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
boolean valid = true;
if (state.get(HALF) == DoubleBlockHalf.LOWER) {
if (direction == Direction.UP) {
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(HALF) != DoubleBlockHalf.UPPER) {
valid = false;
}
} else if (direction == Direction.DOWN) {
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BASE_BLOCK) {
valid = false;
}
}
} else if (state.get(HALF) == DoubleBlockHalf.UPPER && direction == Direction.DOWN) {
if (newState.getBlock() != EnergonRelics.LIGHTNING_ROD_BLOCK || newState.get(HALF) != DoubleBlockHalf.LOWER) {
valid = false;
}
}
if (valid) {
return super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
} else {
return Blocks.AIR.getDefaultState();
}
}
@Override
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
if (!world.isClient() && player.isCreative()) {
int distance = state.get(HALF) == DoubleBlockHalf.LOWER ? 1 : 2;
BlockPos targetPos = pos.down(distance);
world.breakBlock(targetPos, false, player);
}
super.onBreak(world, pos, state, player);
}
}

View File

@ -1,7 +1,10 @@
{
"variants": {
"": {
"model": "energonrelics:block/lightning_rod"
"half=lower": {
"model": "energonrelics:block/lightning_rod_lower"
},
"half=upper": {
"model": "energonrelics:block/lightning_rod_upper"
}
}
}

View File

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

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

@ -0,0 +1,58 @@
{
"parent": "minecraft:block/block",
"textures": {
"1": "energonrelics:block/lightning_rod_base",
"particle": "#1"
},
"elements": [
{
"from": [3, 0, 3],
"to": [13, 4, 13],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [3, 12, 13, 16], "texture": "#1"},
"east": {"uv": [3, 12, 13, 16], "texture": "#1"},
"south": {"uv": [3, 12, 13, 16], "texture": "#1"},
"west": {"uv": [3, 12, 13, 16], "texture": "#1"},
"up": {"uv": [3, 3, 13, 13], "texture": "#1"},
"down": {"uv": [3, 3, 13, 13], "texture": "#1"}
}
},
{
"from": [4, 4, 4],
"to": [12, 8, 12],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [4, 8, 12, 12], "texture": "#1"},
"east": {"uv": [4, 8, 12, 12], "texture": "#1"},
"south": {"uv": [4, 8, 12, 12], "texture": "#1"},
"west": {"uv": [4, 8, 12, 12], "texture": "#1"},
"up": {"uv": [4, 4, 12, 12], "texture": "#1"}
}
},
{
"from": [5, 8, 5],
"to": [11, 12, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [5, 4, 11, 8], "texture": "#1"},
"east": {"uv": [5, 4, 11, 8], "texture": "#1"},
"south": {"uv": [5, 4, 11, 8], "texture": "#1"},
"west": {"uv": [5, 4, 11, 8], "texture": "#1"},
"up": {"uv": [5, 5, 11, 11], "texture": "#1"}
}
},
{
"from": [6, 12, 6],
"to": [10, 16, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [6, 0, 10, 4], "texture": "#1"},
"east": {"uv": [6, 0, 10, 4], "texture": "#1"},
"south": {"uv": [6, 0, 10, 4], "texture": "#1"},
"west": {"uv": [6, 0, 10, 4], "texture": "#1"},
"up": {"uv": [6, 6, 10, 10], "texture": "#1"}
}
}
]
}

View File

@ -0,0 +1,20 @@
{
"parent": "minecraft:block/block",
"textures": {
"1": "energonrelics:block/lightning_rod",
"particle": "#1"
},
"elements": [
{
"from": [7.5, 0, 7.5],
"to": [8.5, 16, 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"}
}
}
]
}

View File

@ -0,0 +1,21 @@
{
"parent": "minecraft:block/block",
"textures": {
"1": "energonrelics:block/lightning_rod",
"particle": "#1"
},
"elements": [
{
"from": [7.5, 0, 7.5],
"to": [8.5, 8, 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"}
}
}
]
}

View File

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

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "energonrelics:item/lightning_rod"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "energonrelics:lightning_rod_base"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -10,14 +10,14 @@
"item": "minecraft:blaze_rod"
},
"B": {
"item": "minecraft:polished_blackstone_bricks"
"item": "minecraft:blackstone"
},
"#": {
"item": "energonrelics:circuit_board"
}
},
"result": {
"item": "energonrelics:lightning_rod",
"item": "energonrelics:lightning_rod_base",
"count": 1
}
}