mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Compare commits
10 commits
78258dce4e
...
65d660ad08
Author | SHA1 | Date | |
---|---|---|---|
|
65d660ad08 | ||
|
668f7ffed3 | ||
|
b8575c4a67 | ||
|
e9d917dc64 | ||
|
74982c36b5 | ||
|
74addcb6e0 | ||
|
de635bb709 | ||
|
5fb22fa63c | ||
|
7fb62cb859 | ||
|
db1bb6e7eb |
24 changed files with 376 additions and 272 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
# 1.3.9+mc1.21.1
|
||||||
|
* Change laser rendering to be compatible with Iris
|
||||||
|
* Fix machines in the Engineer House being obtainable when broken
|
||||||
|
* Fixed the drill breaking when out of energy.
|
||||||
|
* Hopefully fixed crash with Lithium on dedicated servers.
|
||||||
|
|
||||||
# 1.3.8+mc1.21.1
|
# 1.3.8+mc1.21.1
|
||||||
* Lock the Immersive Engineering cloche compat recipes behind a mod loaded condition
|
* Lock the Immersive Engineering cloche compat recipes behind a mod loaded condition
|
||||||
* Add the stairs, slabs and walls to the appropriate block/item tags
|
* Add the stairs, slabs and walls to the appropriate block/item tags
|
||||||
|
|
|
@ -4,7 +4,7 @@ org.gradle.parallel=true
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.configuration-cache=false
|
org.gradle.configuration-cache=false
|
||||||
|
|
||||||
mod_version=1.3.8
|
mod_version=1.3.9
|
||||||
|
|
||||||
# Forge
|
# Forge
|
||||||
game_version=1.21.1
|
game_version=1.21.1
|
||||||
|
|
|
@ -10,14 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.ReconstructorHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -39,7 +37,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -47,6 +44,7 @@ import java.text.NumberFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container implements IHudDisplay {
|
public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new ReconstructorHud();
|
||||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||||
|
|
||||||
public static final int NAME_FLAVOR_AMOUNTS_1 = 12;
|
public static final int NAME_FLAVOR_AMOUNTS_1 = 12;
|
||||||
|
@ -121,25 +119,8 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
if (!(rayCast instanceof BlockHitResult) || minecraft.level == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
|
||||||
if (tile instanceof TileEntityAtomicReconstructor) {
|
|
||||||
ItemStack slot = ((TileEntityAtomicReconstructor) tile).inv.getStackInSlot(0);
|
|
||||||
Component lens_name;
|
|
||||||
if (slot.isEmpty()) {
|
|
||||||
lens_name = Component.translatable("info.actuallyadditions.nolens");
|
|
||||||
} else {
|
|
||||||
lens_name = slot.getItem().getName(slot);
|
|
||||||
|
|
||||||
AssetUtil.renderStackToGui(slot, resolution.getGuiScaledWidth() / 2 + 15, resolution.getGuiScaledHeight() / 2 - 19, 1F);
|
|
||||||
}
|
|
||||||
guiGraphics.drawString(minecraft.font, lens_name.plainCopy().withStyle(ChatFormatting.YELLOW).withStyle(ChatFormatting.ITALIC).getString(), (int) (resolution.getGuiScaledWidth() / 2.0f + 35), (int) (resolution.getGuiScaledHeight() / 2.0f - 15), 0xFFFFFF);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TheItemBlock extends AABlockItem {
|
public static class TheItemBlock extends AABlockItem {
|
||||||
|
|
|
@ -10,29 +10,19 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.LaserRelayHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade;
|
import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyAdvanced;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyExtreme;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayFluids;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemAdvanced;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.ItemInteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -45,7 +35,6 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
|
@ -55,7 +44,7 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class BlockLaserRelay extends FullyDirectionalBlock.Container implements IHudDisplay {
|
public class BlockLaserRelay extends FullyDirectionalBlock.Container implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new LaserRelayHud();
|
||||||
//This took way too much fiddling around. I'm not good with numbers.
|
//This took way too much fiddling around. I'm not good with numbers.
|
||||||
// private static final float F = 1 / 16F;
|
// private static final float F = 1 / 16F;
|
||||||
// private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(2 * F, 0, 2 * F, 1 - 2 * F, 10 * F, 1 - 2 * F);
|
// private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(2 * F, 0, 2 * F, 1 - 2 * F, 10 * F, 1 - 2 * F);
|
||||||
|
@ -195,38 +184,6 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
|
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
|
||||||
if (!(rayCast instanceof BlockHitResult)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockPos pos = ((BlockHitResult) rayCast).getBlockPos();
|
|
||||||
if (minecraft.level != null) {
|
|
||||||
boolean wearing = ItemEngineerGoggles.isWearing(player);
|
|
||||||
if (wearing || !stack.isEmpty()) {
|
|
||||||
boolean compass = stack.getItem() == CommonConfig.Other.relayConfigureItem;
|
|
||||||
if (wearing || compass || stack.getItem() instanceof ItemLaserWrench) {
|
|
||||||
BlockEntity tile = minecraft.level.getBlockEntity(pos);
|
|
||||||
if (tile instanceof TileEntityLaserRelay relay) {
|
|
||||||
|
|
||||||
Component strg = relay.getExtraDisplayString();
|
|
||||||
guiGraphics.drawString(minecraft.font, strg, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 5), 0xFFFFFF);
|
|
||||||
|
|
||||||
Component expl;
|
|
||||||
if (compass) {
|
|
||||||
expl = relay.getCompassDisplayString();
|
|
||||||
} else {
|
|
||||||
expl = Component.translatable("info.actuallyadditions.laserRelay.mode.noCompasss", Component.translatable(CommonConfig.Other.relayConfigureItem.getDescriptionId()).getString()).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
guiGraphics.drawString(minecraft.font, expl, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 15), 0xFFFFFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
|
@ -251,6 +208,11 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements
|
||||||
}
|
}
|
||||||
super.onRemove(state, world, pos, newState, isMoving);
|
super.onRemove(state, world, pos, newState, isMoving);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
|
return HUD;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public void breakBlock(World world, BlockPos pos, BlockState state) {
|
// public void breakBlock(World world, BlockPos pos, BlockState state) {
|
||||||
|
|
|
@ -10,28 +10,23 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.LavaFactoryControllerHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class BlockLavaFactoryController extends DirectionalBlock.Container implements IHudDisplay {
|
public class BlockLavaFactoryController extends DirectionalBlock.Container implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new LavaFactoryControllerHud();
|
||||||
|
|
||||||
public BlockLavaFactoryController() {
|
public BlockLavaFactoryController() {
|
||||||
super(ActuallyBlocks.defaultPickProps(4.5F, 20.0F).sound(SoundType.METAL));
|
super(ActuallyBlocks.defaultPickProps(4.5F, 20.0F).sound(SoundType.METAL));
|
||||||
|
@ -50,22 +45,11 @@ public class BlockLavaFactoryController extends DirectionalBlock.Container imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
if (!(rayCast instanceof BlockHitResult)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController) minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
|
||||||
if (factory != null) {
|
|
||||||
int state = factory.isMultiblock();
|
|
||||||
if (state == TileEntityLavaFactoryController.NOT_MULTI) {
|
|
||||||
guiGraphics.drawWordWrap(minecraft.font, Component.translatable("tooltip.actuallyadditions.factory.notPart.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 5, 200, 0xFFFFFF);
|
|
||||||
} else if (state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA) {
|
|
||||||
guiGraphics.drawWordWrap(minecraft.font, Component.translatable("tooltip.actuallyadditions.factory.working.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 5, 200, 0xFFFFFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @Override
|
/* @Override
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||||
|
|
|
@ -10,46 +10,30 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBreaker;
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomEnergyface;
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.PhantomHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomItemface;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomLiquiface;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomRedstoneface;
|
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.FormattedText;
|
|
||||||
import net.minecraft.util.FormattedCharSequence;
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.ItemInteractionResult;
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
|
public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new PhantomHud();
|
||||||
|
|
||||||
public final Type type;
|
public final Type type;
|
||||||
|
|
||||||
|
@ -141,44 +125,11 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
if (!(rayCast instanceof BlockHitResult)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BlockPos pos = ((BlockHitResult) rayCast).getBlockPos();
|
|
||||||
BlockEntity tile = minecraft.level.getBlockEntity(pos);
|
|
||||||
if (tile != null) {
|
|
||||||
if (tile instanceof IPhantomTile phantom) {
|
|
||||||
guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.blockPhantomRange.desc").append(": " + phantom.getRange()).withStyle(ChatFormatting.GOLD), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 40, ChatFormatting.WHITE.getColor());
|
|
||||||
if (phantom.hasBoundPosition()) {
|
|
||||||
int distance = Mth.ceil(new Vec3(pos.getX(), pos.getY(), pos.getZ()).distanceTo(new Vec3(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ())));
|
|
||||||
BlockState state = minecraft.level.getBlockState(phantom.getBoundPosition());
|
|
||||||
Block block = state.getBlock();
|
|
||||||
Item item = Item.byBlock(block);
|
|
||||||
String name = item.getName(new ItemStack(block)).getString();
|
|
||||||
drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 30, 200, 0xFFFFFF, true);
|
|
||||||
|
|
||||||
if (phantom.isBoundThingInRange()) {
|
|
||||||
drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true);
|
|
||||||
} else {
|
|
||||||
drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedNoRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.notConnected.desc").withStyle(ChatFormatting.RED), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, ChatFormatting.WHITE.getColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void drawWordWrap(GuiGraphics gg, Font font, FormattedText text, int x, int y, int width, int color, boolean shadow) {
|
|
||||||
for (FormattedCharSequence line : font.split(text, width)) {
|
|
||||||
gg.drawString(font, line, x, y, color, shadow);
|
|
||||||
y += font.lineHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
ITEMFACE,
|
ITEMFACE,
|
||||||
PLACER,
|
PLACER,
|
||||||
|
|
|
@ -10,28 +10,24 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.PlayerInterfaceHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay {
|
public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new PlayerInterfaceHud();
|
||||||
public BlockPlayerInterface() {
|
public BlockPlayerInterface() {
|
||||||
super(ActuallyBlocks.defaultPickProps(4.5F, 10.0F));
|
super(ActuallyBlocks.defaultPickProps(4.5F, 10.0F));
|
||||||
}
|
}
|
||||||
|
@ -64,26 +60,7 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
if (!(rayCast instanceof BlockHitResult)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
|
||||||
if (tile != null) {
|
|
||||||
if (tile instanceof TileEntityPlayerInterface face) {
|
|
||||||
String name = face.playerName == null
|
|
||||||
? "Unknown"
|
|
||||||
: face.playerName;
|
|
||||||
guiGraphics.drawString(minecraft.font, "Bound to: " + ChatFormatting.RED + name, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 5), 0xFFFFFF);
|
|
||||||
guiGraphics.drawString(minecraft.font, "UUID: " + ChatFormatting.DARK_GREEN + face.connectedPlayer, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 15), 0xFFFFFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @Override
|
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
|
||||||
return VoxelShapes.PLAYER_INTERFACE_SHAPE;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,27 +10,25 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.MinerHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class BlockVerticalDigger extends DirectionalBlock.Container implements IHudDisplay {
|
public class BlockVerticalDigger extends DirectionalBlock.Container implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new MinerHud();
|
||||||
|
|
||||||
public BlockVerticalDigger() {
|
public BlockVerticalDigger() {
|
||||||
super(ActuallyBlocks.defaultPickProps(8F, 30F));
|
super(ActuallyBlocks.defaultPickProps(8F, 30F));
|
||||||
|
@ -54,20 +52,8 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
if (!(rayCast instanceof BlockHitResult)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
|
||||||
if (tile instanceof TileEntityVerticalDigger miner) {
|
|
||||||
String info = miner.checkY == 0
|
|
||||||
? "Done Mining!"
|
|
||||||
: miner.checkY == -1
|
|
||||||
? "Calculating positions..."
|
|
||||||
: "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + ".";
|
|
||||||
guiGraphics.drawString(minecraft.font, info, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f - 20), 0xFFFFFF);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override
|
/* @Override
|
||||||
|
|
|
@ -10,16 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
public interface IHudDisplay {
|
public interface IHudDisplay {
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution);
|
IBlockHud getHud();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LevelReader;
|
import net.minecraft.world.level.LevelReader;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.EntityBlock;
|
import net.minecraft.world.level.block.EntityBlock;
|
||||||
import net.minecraft.world.level.block.RenderShape;
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
@ -194,11 +195,10 @@ public abstract class BlockContainerBase extends Block implements EntityBlock {
|
||||||
@Override
|
@Override
|
||||||
public BlockState playerWillDestroy(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState state, Player player) {
|
public BlockState playerWillDestroy(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull BlockState state, Player player) {
|
||||||
BlockState theState = super.playerWillDestroy(world, pos, state, player);
|
BlockState theState = super.playerWillDestroy(world, pos, state, player);
|
||||||
if (!player.isCreative()) {
|
if (!player.isCreative() && world.getBlockEntity(pos) instanceof TileEntityBase tileBase && tileBase.stopFromDropping) {
|
||||||
BlockEntity tile = world.getBlockEntity(pos);
|
if (!world.isClientSide)
|
||||||
if (tile instanceof TileEntityBase && ((TileEntityBase) tile).stopFromDropping) {
|
|
||||||
player.displayClientMessage(Component.translatable("info.actuallyadditions.machineBroke").withStyle(ChatFormatting.RED), false);
|
player.displayClientMessage(Component.translatable("info.actuallyadditions.machineBroke").withStyle(ChatFormatting.RED), false);
|
||||||
}
|
return Blocks.AIR.defaultBlockState();
|
||||||
}
|
}
|
||||||
return theState;
|
return theState;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package de.ellpeck.actuallyadditions.mod.blocks.blockhuds;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
public interface IBlockHud {
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution);
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package de.ellpeck.actuallyadditions.mod.blocks.blockhuds;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
public class LaserRelayHud implements IBlockHud {
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||||
|
if (!(rayCast instanceof BlockHitResult)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockPos pos = ((BlockHitResult) rayCast).getBlockPos();
|
||||||
|
if (minecraft.level != null) {
|
||||||
|
boolean wearing = ItemEngineerGoggles.isWearing(player);
|
||||||
|
if (wearing || !stack.isEmpty()) {
|
||||||
|
boolean compass = stack.getItem() == CommonConfig.Other.relayConfigureItem;
|
||||||
|
if (wearing || compass || stack.getItem() instanceof ItemLaserWrench) {
|
||||||
|
BlockEntity tile = minecraft.level.getBlockEntity(pos);
|
||||||
|
if (tile instanceof TileEntityLaserRelay relay) {
|
||||||
|
|
||||||
|
Component strg = relay.getExtraDisplayString();
|
||||||
|
guiGraphics.drawString(minecraft.font, strg, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 5), 0xFFFFFF);
|
||||||
|
|
||||||
|
Component expl;
|
||||||
|
if (compass) {
|
||||||
|
expl = relay.getCompassDisplayString();
|
||||||
|
} else {
|
||||||
|
expl = Component.translatable("info.actuallyadditions.laserRelay.mode.noCompasss", Component.translatable(CommonConfig.Other.relayConfigureItem.getDescriptionId()).getString()).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
guiGraphics.drawString(minecraft.font, expl, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 15), 0xFFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package de.ellpeck.actuallyadditions.mod.blocks.blockhuds;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
public class LavaFactoryControllerHud implements IBlockHud {
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||||
|
if (!(rayCast instanceof BlockHitResult)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController) minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
||||||
|
if (factory != null) {
|
||||||
|
int state = factory.isMultiblock();
|
||||||
|
if (state == TileEntityLavaFactoryController.NOT_MULTI) {
|
||||||
|
guiGraphics.drawWordWrap(minecraft.font, Component.translatable("tooltip.actuallyadditions.factory.notPart.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 5, 200, 0xFFFFFF);
|
||||||
|
} else if (state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA) {
|
||||||
|
guiGraphics.drawWordWrap(minecraft.font, Component.translatable("tooltip.actuallyadditions.factory.working.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 5, 200, 0xFFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package de.ellpeck.actuallyadditions.mod.blocks.blockhuds;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
public class MinerHud implements IBlockHud {
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||||
|
if (!(rayCast instanceof BlockHitResult)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
||||||
|
if (tile instanceof TileEntityVerticalDigger miner) {
|
||||||
|
String info = miner.checkY == 0
|
||||||
|
? "Done Mining!"
|
||||||
|
: miner.checkY == -1
|
||||||
|
? "Calculating positions..."
|
||||||
|
: "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + ".";
|
||||||
|
guiGraphics.drawString(minecraft.font, info, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f - 20), 0xFFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package de.ellpeck.actuallyadditions.mod.blocks.blockhuds;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.FormattedText;
|
||||||
|
import net.minecraft.util.FormattedCharSequence;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
public class PhantomHud implements IBlockHud {
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||||
|
if (!(rayCast instanceof BlockHitResult)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BlockPos pos = ((BlockHitResult) rayCast).getBlockPos();
|
||||||
|
BlockEntity tile = minecraft.level.getBlockEntity(pos);
|
||||||
|
if (tile != null) {
|
||||||
|
if (tile instanceof IPhantomTile phantom) {
|
||||||
|
guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.blockPhantomRange.desc").append(": " + phantom.getRange()).withStyle(ChatFormatting.GOLD), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 40, ChatFormatting.WHITE.getColor());
|
||||||
|
if (phantom.hasBoundPosition()) {
|
||||||
|
int distance = Mth.ceil(new Vec3(pos.getX(), pos.getY(), pos.getZ()).distanceTo(new Vec3(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ())));
|
||||||
|
BlockState state = minecraft.level.getBlockState(phantom.getBoundPosition());
|
||||||
|
Block block = state.getBlock();
|
||||||
|
Item item = Item.byBlock(block);
|
||||||
|
String name = item.getName(new ItemStack(block)).getString();
|
||||||
|
drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 30, 200, 0xFFFFFF, true);
|
||||||
|
|
||||||
|
if (phantom.isBoundThingInRange()) {
|
||||||
|
drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true);
|
||||||
|
} else {
|
||||||
|
drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedNoRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.notConnected.desc").withStyle(ChatFormatting.RED), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, ChatFormatting.WHITE.getColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static void drawWordWrap(GuiGraphics gg, Font font, FormattedText text, int x, int y, int width, int color, boolean shadow) {
|
||||||
|
for (FormattedCharSequence line : font.split(text, width)) {
|
||||||
|
gg.drawString(font, line, x, y, color, shadow);
|
||||||
|
y += font.lineHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package de.ellpeck.actuallyadditions.mod.blocks.blockhuds;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
public class PlayerInterfaceHud implements IBlockHud {
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||||
|
if (!(rayCast instanceof BlockHitResult)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
||||||
|
if (tile != null) {
|
||||||
|
if (tile instanceof TileEntityPlayerInterface face) {
|
||||||
|
String name = face.playerName == null
|
||||||
|
? "Unknown"
|
||||||
|
: face.playerName;
|
||||||
|
guiGraphics.drawString(minecraft.font, "Bound to: " + ChatFormatting.RED + name, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 5), 0xFFFFFF);
|
||||||
|
guiGraphics.drawString(minecraft.font, "UUID: " + ChatFormatting.DARK_GREEN + face.connectedPlayer, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 15), 0xFFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package de.ellpeck.actuallyadditions.mod.blocks.blockhuds;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
public class ReconstructorHud implements IBlockHud {
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||||
|
if (!(rayCast instanceof BlockHitResult) || minecraft.level == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos());
|
||||||
|
if (tile instanceof TileEntityAtomicReconstructor) {
|
||||||
|
ItemStack slot = ((TileEntityAtomicReconstructor) tile).inv.getStackInSlot(0);
|
||||||
|
Component lens_name;
|
||||||
|
if (slot.isEmpty()) {
|
||||||
|
lens_name = Component.translatable("info.actuallyadditions.nolens");
|
||||||
|
} else {
|
||||||
|
lens_name = slot.getItem().getName(slot);
|
||||||
|
|
||||||
|
AssetUtil.renderStackToGui(slot, resolution.getGuiScaledWidth() / 2 + 15, resolution.getGuiScaledHeight() / 2 - 19, 1F);
|
||||||
|
}
|
||||||
|
guiGraphics.drawString(minecraft.font, lens_name.plainCopy().withStyle(ChatFormatting.YELLOW).withStyle(ChatFormatting.ITALIC).getString(), (int) (resolution.getGuiScaledWidth() / 2.0f + 35), (int) (resolution.getGuiScaledHeight() / 2.0f - 15), 0xFFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ public class RenderTypes extends RenderType {
|
||||||
.setOutputState(MAIN_TARGET)
|
.setOutputState(MAIN_TARGET)
|
||||||
.setLightmapState(RenderStateShard.LIGHTMAP)
|
.setLightmapState(RenderStateShard.LIGHTMAP)
|
||||||
.setCullState(RenderStateShard.NO_CULL)
|
.setCullState(RenderStateShard.NO_CULL)
|
||||||
.setShaderState(RenderStateShard.POSITION_COLOR_TEX_LIGHTMAP_SHADER)
|
.setShaderState(RenderStateShard.POSITION_COLOR_SHADER)
|
||||||
.createCompositeState(true));
|
.createCompositeState(true));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ public class ClientEvents {
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
if (stack.getItem() instanceof IHudDisplay) {
|
if (stack.getItem() instanceof IHudDisplay) {
|
||||||
((IHudDisplay) stack.getItem()).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow());
|
((IHudDisplay) stack.getItem()).getHud().displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ public class ClientEvents {
|
||||||
BlockEntity tileHit = minecraft.level.getBlockEntity(rayCast.getBlockPos());
|
BlockEntity tileHit = minecraft.level.getBlockEntity(rayCast.getBlockPos());
|
||||||
|
|
||||||
if (blockHit instanceof IHudDisplay) {
|
if (blockHit instanceof IHudDisplay) {
|
||||||
((IHudDisplay) blockHit).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow());
|
((IHudDisplay) blockHit).getHud().displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tileHit instanceof TileEntityBase base) {
|
if (tileHit instanceof TileEntityBase base) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Tiers;
|
import net.minecraft.world.item.Tiers;
|
||||||
import net.minecraft.world.item.component.ItemAttributeModifiers;
|
import net.minecraft.world.item.component.ItemAttributeModifiers;
|
||||||
import net.minecraft.world.item.component.ItemContainerContents;
|
import net.minecraft.world.item.component.ItemContainerContents;
|
||||||
|
import net.minecraft.world.item.component.Unbreakable;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.item.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -68,7 +69,6 @@ public class DrillItem extends ItemEnergy {
|
||||||
|
|
||||||
public DrillItem() {
|
public DrillItem() {
|
||||||
super(ActuallyItems.defaultProps()
|
super(ActuallyItems.defaultProps()
|
||||||
.durability(0)
|
|
||||||
.stacksTo(1)
|
.stacksTo(1)
|
||||||
.component(DataComponents.TOOL, Tiers.NETHERITE.createToolProperties(ActuallyTags.Blocks.MINEABLE_WITH_DRILL))
|
.component(DataComponents.TOOL, Tiers.NETHERITE.createToolProperties(ActuallyTags.Blocks.MINEABLE_WITH_DRILL))
|
||||||
, 250000, 1000);
|
, 250000, 1000);
|
||||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.advancements.AdvancementHolder;
|
import net.minecraft.advancements.AdvancementHolder;
|
||||||
|
@ -32,10 +31,12 @@ import net.minecraft.world.item.TooltipFlag;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemBooklet extends ItemBase implements IHudDisplay {
|
public class ItemBooklet extends ItemBase {
|
||||||
|
|
||||||
|
|
||||||
public static IBookletPage forcedPage;
|
public static IBookletPage forcedPage;
|
||||||
|
@ -99,8 +100,7 @@ public class ItemBooklet extends ItemBase implements IHudDisplay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||||
// if (rayCast != null && rayCast.getBlockPos() != null) {
|
// if (rayCast != null && rayCast.getBlockPos() != null) {
|
||||||
// BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
|
// BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
|
||||||
|
|
|
@ -31,7 +31,6 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public abstract class ItemEnergy extends ItemBase {
|
public abstract class ItemEnergy extends ItemBase {
|
||||||
|
|
||||||
public final int maxPower;
|
public final int maxPower;
|
||||||
public final int transfer;
|
public final int transfer;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class ParticleBeam extends Particle {
|
||||||
RenderSystem.disableCull();
|
RenderSystem.disableCull();
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
|
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
|
||||||
return tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE);
|
return tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,7 +100,7 @@ public class ParticleBeam extends Particle {
|
||||||
|
|
||||||
public static ParticleOptions createData(double endX, double endY, double endZ, int color, float alpha,
|
public static ParticleOptions createData(double endX, double endY, double endZ, int color, float alpha,
|
||||||
int maxAge, double rotationTime, float size) {
|
int maxAge, double rotationTime, float size) {
|
||||||
return new BeamParticleData(endX, endY, endZ, color, maxAge, rotationTime, size);
|
return new BeamParticleData(endX, endY, endZ, FastColor.ARGB32.color((int)(alpha * 255F), color), maxAge, rotationTime, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -234,9 +233,9 @@ public final class AssetUtil {
|
||||||
int g = (color >> 8) & 0xFF;
|
int g = (color >> 8) & 0xFF;
|
||||||
int b = color & 0xFF;
|
int b = color & 0xFF;
|
||||||
int a = (int) (alpha * 255);*/
|
int a = (int) (alpha * 255);*/
|
||||||
int r = (int)(((color >> 16) & 0xFF) * alpha);
|
int r = (int)(((color >> 16) & 0xFF) * alpha * 0.4F);
|
||||||
int g = (int)(((color >> 8) & 0xFF) * alpha);
|
int g = (int)(((color >> 8) & 0xFF) * alpha * 0.4F);
|
||||||
int b = (int)((color & 0xFF) * alpha);
|
int b = (int)((color & 0xFF) * alpha * 0.4F);
|
||||||
int a = 255;
|
int a = 255;
|
||||||
|
|
||||||
int lightmap = LightTexture.pack(MAX_LIGHT_X, MAX_LIGHT_Y);
|
int lightmap = LightTexture.pack(MAX_LIGHT_X, MAX_LIGHT_Y);
|
||||||
|
@ -254,35 +253,29 @@ public final class AssetUtil {
|
||||||
|
|
||||||
Matrix4f matrix = matrixStack.last().pose();
|
Matrix4f matrix = matrixStack.last().pose();
|
||||||
|
|
||||||
TextureAtlasSprite sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(FORGE_WHITE);
|
|
||||||
float minU = sprite.getU0();
|
|
||||||
float maxU = sprite.getU1();
|
|
||||||
float minV = sprite.getV0();
|
|
||||||
float maxV = sprite.getV1();
|
|
||||||
|
|
||||||
//Draw laser tube faces
|
//Draw laser tube faces
|
||||||
for (int i = 1; i < 4; i++) {
|
for (int i = 1; i < 4; i++) {
|
||||||
float width = beamWidth * (i / 4.0f);
|
float width = beamWidth * (i / 4.0f);
|
||||||
//top
|
//top
|
||||||
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap);
|
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setLight(lightmap);
|
||||||
//bottom
|
//bottom
|
||||||
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap);
|
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setLight(lightmap);
|
||||||
//left
|
//left
|
||||||
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setLight(lightmap);
|
||||||
//right
|
//right
|
||||||
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setLight(lightmap);
|
||||||
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setLight(lightmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,37 +327,31 @@ public final class AssetUtil {
|
||||||
|
|
||||||
Matrix4f matrix = matrixStack.last().pose();
|
Matrix4f matrix = matrixStack.last().pose();
|
||||||
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorLightmapShader);
|
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||||
|
|
||||||
TextureAtlasSprite sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(FORGE_WHITE);
|
|
||||||
float minU = sprite.getU0();
|
|
||||||
float maxU = sprite.getU1();
|
|
||||||
float minV = sprite.getV0();
|
|
||||||
float maxV = sprite.getV1();
|
|
||||||
|
|
||||||
//Draw laser tube faces
|
//Draw laser tube faces
|
||||||
for (int i = 1; i < 4; i++) {
|
for (int i = 1; i < 4; i++) {
|
||||||
float width = beamWidth * (i / 4.0f);
|
float width = beamWidth * (i / 4.0f);
|
||||||
//top
|
//top
|
||||||
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap);
|
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a);
|
||||||
//bottom
|
//bottom
|
||||||
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap);
|
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a);
|
||||||
//left
|
//left
|
||||||
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a);
|
||||||
//right
|
//right
|
||||||
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
|
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a);
|
||||||
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
|
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a);
|
||||||
|
|
||||||
}
|
}
|
||||||
matrixStack.popPose();
|
matrixStack.popPose();
|
||||||
|
|
Loading…
Reference in a new issue