Skip to content

Commit

Permalink
1.20.1-release
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticpasta1 committed Jan 2, 2024
1 parent c493383 commit 9d461dc
Show file tree
Hide file tree
Showing 20 changed files with 326 additions and 68 deletions.
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ repositories {
}
}

loom {
accessWidenerPath = file("src/main/resources/holographic_renders.accesswidener")
}

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
name = "CottonMC"
url = "https://server.bbkr.space/artifactory/libs-release"
}
maven { url "https://maven.wispforest.io" }
maven { url = "https://s01.oss.sonatype.org/content/repositories/snapshots" }
}

dependencies {
Expand All @@ -34,8 +38,8 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "io.wispforest:worldmesher:${project.worldmesher_version}"
include "io.wispforest:worldmesher:${project.worldmesher_version}"
modImplementation "com.github.Mysticpasta1:worldmesher:${project.worldmesher_version}"
include "com.github.Mysticpasta1:worldmesher:${project.worldmesher_version}"

modImplementation include("io.github.cottonmc:LibGui:8.1.0+1.20.1")

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ org.gradle.daemon=false

minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.3
loader_version=0.15.0

#Fabric api
fabric_version=0.91.0+1.20.1
worldmesher_version=0.4.3+1.20
worldmesher_version=133ea00c0

# Mod Properties
mod_version = 1.0.0
Expand Down
Binary file removed libs/worldmesher-0.1-dev.jar
Binary file not shown.
Binary file removed libs/worldmesher-0.1-sources-dev.jar
Binary file not shown.
Binary file removed libs/worldmesher-0.1-sources.jar
Binary file not shown.
Binary file removed libs/worldmesher-0.1.jar
Binary file not shown.
58 changes: 31 additions & 27 deletions src/main/java/com/mystic/holographicrenders/HolographicRenders.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
package com.mystic.holographicrenders;

import com.mystic.holographicrenders.blocks.projector.ItemProjectionHandler;
import com.mystic.holographicrenders.blocks.projector.ProjectorBlock;
import com.mystic.holographicrenders.blocks.projector.ProjectorBlockEntity;
import com.mystic.holographicrenders.client.TextboxScreenRoot;
import com.mystic.holographicrenders.gui.ProjectorScreenHandler;
import com.mystic.holographicrenders.item.AreaScannerItem;
import com.mystic.holographicrenders.item.EntityScannerItem;
import com.mystic.holographicrenders.item.TextureScannerItem;
import com.mystic.holographicrenders.item.WidgetScannerItem;
import com.mystic.holographicrenders.item.WidgetType;
import com.mystic.holographicrenders.network.ProjectorScreenPacket;
import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.impl.LibGuiCommon;
import io.github.cottonmc.cotton.gui.impl.client.ItemUseChecker;
import io.github.cottonmc.cotton.gui.impl.client.LibGuiClient;
import io.netty.buffer.ByteBufUtil;

import com.mystic.holographicrenders.item.*;
import com.mystic.holographicrenders.network.LightPacket;
import com.mystic.holographicrenders.network.RotatePacket;
import com.mystic.holographicrenders.network.SpinPacket;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.fabricmc.fabric.impl.itemgroup.FabricItemGroup;
import net.fabricmc.fabric.impl.itemgroup.FabricItemGroupBuilderImpl;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.inventory.StackReference;
import net.minecraft.item.*;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.screen.ScreenHandlerType;
Expand Down Expand Up @@ -70,13 +55,8 @@ public static ItemConvertible addToMainTab (ItemConvertible itemLike) {
public static final BlockEntityType<ProjectorBlockEntity> PROJECTOR_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(ProjectorBlockEntity::new, PROJECTOR_BLOCK).build(null);

public static final Identifier PROJECTOR_ID = new Identifier(MOD_ID, "projector");
public static final Identifier TEXTBOX_ID = new Identifier(MOD_ID, "textbox");
public static final ScreenHandlerType<ProjectorScreenHandler> PROJECTOR_SCREEN_HANDLER;

static {
PROJECTOR_SCREEN_HANDLER = ScreenHandlerRegistry.registerExtended(new Identifier(MOD_ID, "projector_screen"), ProjectorScreenHandler::new);
}

public static final ScreenHandlerType<ProjectorScreenHandler> PROJECTOR_SCREEN_HANDLER = Registry.register(Registries.SCREEN_HANDLER, new Identifier(MOD_ID, "projector_screen"), new ExtendedScreenHandlerType<>(ProjectorScreenHandler::new));

@Override
public void onInitialize() {
Properties props = System.getProperties();
Expand All @@ -99,7 +79,9 @@ public void onInitialize() {

Registry.register(Registries.ITEM_GROUP, new Identifier(MOD_ID, "group"), owo);

ServerPlayNetworking.registerGlobalReceiver(ProjectorScreenPacket.ACTION_REQUEST_ID, ProjectorScreenPacket::onActionRequest);
ServerPlayNetworking.registerGlobalReceiver(LightPacket.ACTION_REQUEST_ID, LightPacket::onActionRequest);
ServerPlayNetworking.registerGlobalReceiver(SpinPacket.ACTION_REQUEST_ID, SpinPacket::onActionRequest);
ServerPlayNetworking.registerGlobalReceiver(RotatePacket.ACTION_REQUEST_ID, RotatePacket::onActionRequest);
ServerPlayNetworking.registerGlobalReceiver(new Identifier(HolographicRenders.MOD_ID, "url_packet"), (server, player, handler, buf, responseSender) -> {
String url = buf.readString();
ItemStack stack = player.getStackInHand(buf.readEnumConstant(Hand.class));
Expand Down Expand Up @@ -136,5 +118,27 @@ public void onInitialize() {
}
});
});

ServerPlayNetworking.registerGlobalReceiver(new Identifier(HolographicRenders.MOD_ID, "spin_packet"), (server, player, handler, buf, responseSender) -> {
BlockPos pos = buf.readBlockPos();
boolean spin = buf.readBoolean();
server.execute(() -> {
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if(blockEntity instanceof ProjectorBlockEntity){
((ProjectorBlockEntity) blockEntity).setSpinEnabled(spin);
}
});
});

ServerPlayNetworking.registerGlobalReceiver(new Identifier(HolographicRenders.MOD_ID, "rotate_packet"), (server, player, handler, buf, responseSender) -> {
BlockPos pos = buf.readBlockPos();
int rotation = buf.readInt();
server.execute(() -> {
BlockEntity blockEntity = player.getWorld().getBlockEntity(pos);
if(blockEntity instanceof ProjectorBlockEntity){
((ProjectorBlockEntity) blockEntity).setRotation(rotation);
}
});
});
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.mystic.holographicrenders.blocks.projector;

import com.mystic.holographicrenders.network.ProjectorScreenPacket;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import com.mystic.holographicrenders.network.LightPacket;
import com.mystic.holographicrenders.network.RotatePacket;
import com.mystic.holographicrenders.network.SpinPacket;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
Expand Down Expand Up @@ -160,7 +160,9 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt

if (screenHandlerFactory != null) {
player.openHandledScreen(screenHandlerFactory);
((ServerPlayerEntity) player).networkHandler.sendPacket(ProjectorScreenPacket.createUpdate(be.lightsEnabled()));
((ServerPlayerEntity) player).networkHandler.sendPacket(LightPacket.createUpdate(be.lightsEnabled()));
((ServerPlayerEntity) player).networkHandler.sendPacket(SpinPacket.createUpdate(be.spinEnabled()));
((ServerPlayerEntity) player).networkHandler.sendPacket(RotatePacket.createUpdate(be.getRotation()));
}

return ActionResult.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public class ProjectorBlockEntity extends BlockEntity implements ExtendedScreenH
private final DefaultedList<ItemStack> inventory = DefaultedList.ofSize(1, ItemStack.EMPTY);
private float alpha = 1;
private boolean lightEnabled = true;
private boolean spinEnabled = true;
private RenderDataProvider<?> renderer = EmptyProvider.INSTANCE;
private int rotation;


public @NotNull RenderDataProvider<?> getRenderer() {
Expand Down Expand Up @@ -66,15 +68,32 @@ public void setLightEnabled(boolean shouldDrawLights) {
this.markDirty();
}

public void setRotation(int rotation) {
this.rotation = rotation;
this.markDirty();
}

public void setSpinEnabled(boolean shouldSpin) {
this.spinEnabled = shouldSpin;
this.markDirty();
}

public boolean lightsEnabled() {
return lightEnabled;
}

public int getRotation() {return rotation;}
public boolean spinEnabled() {
return spinEnabled;
}

@Override
public void readNbt(NbtCompound tag) {
super.readNbt(tag);
alpha = tag.getFloat("Alpha");
lightEnabled = tag.getBoolean("Lights");
spinEnabled = tag.getBoolean("Spin");
rotation = tag.getInt("Rotate");
Identifier providerId = Identifier.tryParse(tag.getString("RendererType"));
renderer = providerId == null ? EmptyProvider.INSTANCE : RenderDataProviderRegistry.getProvider(renderer, providerId);
renderer.fromTag(tag, this);
Expand All @@ -85,6 +104,8 @@ public void readNbt(NbtCompound tag) {
public void writeNbt(NbtCompound tag) {
tag.putFloat("Alpha", alpha);
tag.putBoolean("Lights", lightEnabled);
tag.putBoolean("Spin", spinEnabled);
tag.putInt("Rotate", rotation);
tag.put("Stack", getItem().writeNbt(new NbtCompound()));
renderer.toTag(tag, this);
super.writeNbt(tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.fabricmc.api.Environment;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
Expand All @@ -21,6 +21,8 @@
import net.minecraft.util.math.RotationAxis;
import org.apache.commons.lang3.tuple.Pair;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

Expand All @@ -38,21 +40,28 @@ public com.mystic.holographicrenders.client.AreaProvider load(Pair<BlockPos, Blo
public static final Identifier ID = new Identifier(HolographicRenders.MOD_ID, "area");

private final MinecraftClient client;
private final WorldMesherFluidRenderer worldMesherFluidRenderer;
private long lastUpdateTick;
private WorldMesh mesh;
private static ProjectorBlockEntity entity;

protected AreaProvider(Pair<BlockPos, BlockPos> data) {
super(data);
this.client = MinecraftClient.getInstance();
//TODO fix this argh
this.lastUpdateTick = this.client.world.getTime();
this.worldMesherFluidRenderer = new WorldMesherFluidRenderer();
invalidateCache();
}

public static com.mystic.holographicrenders.client.AreaProvider from(BlockPos start, BlockPos end) throws ExecutionException {
return cache.get(Pair.of(start, end));
}

public static void setEntity(ProjectorBlockEntity entity) {
AreaProvider.entity = entity;
}

@Override
@Environment(EnvType.CLIENT)
public void render(MatrixStack matrices, VertexConsumerProvider.Immediate immediate, float tickDelta, int light, int overlay, BlockEntity be) {
Expand All @@ -69,15 +78,24 @@ public void render(MatrixStack matrices, VertexConsumerProvider.Immediate immedi
matrices.translate(0, 0.65, 0);
TextProvider.drawText(matrices, be, 0, Text.of("§b[§aScanning§b]"), immediate);
} else {
matrices.push();
matrices.translate(0.5, 0.5, 0.5);
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) (System.currentTimeMillis() / 60d % 360d))); //Rotate Speed

if(entity.spinEnabled()) {
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) (System.currentTimeMillis() / 60d % 360d))); //Rotate Speed
} else {
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(entity.getRotation()));
}

matrices.scale(0.075f, 0.075f, 0.075f); //TODO make this usable with scaling sliders

int xSize = 1 + Math.max(data.getLeft().getX(), data.getRight().getX()) - Math.min(data.getLeft().getX(), data.getRight().getX());
int zSize = 1 + Math.max(data.getLeft().getZ(), data.getRight().getZ()) - Math.min(data.getLeft().getZ(), data.getRight().getZ());
int xSize = (int) (mesh.dimensions().getXLength() + 1);
int zSize = (int) (mesh.dimensions().getZLength() + 1);

matrices.translate(-xSize / 2f, 0, -zSize / 2f); //TODO make this usable with translation sliders

mesh.render(matrices);
matrices.pop();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import com.mystic.holographicrenders.gui.ProjectorScreen;
import com.mystic.holographicrenders.gui.TextboxScreen;
import com.mystic.holographicrenders.gui.WidgetScreen;
import com.mystic.holographicrenders.network.ProjectorScreenPacket;
import com.mystic.holographicrenders.network.LightPacket;
import com.mystic.holographicrenders.network.RotatePacket;
import com.mystic.holographicrenders.network.SpinPacket;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
Expand All @@ -28,7 +30,9 @@ public void onInitializeClient() {

ScreenRegistry.register(HolographicRenders.PROJECTOR_SCREEN_HANDLER, ProjectorScreen::new);

ClientPlayNetworking.registerGlobalReceiver(ProjectorScreenPacket.UPDATE_ID, ProjectorScreenPacket::onClientUpdate);
ClientPlayNetworking.registerGlobalReceiver(LightPacket.UPDATE_ID, LightPacket::onClientUpdate);
ClientPlayNetworking.registerGlobalReceiver(SpinPacket.UPDATE_ID, SpinPacket::onClientUpdate);
ClientPlayNetworking.registerGlobalReceiver(RotatePacket.UPDATE_ID, RotatePacket::onClientUpdate);
ClientPlayNetworking.registerGlobalReceiver(new Identifier(HolographicRenders.MOD_ID, "render_packet"), (client, handler, buf, responseSender) -> {
ItemStack stack = buf.readItemStack();
BlockPos pos = buf.readBlockPos();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public void render(ProjectorBlockEntity entity, float tickDelta, MatrixStack mat
matrices.multiply(RotationAxis.NEGATIVE_Z.rotationDegrees(facing.getOffsetX() * 90));
matrices.translate(-0.5, -0.5, -0.5);

AreaProvider.setEntity(entity);

if (entity.lightsEnabled()) {
matrices.push();
RenderSystem.enableDepthTest();
Expand Down
Loading

0 comments on commit 9d461dc

Please sign in to comment.