This commit is contained in:
parent
f11e346a27
commit
7f813582c1
@ -4,6 +4,8 @@ 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.forcefield.ForcefieldBlock;
|
||||
import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldProjectorBlock;
|
||||
import com.thebrokenrail.energonrelics.block.structure.StructureGeneratorBlock;
|
||||
import com.thebrokenrail.energonrelics.block.ThermalGlassBlock;
|
||||
import com.thebrokenrail.energonrelics.block.battery.ActiveBatteryControllerBlock;
|
||||
@ -77,6 +79,9 @@ public class EnergonRelics implements ModInitializer {
|
||||
|
||||
public static final SpecialRecipeSerializer<DuplicateNetworkChipRecipe> DUPLICATE_NETWORK_CHIP_RECIPE = new SpecialRecipeSerializer<>(DuplicateNetworkChipRecipe::new);
|
||||
|
||||
public static final ForcefieldBlock FORCEFIELD_BLOCK = new ForcefieldBlock();
|
||||
public static final ForcefieldProjectorBlock FORCEFIELD_PROJECTOR_BLOCK = new ForcefieldProjectorBlock();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
NETWORK_CHIP_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "network_chip"), new NetworkChipItem());
|
||||
@ -117,5 +122,8 @@ public class EnergonRelics implements ModInitializer {
|
||||
LIGHTNING_ROD_BLOCK.register("lightning_rod");
|
||||
|
||||
Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(NAMESPACE, "duplicate_network_chip"), DUPLICATE_NETWORK_CHIP_RECIPE);
|
||||
|
||||
FORCEFIELD_BLOCK.register("forcefield");
|
||||
FORCEFIELD_PROJECTOR_BLOCK.register("forcefield_projector");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.thebrokenrail.energonrelics.block.entity.forcefield;
|
||||
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldBlock;
|
||||
import com.thebrokenrail.energonrelics.block.forcefield.ForcefieldProjectorBlock;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import com.thebrokenrail.energonrelics.energy.core.EnergyReceiverBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.energy.core.util.Action;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
public class ForcefieldProjectorBlockEntity extends EnergyReceiverBlockEntity {
|
||||
public ForcefieldProjectorBlockEntity(BlockEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tickEnergy() {
|
||||
assert getWorld() != null;
|
||||
|
||||
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.FORCEFIELD_PROJECTOR_ENERGY_REQUIRED, ForcefieldProjectorBlock.POWERED, true, false, new Identifier(EnergonRelics.NAMESPACE, "forcefield_projector")));
|
||||
if (getCachedState().get(ForcefieldProjectorBlock.POWERED)) {
|
||||
Direction facing = getCachedState().get(ForcefieldProjectorBlock.FACING);
|
||||
BlockState state = EnergonRelics.FORCEFIELD_BLOCK.getDefaultState().with(ForcefieldBlock.FACING, facing);
|
||||
for (int i = 1; i < HardcodedConfig.FORCEFIELD_MAX_SIZE + 1; i++) {
|
||||
BlockPos targetPos = getPos().offset(facing, i);
|
||||
BlockState targetState = getWorld().getBlockState(targetPos);
|
||||
if (targetState.isAir()) {
|
||||
getWorld().setBlockState(targetPos, state);
|
||||
} else if (targetState.getBlock() != EnergonRelics.FORCEFIELD_BLOCK) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.thebrokenrail.energonrelics.block.forcefield;
|
||||
|
||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||
import com.thebrokenrail.energonrelics.block.util.SimpleBlock;
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
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.piston.PistonBehavior;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ForcefieldBlock extends SimpleBlock {
|
||||
public static final DirectionProperty FACING = Properties.FACING;
|
||||
|
||||
public ForcefieldBlock() {
|
||||
super(FabricBlockSettings.copy(Blocks.BARRIER).dropsNothing().lightLevel(state -> 4).emissiveLighting((state, world, pos) -> true).nonOpaque().sounds(BlockSoundGroup.GLASS).allowsSpawning((state, world, pos, type) -> false).solidBlock((state, world, pos) -> false).suffocates((state, world, pos) -> false));
|
||||
setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return state.with(FACING, rotation.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return state.rotate(mirror.getRotation(state.get(FACING)));
|
||||
}
|
||||
|
||||
@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
|
||||
protected boolean registerItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||
BlockState defaultState = super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom);
|
||||
Direction facing = state.get(FACING).getOpposite();
|
||||
if (direction.equals(facing)) {
|
||||
boolean found = false;
|
||||
for (int i = 0; i < HardcodedConfig.FORCEFIELD_MAX_SIZE + 1; i++) {
|
||||
BlockPos targetPos = pos.offset(facing, i);
|
||||
BlockState targetState = world.getBlockState(targetPos);
|
||||
if (targetState.getBlock() == this) {
|
||||
if (!facing.equals(targetState.get(FACING).getOpposite())) {
|
||||
break;
|
||||
}
|
||||
} else if (targetState.getBlock() == EnergonRelics.FORCEFIELD_PROJECTOR_BLOCK) {
|
||||
if (facing.equals(targetState.get(FACING).getOpposite()) && targetState.get(ForcefieldProjectorBlock.POWERED)) {
|
||||
found = true;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found ? defaultState : Blocks.AIR.getDefaultState();
|
||||
} else {
|
||||
return defaultState;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public boolean isSideInvisible(BlockState state, BlockState stateFrom, Direction direction) {
|
||||
return stateFrom.isOf(this) || super.isSideInvisible(state, stateFrom, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PistonBehavior getPistonBehavior(BlockState state) {
|
||||
return PistonBehavior.DESTROY;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.thebrokenrail.energonrelics.block.forcefield;
|
||||
|
||||
import com.thebrokenrail.energonrelics.block.entity.forcefield.ForcefieldProjectorBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.block.util.energy.FacingEnergyProviderBlock;
|
||||
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.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ForcefieldProjectorBlock extends FacingEnergyProviderBlock {
|
||||
public static final BooleanProperty POWERED = Properties.POWERED;
|
||||
|
||||
public ForcefieldProjectorBlock() {
|
||||
super(FabricBlockSettings.copy(Blocks.IRON_BLOCK));
|
||||
setDefaultState(getDefaultState().with(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
|
||||
return ForcefieldProjectorBlockEntity::new;
|
||||
}
|
||||
}
|
@ -15,14 +15,20 @@ public class SimpleBlock extends Block {
|
||||
|
||||
public void register(String name) {
|
||||
Registry.register(Registry.BLOCK, new Identifier(EnergonRelics.NAMESPACE, name), this);
|
||||
if (registerItem()) {
|
||||
Item.Settings settings = new Item.Settings();
|
||||
if (addToItemGroup() || FabricLoader.getInstance().isDevelopmentEnvironment()) {
|
||||
settings.group(EnergonRelics.ITEM_GROUP);
|
||||
}
|
||||
Registry.register(Registry.ITEM, new Identifier(EnergonRelics.NAMESPACE, name), new BlockItem(this, settings));
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean addToItemGroup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean registerItem() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,10 @@ public class EnergonRelicsClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
EnergyProviderBlock.initRenderer();
|
||||
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.THERMAL_GLASS_BLOCK, RenderLayer.getCutout());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.DEFENSIVE_LASER_BLOCK, RenderLayer.getCutout());
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(EnergonRelics.FORCEFIELD_BLOCK, RenderLayer.getTranslucent());
|
||||
|
||||
AutoConfig.register(UserConfig.class, ReloadSerializer::new);
|
||||
}
|
||||
|
@ -27,4 +27,7 @@ public class HardcodedConfig {
|
||||
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 FORCEFIELD_PROJECTOR_ENERGY_REQUIRED = 64;
|
||||
public static final int FORCEFIELD_MAX_SIZE = 12;
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "energonrelics:block/forcefield"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
{
|
||||
"variants": {
|
||||
"facing=down,powered=false": {
|
||||
"model": "energonrelics:block/forcefield_projector_off",
|
||||
"x": 90
|
||||
},
|
||||
"facing=down,powered=true": {
|
||||
"model": "energonrelics:block/forcefield_projector_on",
|
||||
"x": 90
|
||||
},
|
||||
"facing=east,powered=false": {
|
||||
"model": "energonrelics:block/forcefield_projector_off",
|
||||
"y": 90
|
||||
},
|
||||
"facing=east,powered=true": {
|
||||
"model": "energonrelics:block/forcefield_projector_on",
|
||||
"y": 90
|
||||
},
|
||||
"facing=north,powered=false": {
|
||||
"model": "energonrelics:block/forcefield_projector_off"
|
||||
},
|
||||
"facing=north,powered=true": {
|
||||
"model": "energonrelics:block/forcefield_projector_on"
|
||||
},
|
||||
"facing=south,powered=false": {
|
||||
"model": "energonrelics:block/forcefield_projector_off",
|
||||
"y": 180
|
||||
},
|
||||
"facing=south,powered=true": {
|
||||
"model": "energonrelics:block/forcefield_projector_on",
|
||||
"y": 180
|
||||
},
|
||||
"facing=up,powered=false": {
|
||||
"model": "energonrelics:block/forcefield_projector_off",
|
||||
"x": 270
|
||||
},
|
||||
"facing=up,powered=true": {
|
||||
"model": "energonrelics:block/forcefield_projector_on",
|
||||
"x": 270
|
||||
},
|
||||
"facing=west,powered=false": {
|
||||
"model": "energonrelics:block/forcefield_projector_off",
|
||||
"y": 270
|
||||
},
|
||||
"facing=west,powered=true": {
|
||||
"model": "energonrelics:block/forcefield_projector_on",
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
@ -34,5 +34,7 @@
|
||||
"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"
|
||||
"block.energonrelics.lightning_rod": "Lightning Rod",
|
||||
"block.energonrelics.forcefield": "Forcefield",
|
||||
"block.energonrelics.forcefield_projector": "Forcefield Projector"
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:block/cube_all",
|
||||
"textures": {
|
||||
"all": "energonrelics:block/forcefield"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/orientable",
|
||||
"textures": {
|
||||
"top": "energonrelics:block/forcefield_projector_side",
|
||||
"front": "energonrelics:block/forcefield_projector_off",
|
||||
"side": "energonrelics:block/forcefield_projector_side"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/orientable",
|
||||
"textures": {
|
||||
"top": "energonrelics:block/forcefield_projector_side",
|
||||
"front": "energonrelics:block/forcefield_projector_on",
|
||||
"side": "energonrelics:block/forcefield_projector_side"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "energonrelics:block/forcefield_projector_on"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 491 B |
Binary file not shown.
After Width: | Height: | Size: 733 B |
Binary file not shown.
After Width: | Height: | Size: 731 B |
Binary file not shown.
After Width: | Height: | Size: 651 B |
@ -0,0 +1,19 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "energonrelics:forcefield_projector"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user