forked from KidsDontPlay/Storage-Network
-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
work in progress: working facade blocks rendering in cables
- Loading branch information
Showing
14 changed files
with
382 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/lothrazar/storagenetwork/block/facade/TesrCable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.lothrazar.storagenetwork.block.facade; | ||
|
||
import com.lothrazar.storagenetwork.block.cable.TileCable; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.block.BlockRenderDispatcher; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||
import net.minecraftforge.client.model.data.ModelData; | ||
|
||
public class TesrCable implements BlockEntityRenderer<TileCable> { | ||
|
||
private BlockRenderDispatcher brd; | ||
|
||
public TesrCable(BlockEntityRendererProvider.Context d) { | ||
this.brd = d.getBlockRenderDispatcher(); | ||
} | ||
|
||
@Override | ||
public boolean shouldRenderOffScreen(TileCable te) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void render(TileCable te, float v, PoseStack matrixStack, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { | ||
if (te.getFacadeState() != null) { | ||
brd.renderSingleBlock(te.getFacadeState(), matrixStack, ibuffer, partialTicks, destroyStage, ModelData.EMPTY, RenderType.solid()); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/lothrazar/storagenetwork/block/facade/TesrExportCable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.lothrazar.storagenetwork.block.facade; | ||
|
||
import com.lothrazar.storagenetwork.block.cable.export.TileCableExport; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.block.BlockRenderDispatcher; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||
import net.minecraftforge.client.model.data.ModelData; | ||
|
||
public class TesrExportCable implements BlockEntityRenderer<TileCableExport> { | ||
|
||
private BlockRenderDispatcher brd; | ||
|
||
public TesrExportCable(BlockEntityRendererProvider.Context d) { | ||
this.brd = d.getBlockRenderDispatcher(); | ||
} | ||
|
||
@Override | ||
public boolean shouldRenderOffScreen(TileCableExport te) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void render(TileCableExport te, float v, PoseStack matrixStack, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { | ||
if (te.getFacadeState() != null) { | ||
brd.renderSingleBlock(te.getFacadeState(), matrixStack, ibuffer, partialTicks, destroyStage, ModelData.EMPTY, RenderType.solid()); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/lothrazar/storagenetwork/block/facade/TesrImportCable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.lothrazar.storagenetwork.block.facade; | ||
|
||
import com.lothrazar.storagenetwork.block.cable.input.TileCableIO; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.block.BlockRenderDispatcher; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||
import net.minecraftforge.client.model.data.ModelData; | ||
|
||
public class TesrImportCable implements BlockEntityRenderer<TileCableIO> { | ||
|
||
private BlockRenderDispatcher brd; | ||
|
||
public TesrImportCable(BlockEntityRendererProvider.Context d) { | ||
this.brd = d.getBlockRenderDispatcher(); | ||
} | ||
|
||
@Override | ||
public boolean shouldRenderOffScreen(TileCableIO te) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void render(TileCableIO te, float v, PoseStack matrixStack, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { | ||
if (te.getFacadeState() != null) { | ||
brd.renderSingleBlock(te.getFacadeState(), matrixStack, ibuffer, partialTicks, destroyStage, ModelData.EMPTY, RenderType.solid()); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/lothrazar/storagenetwork/block/facade/TesrImportFilterCable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.lothrazar.storagenetwork.block.facade; | ||
|
||
import com.lothrazar.storagenetwork.block.cable.inputfilter.TileCableImportFilter; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.block.BlockRenderDispatcher; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||
import net.minecraftforge.client.model.data.ModelData; | ||
|
||
public class TesrImportFilterCable implements BlockEntityRenderer<TileCableImportFilter> { | ||
|
||
private BlockRenderDispatcher brd; | ||
|
||
public TesrImportFilterCable(BlockEntityRendererProvider.Context d) { | ||
this.brd = d.getBlockRenderDispatcher(); | ||
} | ||
|
||
@Override | ||
public boolean shouldRenderOffScreen(TileCableImportFilter te) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void render(TileCableImportFilter te, float v, PoseStack matrixStack, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { | ||
if (te.getFacadeState() != null) { | ||
brd.renderSingleBlock(te.getFacadeState(), matrixStack, ibuffer, partialTicks, destroyStage, ModelData.EMPTY, RenderType.solid()); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/lothrazar/storagenetwork/block/facade/TesrStorageCable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.lothrazar.storagenetwork.block.facade; | ||
|
||
import com.lothrazar.storagenetwork.block.cable.link.TileCableLink; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.block.BlockRenderDispatcher; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||
import net.minecraftforge.client.model.data.ModelData; | ||
|
||
public class TesrStorageCable implements BlockEntityRenderer<TileCableLink> { | ||
|
||
private BlockRenderDispatcher brd; | ||
|
||
public TesrStorageCable(BlockEntityRendererProvider.Context d) { | ||
this.brd = d.getBlockRenderDispatcher(); | ||
} | ||
|
||
@Override | ||
public boolean shouldRenderOffScreen(TileCableLink te) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void render(TileCableLink te, float v, PoseStack matrixStack, MultiBufferSource ibuffer, int partialTicks, int destroyStage) { | ||
if (te.getFacadeState() != null) { | ||
brd.renderSingleBlock(te.getFacadeState(), matrixStack, ibuffer, partialTicks, destroyStage, ModelData.EMPTY, RenderType.solid()); | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/com/lothrazar/storagenetwork/network/CableFacadeMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.lothrazar.storagenetwork.network; | ||
|
||
import java.util.function.Supplier; | ||
import com.lothrazar.storagenetwork.block.cable.TileCable; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraftforge.network.NetworkEvent; | ||
|
||
public class CableFacadeMessage { | ||
|
||
//sync sort data TO client gui FROM server | ||
private BlockPos pos; | ||
private boolean erase = false; | ||
private CompoundTag blockStateTag = new CompoundTag(); | ||
|
||
private CableFacadeMessage() {} | ||
|
||
public CableFacadeMessage(BlockPos pos, CompoundTag state) { | ||
this.pos = pos; | ||
this.blockStateTag = state; | ||
this.erase = false; | ||
} | ||
|
||
public CableFacadeMessage(BlockPos pos, boolean eraseIn) { | ||
this.pos = pos; | ||
this.erase = eraseIn; | ||
blockStateTag = new CompoundTag(); | ||
} | ||
|
||
public static void handle(CableFacadeMessage message, Supplier<NetworkEvent.Context> ctx) { | ||
ctx.get().enqueueWork(() -> { | ||
ServerPlayer player = ctx.get().getSender(); | ||
ServerLevel serverWorld = (ServerLevel) player.level(); | ||
TileCable tile = TileCable.getTileCable(serverWorld, message.pos); | ||
if (tile != null) { | ||
if (message.erase) { | ||
// StorageNetworkMod.log("Network Packet facade SAVE NULL EMPTY ERASE " + message.blockStateTag); | ||
tile.setFacadeState(null); | ||
} | ||
else { | ||
// StorageNetworkMod.log("Network Packet facade SAVE " + message.blockStateTag); | ||
tile.setFacadeState(message.blockStateTag); | ||
} | ||
serverWorld.markAndNotifyBlock(message.pos, serverWorld.getChunkAt(message.pos), | ||
tile.getBlockState(), tile.getBlockState(), 3, 1); | ||
} | ||
}); | ||
ctx.get().setPacketHandled(true); | ||
} | ||
|
||
public static CableFacadeMessage decode(FriendlyByteBuf buf) { | ||
CableFacadeMessage message = new CableFacadeMessage(); | ||
message.erase = buf.readBoolean(); | ||
message.pos = buf.readBlockPos(); | ||
message.blockStateTag = buf.readNbt(); | ||
return message; | ||
} | ||
|
||
public static void encode(CableFacadeMessage msg, FriendlyByteBuf buf) { | ||
buf.writeBoolean(msg.erase); | ||
buf.writeBlockPos(msg.pos); | ||
buf.writeNbt(msg.blockStateTag); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.