This commit is contained in:
parent
b9f1987332
commit
deb00f4798
@ -24,11 +24,11 @@ public class FieldProjectorBlockEntity extends EnergyReceiverBlockEntity {
|
|||||||
protected void energyTick() {
|
protected void energyTick() {
|
||||||
assert getWorld() != null;
|
assert getWorld() != null;
|
||||||
|
|
||||||
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.FORCEFIELD_PROJECTOR_ENERGY_REQUIRED, FieldProjectorBlock.POWERED, true, false));
|
addAction(Action.createBlockStatePropertyAction(HardcodedConfig.FIELD_PROJECTOR_ENERGY_REQUIRED, FieldProjectorBlock.POWERED, true, false));
|
||||||
if (getCachedState().get(FieldProjectorBlock.POWERED)) {
|
if (getCachedState().get(FieldProjectorBlock.POWERED)) {
|
||||||
Direction facing = getCachedState().get(FieldProjectorBlock.FACING);
|
Direction facing = getCachedState().get(FieldProjectorBlock.FACING);
|
||||||
BlockState state = block.apply(getCachedState()).getDefaultState().with(AbstractFieldBlock.FACING, facing);
|
BlockState state = block.apply(getCachedState()).getDefaultState().with(AbstractFieldBlock.FACING, facing);
|
||||||
for (int i = 1; i < HardcodedConfig.FORCEFIELD_MAX_SIZE + 1; i++) {
|
for (int i = 1; i < HardcodedConfig.FIELD_MAX_SIZE + 1; i++) {
|
||||||
BlockPos targetPos = getPos().offset(facing, i);
|
BlockPos targetPos = getPos().offset(facing, i);
|
||||||
BlockState targetState = getWorld().getBlockState(targetPos);
|
BlockState targetState = getWorld().getBlockState(targetPos);
|
||||||
if (targetState.isAir() || (targetState != state && targetState.getBlock() instanceof AbstractFieldBlock && targetState.get(AbstractFieldBlock.FACING) == facing)) {
|
if (targetState.isAir() || (targetState != state && targetState.getBlock() instanceof AbstractFieldBlock && targetState.get(AbstractFieldBlock.FACING) == facing)) {
|
||||||
|
@ -11,6 +11,7 @@ import net.minecraft.state.property.BooleanProperty;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -30,7 +31,7 @@ public class TractorBeamProjectorBlock extends FieldProjectorBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
return getDefaultState().with(IS_REPULSOR, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
|
return Objects.requireNonNull(super.getPlacementState(ctx)).with(IS_REPULSOR, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,7 +75,7 @@ public abstract class AbstractFieldBlock extends SimpleBlock {
|
|||||||
public FieldProjectorBlockEntity findProjector(BlockView world, BlockPos pos, BlockState state) {
|
public FieldProjectorBlockEntity findProjector(BlockView world, BlockPos pos, BlockState state) {
|
||||||
Direction facing = state.get(FACING).getOpposite();
|
Direction facing = state.get(FACING).getOpposite();
|
||||||
FieldProjectorBlockEntity found = null;
|
FieldProjectorBlockEntity found = null;
|
||||||
for (int i = 0; i < HardcodedConfig.FORCEFIELD_MAX_SIZE + 1; i++) {
|
for (int i = 0; i < HardcodedConfig.FIELD_MAX_SIZE + 1; i++) {
|
||||||
BlockPos targetPos = pos.offset(facing, i);
|
BlockPos targetPos = pos.offset(facing, i);
|
||||||
BlockState targetState = world.getBlockState(targetPos);
|
BlockState targetState = world.getBlockState(targetPos);
|
||||||
if (targetState.getBlock() == this) {
|
if (targetState.getBlock() == this) {
|
||||||
|
@ -2,6 +2,7 @@ package com.thebrokenrail.energonrelics.block.forcefield.util;
|
|||||||
|
|
||||||
import com.thebrokenrail.energonrelics.EnergonRelics;
|
import com.thebrokenrail.energonrelics.EnergonRelics;
|
||||||
import com.thebrokenrail.energonrelics.block.forcefield.TractorBeamProjectorBlock;
|
import com.thebrokenrail.energonrelics.block.forcefield.TractorBeamProjectorBlock;
|
||||||
|
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@ -32,14 +33,14 @@ public class BeamBlock extends AbstractFieldBlock {
|
|||||||
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||||
super.onEntityCollision(state, world, pos, entity);
|
super.onEntityCollision(state, world, pos, entity);
|
||||||
if (!(entity instanceof PlayerEntity) || !((PlayerEntity) entity).abilities.flying) {
|
if (!(entity instanceof PlayerEntity) || !((PlayerEntity) entity).abilities.flying) {
|
||||||
entity.slowMovement(state, new Vec3d(0.9d, 0.9d, 0.9d));
|
entity.slowMovement(state, new Vec3d(HardcodedConfig.TRACTOR_BEAM_MOVEMENT_MULTIPLIER, HardcodedConfig.TRACTOR_BEAM_MOVEMENT_MULTIPLIER, HardcodedConfig.TRACTOR_BEAM_MOVEMENT_MULTIPLIER));
|
||||||
|
|
||||||
Direction facing = state.get(FACING);
|
Direction facing = state.get(FACING);
|
||||||
if (!isRepulsor) {
|
if (!isRepulsor) {
|
||||||
facing = facing.getOpposite();
|
facing = facing.getOpposite();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d pullForce = Vec3d.of(facing.getVector()).multiply(0.065f);
|
Vec3d pullForce = Vec3d.of(facing.getVector()).multiply(HardcodedConfig.TRACTOR_BEAM_PULL_FORCE);
|
||||||
entity.addVelocity(pullForce.getX(), pullForce.getY(), pullForce.getZ());
|
entity.addVelocity(pullForce.getX(), pullForce.getY(), pullForce.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,11 @@ public class HardcodedConfig {
|
|||||||
public static final double LIGHTNING_ROD_CHANCE = 0.00005d;
|
public static final double LIGHTNING_ROD_CHANCE = 0.00005d;
|
||||||
public static final int LIGHTNING_ROD_COOLDOWN = 5;
|
public static final int LIGHTNING_ROD_COOLDOWN = 5;
|
||||||
|
|
||||||
public static final long FORCEFIELD_PROJECTOR_ENERGY_REQUIRED = 64;
|
public static final long FIELD_PROJECTOR_ENERGY_REQUIRED = 64;
|
||||||
public static final int FORCEFIELD_MAX_SIZE = 12;
|
public static final int FIELD_MAX_SIZE = 12;
|
||||||
|
|
||||||
|
public static final double TRACTOR_BEAM_MOVEMENT_MULTIPLIER = 0.95d;
|
||||||
|
public static final double TRACTOR_BEAM_PULL_FORCE = 0.065d;
|
||||||
|
|
||||||
public static final long HOLOGRAPHIC_SKY_ENERGY_REQUIRED = 15;
|
public static final long HOLOGRAPHIC_SKY_ENERGY_REQUIRED = 15;
|
||||||
}
|
}
|
Reference in New Issue
Block a user