This commit is contained in:
parent
41f34c3fdd
commit
30fdf38525
@ -40,7 +40,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
|||||||
return new Vec3d(pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d);
|
return new Vec3d(pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vec3d getPosVec() {
|
public Vec3d getPosVec() {
|
||||||
return getPosVec(getPos());
|
return getPosVec(getPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
|||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vec3d getRayVector() {
|
public Vec3d getRayVector() {
|
||||||
return DefensiveLaserBlockEntity.getRayVector(yaw, pitch);
|
return DefensiveLaserBlockEntity.getRayVector(yaw, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,8 +154,6 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
|||||||
private LivingEntity target;
|
private LivingEntity target;
|
||||||
private int countdown = 0;
|
private int countdown = 0;
|
||||||
|
|
||||||
private boolean firing = false;
|
|
||||||
|
|
||||||
private Predicate<LivingEntity> getTargetPredicate(boolean useCurrentRotation) {
|
private Predicate<LivingEntity> getTargetPredicate(boolean useCurrentRotation) {
|
||||||
return entity -> {
|
return entity -> {
|
||||||
if (entity.isAlive() && (!(entity instanceof PlayerEntity) || !((PlayerEntity) entity).isCreative()) && !entity.isInvisible() && entity.getPos().distanceTo(getPosVec()) <= HardcodedConfig.DEFENSIVE_LASER_RANGE) {
|
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--;
|
countdown--;
|
||||||
}
|
}
|
||||||
if (countdown == 1) {
|
if (countdown == 1) {
|
||||||
addAction(new Action(HardcodedConfig.DEFENSIVE_LASER_FIRE_ENERGY_REQUIRED, (world, pos, state) -> {
|
addAction(new Action(HardcodedConfig.DEFENSIVE_LASER_FIRE_ENERGY_REQUIRED, (world, pos, state) -> fire(world, pos), (world, pos, state) -> {}));
|
||||||
firing = false;
|
|
||||||
fire(world, pos);
|
|
||||||
}, (world, pos, state) -> firing = false));
|
|
||||||
target = null;
|
target = null;
|
||||||
firing = true;
|
} else if (countdown < 1) {
|
||||||
} else if (countdown < 1 && !firing) {
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
List<LivingEntity> entities = getEntities(getTargetPredicate(false));
|
List<LivingEntity> entities = getEntities(getTargetPredicate(false));
|
||||||
if (entities.size() > 0) {
|
if (entities.size() > 0) {
|
||||||
@ -276,6 +270,5 @@ public class DefensiveLaserBlockEntity extends EnergyReceiverBlockEntity {
|
|||||||
super.fromTag(state, tag);
|
super.fromTag(state, tag);
|
||||||
rotation.fromTag(tag);
|
rotation.fromTag(tag);
|
||||||
countdown = tag.getInt("Countdown");
|
countdown = tag.getInt("Countdown");
|
||||||
firing = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,16 @@ import com.thebrokenrail.energonrelics.EnergonRelics;
|
|||||||
import com.thebrokenrail.energonrelics.block.entity.DefensiveLaserBlockEntity;
|
import com.thebrokenrail.energonrelics.block.entity.DefensiveLaserBlockEntity;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.Matrix4f;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRenderer {
|
public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRenderer {
|
||||||
public DefensiveLaserBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
|
public DefensiveLaserBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) {
|
||||||
@ -19,10 +23,11 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
|
|||||||
@Override
|
@Override
|
||||||
public void render(BlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
public void render(BlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||||
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
|
super.render(entity, tickDelta, matrices, vertexConsumers, light, overlay);
|
||||||
|
if (entity instanceof DefensiveLaserBlockEntity) {
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(0.5d, 0.5d, 0.5d);
|
matrices.translate(0.5d, 0.5d, 0.5d);
|
||||||
matrices.scale(0.6f, 0.6f, 0.6f);
|
matrices.scale(0.6f, 0.6f, 0.6f);
|
||||||
if (entity instanceof DefensiveLaserBlockEntity) {
|
|
||||||
DefensiveLaserBlockEntity laser = (DefensiveLaserBlockEntity) entity;
|
DefensiveLaserBlockEntity laser = (DefensiveLaserBlockEntity) entity;
|
||||||
|
|
||||||
float yaw = (float) ((laser.rotation.getYaw()) * DefensiveLaserBlockEntity.DEG2RAD);
|
float yaw = (float) ((laser.rotation.getYaw()) * DefensiveLaserBlockEntity.DEG2RAD);
|
||||||
@ -37,8 +42,24 @@ public class DefensiveLaserBlockEntityRenderer extends HighlightBlockEntityRende
|
|||||||
|
|
||||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90));
|
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();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"parent": "energonrelics:block/block_breaker_on"
|
"parent": "energonrelics:block/block_breaker_off"
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"parent": "energonrelics:block/defensive_laser_on"
|
"parent": "energonrelics:block/defensive_laser_off"
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"parent": "energonrelics:block/energon_light_on"
|
"parent": "energonrelics:block/energon_light_off"
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"parent": "energonrelics:block/forcefield_projector_on"
|
"parent": "energonrelics:block/forcefield_projector_off"
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"parent": "energonrelics:block/reactor_controller_on"
|
"parent": "energonrelics:block/reactor_controller_off"
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"parent": "energonrelics:block/switch_on"
|
"parent": "energonrelics:block/switch_off"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user