Working sorta
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,6 +23,7 @@ build
|
||||
# other
|
||||
eclipse
|
||||
run
|
||||
runclient
|
||||
logs
|
||||
/assets/
|
||||
|
||||
|
||||
@@ -38,46 +38,51 @@ public final class BusCableBakedModel implements IDynamicBakedModel {
|
||||
private static final ModelProperty<BusCableSupportSide> BUS_CABLE_SUPPORT_PROPERTY = new ModelProperty<>();
|
||||
private static final ModelProperty<BusCableFacade> BUS_CABLE_FACADE_PROPERTY = new ModelProperty<>();
|
||||
private final BakedModel proxy;
|
||||
private final BakedModel[] straightModelByAxis;
|
||||
private final BakedModel[] supportModelByFace;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
BusCableBakedModel(final BakedModel proxy) {
|
||||
BusCableBakedModel(BakedModel proxy, BakedModel[] straightModelByAxis, BakedModel[] supportModelByFace) {
|
||||
this.proxy = proxy;
|
||||
this.straightModelByAxis = straightModelByAxis;
|
||||
this.supportModelByFace = supportModelByFace;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public List<BakedQuad> getQuads(@Nullable final BlockState state, @Nullable final Direction side, final RandomSource rand, final ModelData extraData, @Nullable RenderType renderType) {
|
||||
final RenderType layer = RenderType.solid();
|
||||
|
||||
final BusCableFacade facade = extraData.get(BUS_CABLE_FACADE_PROPERTY);
|
||||
if (side != null) {
|
||||
if (facade != null && (renderType != null && renderType.equals(RenderType.solid()))) {
|
||||
return facade.model.getQuads(state, side, rand, facade.data, renderType);
|
||||
if (extraData.has(BUS_CABLE_FACADE_PROPERTY)) {
|
||||
final BusCableFacade facade = extraData.get(BUS_CABLE_FACADE_PROPERTY);
|
||||
if (facade != null && (layer == null)) {
|
||||
return facade.model.getQuads(facade.blockState, side, rand, facade.data, RenderType.solid());
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else {
|
||||
if (state == null || !state.getValue(BusCableBlock.HAS_CABLE) || renderType == null || !renderType.equals(RenderType.solid())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
for (int i = 0; i < Constants.AXES.length; i++) {
|
||||
final Direction.Axis axis = Constants.AXES[i];
|
||||
if (isStraightAlongAxis(state, axis)) {
|
||||
return proxy.getQuads(state, side, rand, extraData, renderType);
|
||||
}
|
||||
}
|
||||
|
||||
final ArrayList<BakedQuad> quads = new ArrayList<>(proxy.getQuads(state, side, rand, extraData, renderType));
|
||||
|
||||
final BusCableSupportSide supportSide = extraData.get(BUS_CABLE_SUPPORT_PROPERTY);
|
||||
if (supportSide != null) {
|
||||
quads.addAll(proxy.getQuads(state, side, rand, extraData, renderType));
|
||||
}
|
||||
|
||||
return quads;
|
||||
}
|
||||
|
||||
if (state == null || !state.getValue(BusCableBlock.HAS_CABLE) || layer == null || !layer.equals(RenderType.solid())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
for (int i = 0; i < Constants.AXES.length; i++) {
|
||||
final Direction.Axis axis = Constants.AXES[i];
|
||||
if (isStraightAlongAxis(state, axis)) {
|
||||
return straightModelByAxis[i].getQuads(state, side, rand, extraData, RenderType.solid());
|
||||
}
|
||||
}
|
||||
|
||||
final ArrayList<BakedQuad> quads = new ArrayList<>(proxy.getQuads(state, side, rand, extraData, RenderType.solid()));
|
||||
|
||||
final BusCableSupportSide supportSide = extraData.get(BUS_CABLE_SUPPORT_PROPERTY);
|
||||
if (supportSide != null) {
|
||||
quads.addAll(supportModelByFace[supportSide.value.get3DDataValue()].getQuads(state, side, rand, extraData, RenderType.solid()));
|
||||
}
|
||||
|
||||
return quads;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,22 @@ public final class BusCableModel implements IUnbakedGeometry<BusCableModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel bake(final IGeometryBakingContext owner, final ModelBakery bakery, final Function<Material, TextureAtlasSprite> spriteGetter, final ModelState modelTransform, final ItemOverrides overrides, final ResourceLocation modelLocation) {
|
||||
return new BusCableBakedModel(proxy.bake(owner, bakery, spriteGetter, modelTransform, overrides, modelLocation));
|
||||
final BakedModel bakedBaseModel = proxy.bake(owner, bakery, spriteGetter, modelTransform, overrides, modelLocation);
|
||||
final BakedModel[] straightModelByAxis = {
|
||||
requireNonNull(bakery.bake(BUS_CABLE_STRAIGHT_MODEL, BlockModelRotation.X0_Y90, spriteGetter)),
|
||||
requireNonNull(bakery.bake(BUS_CABLE_STRAIGHT_MODEL, BlockModelRotation.X90_Y0, spriteGetter)),
|
||||
requireNonNull(bakery.bake(BUS_CABLE_STRAIGHT_MODEL, modelTransform, spriteGetter))
|
||||
};
|
||||
final BakedModel[] supportModelByFace = {
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X270_Y0, spriteGetter)), // -y
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X90_Y0, spriteGetter)), // +y
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y180, spriteGetter)), // -z
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, modelTransform, spriteGetter)), // +z
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y90, spriteGetter)), // -x
|
||||
requireNonNull(bakery.bake(BUS_CABLE_SUPPORT_MODEL, BlockModelRotation.X0_Y270, spriteGetter)) // +x
|
||||
};
|
||||
|
||||
return new BusCableBakedModel(proxy.bake(owner, bakery, spriteGetter, modelTransform, overrides, modelLocation), straightModelByAxis, supportModelByFace);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,6 @@ import li.cil.oc2.common.bus.device.data.FirmwareRegistry;
|
||||
import li.cil.oc2.common.bus.device.provider.ProviderRegistry;
|
||||
import li.cil.oc2.common.container.Containers;
|
||||
import li.cil.oc2.common.entity.Entities;
|
||||
import li.cil.oc2.common.item.ItemRenameHandler;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
import li.cil.oc2.common.item.crafting.RecipeSerializers;
|
||||
import li.cil.oc2.common.serialization.ceres.Serializers;
|
||||
@@ -26,11 +25,9 @@ import li.cil.oc2.common.util.SoundEvents;
|
||||
import li.cil.oc2.common.vm.provider.DeviceTreeProviders;
|
||||
import li.cil.sedna.Sedna;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.NewRegistryEvent;
|
||||
|
||||
@Mod(API.MOD_ID)
|
||||
public final class Main {
|
||||
@@ -63,8 +60,8 @@ public final class Main {
|
||||
|
||||
RegistryUtils.finish();
|
||||
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> Manuals::initialize);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(CommonSetup.class);
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> Manuals::initialize);
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(ClientSetup.class));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
@@ -34,6 +35,7 @@ import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -42,7 +44,6 @@ import static li.cil.oc2.common.util.NBTUtils.makeInventoryTag;
|
||||
import static li.cil.oc2.common.util.RegistryUtils.key;
|
||||
|
||||
public final class RobotItem extends ModItem {
|
||||
|
||||
@Override
|
||||
public void appendHoverText(final ItemStack stack, @Nullable final Level level, final List<Component> tooltip, final TooltipFlag flag) {
|
||||
super.appendHoverText(stack, level, tooltip, flag);
|
||||
@@ -110,6 +111,16 @@ public final class RobotItem extends ModItem {
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void initializeClient(final Consumer<IClientItemExtensions> consumer) {
|
||||
consumer.accept(new IClientItemExtensions() {
|
||||
@Override
|
||||
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
|
||||
return new RobotWithoutLevelRenderer(Minecraft.getInstance().getBlockEntityRenderDispatcher(), Minecraft.getInstance().getEntityModels());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ItemStack getRobotWithFlash() {
|
||||
final ItemStack robot = new ItemStack(this);
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ public abstract class AbstractVirtualMachine implements VirtualMachine {
|
||||
handleRunStateChanged(value);
|
||||
}
|
||||
|
||||
private void setBootError(@Nullable final Component value) {
|
||||
private void setBootError(final Component value) {
|
||||
bootError = value;
|
||||
handleBootErrorChanged(value);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -661,6 +662,7 @@ public final class Terminal {
|
||||
final int clearCount = Math.abs(count * WIDTH);
|
||||
Arrays.fill(buffer, clearIndex, clearIndex + clearCount, (byte) ' ');
|
||||
// TODO Copy color and style from last line.
|
||||
// TODO Copy color and style from last line.
|
||||
Arrays.fill(colors, clearIndex, clearIndex + clearCount, DEFAULT_COLORS);
|
||||
Arrays.fill(styles, clearIndex, clearIndex + clearCount, DEFAULT_STYLE);
|
||||
|
||||
@@ -755,19 +757,36 @@ public final class Terminal {
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
private int findLineIndex(VertexBuffer[] vba, VertexBuffer vb) {
|
||||
int i = 0;
|
||||
while (i < vba.length) {
|
||||
if (vba[i] == vb) {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void renderBuffer(final PoseStack stack, final Matrix4f projectionMatrix) {
|
||||
final ShaderInstance shader = GameRenderer.getPositionColorTexShader();
|
||||
if (shader == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.setShaderTexture(0, LOCATION_FONT_TEXTURE);
|
||||
|
||||
for (final VertexBuffer line : lines) {
|
||||
try {
|
||||
line.drawWithShader(stack.last().pose(), projectionMatrix, shader);
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR: " + e.getMessage());
|
||||
if (!line.isInvalid()) {
|
||||
try {
|
||||
line.bind();
|
||||
line.drawWithShader(stack.last().pose(), projectionMatrix, shader);
|
||||
VertexBuffer.unbind();
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR: " + e.getMessage());
|
||||
System.out.println(findLineIndex(lines, line));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,17 +811,22 @@ public final class Terminal {
|
||||
|
||||
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
|
||||
|
||||
renderBackground(matrix, builder, row);
|
||||
renderForeground(matrix, builder, row);
|
||||
renderBackground(matrix, builder, row);
|
||||
|
||||
BufferBuilder.RenderedBuffer rb = builder.end();
|
||||
|
||||
if (lines[row] == null) {
|
||||
lines[row] = new VertexBuffer();
|
||||
}else if (lines[row] != null) {
|
||||
lines[row].close();
|
||||
lines[row] = new VertexBuffer();
|
||||
}
|
||||
|
||||
if (!lines[row].isInvalid() && !rb.isEmpty()) {
|
||||
if (!lines[row].isInvalid()){
|
||||
lines[row].bind();
|
||||
lines[row].upload(rb);
|
||||
VertexBuffer.unbind();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -942,7 +966,7 @@ public final class Terminal {
|
||||
buffer.vertex(matrix, 0, 0, 0).color(r, g, b, 1).endVertex();
|
||||
|
||||
BufferBuilder.RenderedBuffer rb = buffer.end();
|
||||
BufferUploader.draw(rb);
|
||||
BufferUploader.drawWithShader(rb);
|
||||
|
||||
stack.popPose();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user