Add Debug Info
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-07-25 23:13:15 -04:00
parent 41f34c3fdd
commit 30fdf38525
8 changed files with 36 additions and 22 deletions

View File

@ -40,7 +40,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
return new Vec3d(pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d);
}
private Vec3d getPosVec() {
public Vec3d getPosVec() {
return getPosVec(getPos());
}
@ -100,7 +100,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
markDirty();
}
private Vec3d getRayVector() {
public Vec3d getRayVector() {
return DefensiveLaserBlockEntity.getRayVector(yaw, pitch);
}
@ -154,8 +154,6 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
private LivingEntity target;
private int countdown = 0;
private boolean firing = false;
private Predicate<LivingEntity> getTargetPredicate(boolean useCurrentRotation) {
return entity -> {
if (entity.isAlive() && (!(entity instanceof PlayerEntity) || !((PlayerEntity) entity).isCreative()) && !entity.isInvisible() && entity.getPos().distanceTo(getPosVec()) <= HardcodedConfig.DEFENSIVE_LASER_RANGE) {
@ -230,13 +228,9 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
countdown--;
}
if (countdown == 1) {
addAction(new Action(HardcodedConfig.DEFENSIVE_LASER_FIRE_ENERGY_REQUIRED, (world, pos, state) -> {
firing = false;
fire(world, pos);
}, (world, pos, state) -> firing = false));
addAction(new Action(HardcodedConfig.DEFENSIVE_LASER_FIRE_ENERGY_REQUIRED, (world, pos, state) -> fire(world, pos), (world, pos, state) -> {}));
target = null;
firing = true;
} else if (countdown < 1 && !firing) {
} else if (countdown < 1) {
if (target == null) {
List<LivingEntity> entities = getEntities(getTargetPredicate(false));
if (entities.size() > 0) {
@ -276,6 +270,5 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
super.fromTag(state, tag);
rotation.fromTag(tag);
countdown = tag.getInt("Countdown");
firing = false;
}
}

View File

@ -4,12 +4,16 @@ import com.thebrokenrail.energonrelics.EnergonRelics;
import com.thebrokenrail.energonrelics.block.entity.DefensiveLaserBlockEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3d;
public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRenderer {
public DefensiveLaserBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
@ -19,10 +23,11 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
@Override
public void render(BlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
matrices.push();
matrices.translate(0.5d, 0.5d, 0.5d);
matrices.scale(0.6f, 0.6f, 0.6f);
if (entity instanceof DefensiveLaserBlockEntity) {
matrices.push();
matrices.translate(0.5d, 0.5d, 0.5d);
matrices.scale(0.6f, 0.6f, 0.6f);
DefensiveLaserBlockEntity laser = (DefensiveLaserBlockEntity) entity;
float yaw = (float) ((laser.rotation.getYaw()) * DefensiveLaserBlockEntity.DEG2RAD);
@ -37,8 +42,24 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90));
MinecraftClient.getInstance().getItemRenderer().renderItem(new ItemStack(EnergonRelics.DEFENSIVE_LASER_CORE_ITEM), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers);
MinecraftClient client = MinecraftClient.getInstance();
client.getItemRenderer().renderItem(new ItemStack(EnergonRelics.DEFENSIVE_LASER_CORE_ITEM), ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers);
matrices.pop();
if (client.getEntityRenderManager().shouldRenderHitboxes()) {
matrices.push();
Matrix4f matrix4f = matrices.peek().getModel();
Vec3d vec3d = ((DefensiveLaserBlockEntity) entity).rotation.getRayVector().multiply(2d).add(0.5d, 0.5d, 0.5d);
VertexConsumer vertices = vertexConsumers.getBuffer(RenderLayer.getLines());
vertices.vertex(matrix4f, 0.5f, 0.5f, 0.5f).color(0, 0, 255, 255).next();
vertices.vertex(matrix4f, (float) vec3d.getX(), (float) vec3d.getY(), (float) vec3d.getZ()).color(0, 0, 255, 255).next();
matrices.pop();
}
}
matrices.pop();
}
}

View File

@ -1,3 +1,3 @@
{
"parent": "energonrelics:block/block_breaker_on"
"parent": "energonrelics:block/block_breaker_off"
}

View File

@ -1,3 +1,3 @@
{
"parent": "energonrelics:block/defensive_laser_on"
"parent": "energonrelics:block/defensive_laser_off"
}

View File

@ -1,3 +1,3 @@
{
"parent": "energonrelics:block/energon_light_on"
"parent": "energonrelics:block/energon_light_off"
}

View File

@ -1,3 +1,3 @@
{
"parent": "energonrelics:block/forcefield_projector_on"
"parent": "energonrelics:block/forcefield_projector_off"
}

View File

@ -1,3 +1,3 @@
{
"parent": "energonrelics:block/reactor_controller_on"
"parent": "energonrelics:block/reactor_controller_off"
}

View File

@ -1,3 +1,3 @@
{
"parent": "energonrelics:block/switch_on"
"parent": "energonrelics:block/switch_off"
}