mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 19:58:35 +01:00
parent
fcaedb3d5e
commit
e4a9a8234d
14 changed files with 25 additions and 31 deletions
|
@ -105,11 +105,11 @@ configurations {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'net.minecraftforge:forge:1.19-41.0.45'
|
minecraft 'net.minecraftforge:forge:1.19-41.1.0'
|
||||||
embed 'org.jgrapht:jgrapht-core:1.5.1'
|
embed 'org.jgrapht:jgrapht-core:1.5.1'
|
||||||
|
|
||||||
compileOnly fg.deobf("mezz.jei:jei-1.19-common-api:11.0.0.206")
|
compileOnly fg.deobf("mezz.jei:jei-1.19-common-api:11.1.1.239")
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.19-forge:11.0.0.206")
|
runtimeOnly fg.deobf("mezz.jei:jei-1.19-forge:11.1.1.239")
|
||||||
|
|
||||||
// to test the rf requiring and crafting stuff
|
// to test the rf requiring and crafting stuff
|
||||||
/* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")
|
/* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")
|
||||||
|
|
|
@ -170,7 +170,7 @@ public final class Registry {
|
||||||
event.register(ForgeRegistries.Keys.ENTITY_TYPES, h ->
|
event.register(ForgeRegistries.Keys.ENTITY_TYPES, h ->
|
||||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameEntity = EntityType.Builder.<PipeFrameEntity>of(PipeFrameEntity::new, MobCategory.MISC).build("pipe_frame")));
|
h.register(new ResourceLocation(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameEntity = EntityType.Builder.<PipeFrameEntity>of(PipeFrameEntity::new, MobCategory.MISC).build("pipe_frame")));
|
||||||
|
|
||||||
event.register(ForgeRegistries.Keys.CONTAINER_TYPES, h -> {
|
event.register(ForgeRegistries.Keys.MENU_TYPES, h -> {
|
||||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeContainer = IForgeMenuType.create((windowId, inv, data) -> new MainPipeContainer(Registry.pipeContainer, windowId, inv.player, data.readBlockPos())));
|
h.register(new ResourceLocation(PrettyPipes.ID, "pipe"), Registry.pipeContainer = IForgeMenuType.create((windowId, inv, data) -> new MainPipeContainer(Registry.pipeContainer, windowId, inv.player, data.readBlockPos())));
|
||||||
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalContainer = IForgeMenuType.create((windowId, inv, data) -> new ItemTerminalContainer(Registry.itemTerminalContainer, windowId, inv.player, data.readBlockPos())));
|
h.register(new ResourceLocation(PrettyPipes.ID, "item_terminal"), Registry.itemTerminalContainer = IForgeMenuType.create((windowId, inv, data) -> new ItemTerminalContainer(Registry.itemTerminalContainer, windowId, inv.player, data.readBlockPos())));
|
||||||
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalContainer = IForgeMenuType.create((windowId, inv, data) -> new CraftingTerminalContainer(Registry.craftingTerminalContainer, windowId, inv.player, data.readBlockPos())));
|
h.register(new ResourceLocation(PrettyPipes.ID, "crafting_terminal"), Registry.craftingTerminalContainer = IForgeMenuType.create((windowId, inv, data) -> new CraftingTerminalContainer(Registry.craftingTerminalContainer, windowId, inv.player, data.readBlockPos())));
|
||||||
|
@ -209,7 +209,6 @@ public final class Registry {
|
||||||
public static final class Client {
|
public static final class Client {
|
||||||
|
|
||||||
public static void setup(FMLClientSetupEvent event) {
|
public static void setup(FMLClientSetupEvent event) {
|
||||||
ItemBlockRenderTypes.setRenderLayer(Registry.pipeBlock, RenderType.cutout());
|
|
||||||
BlockEntityRenderers.register(Registry.pipeBlockEntity, PipeRenderer::new);
|
BlockEntityRenderers.register(Registry.pipeBlockEntity, PipeRenderer::new);
|
||||||
EntityRenderers.register(Registry.pipeFrameEntity, PipeFrameRenderer::new);
|
EntityRenderers.register(Registry.pipeFrameEntity, PipeFrameRenderer::new);
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onInitGui(ScreenEvent.InitScreenEvent.Post event) {
|
public void onInitGui(ScreenEvent.Init.Post event) {
|
||||||
var screen = event.getScreen();
|
var screen = event.getScreen();
|
||||||
if (!(screen instanceof ItemTerminalGui terminal))
|
if (!(screen instanceof ItemTerminalGui terminal))
|
||||||
return;
|
return;
|
||||||
|
@ -84,15 +84,15 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRenderGui(ScreenEvent.DrawScreenEvent event) {
|
public void onRenderGui(ScreenEvent.Render event) {
|
||||||
var screen = event.getScreen();
|
var screen = event.getScreen();
|
||||||
if (!(screen instanceof ItemTerminalGui terminal))
|
if (!(screen instanceof ItemTerminalGui terminal))
|
||||||
return;
|
return;
|
||||||
var sync = PlayerPrefs.get().syncJei;
|
var sync = PlayerPrefs.get().syncJei;
|
||||||
if (event instanceof ScreenEvent.DrawScreenEvent.Post) {
|
if (event instanceof ScreenEvent.Render.Post) {
|
||||||
if (this.jeiSyncButton.isHoveredOrFocused())
|
if (this.jeiSyncButton.isHoveredOrFocused())
|
||||||
terminal.renderTooltip(event.getPoseStack(), Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
terminal.renderTooltip(event.getPoseStack(), Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
||||||
} else if (event instanceof ScreenEvent.DrawScreenEvent.Pre) {
|
} else if (event instanceof ScreenEvent.Render.Pre) {
|
||||||
this.jeiSyncButton.setMessage(Component.literal((sync ? ChatFormatting.GREEN : ChatFormatting.RED) + "J"));
|
this.jeiSyncButton.setMessage(Component.literal((sync ? ChatFormatting.GREEN : ChatFormatting.RED) + "J"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class WrenchItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemEnchantability(ItemStack stack) {
|
public int getEnchantmentValue(ItemStack stack) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,10 +79,10 @@ public class PacketButton {
|
||||||
PIPE_TAB((pos, data, player) -> {
|
PIPE_TAB((pos, data, player) -> {
|
||||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level, pos);
|
var tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level, pos);
|
||||||
if (data[0] < 0) {
|
if (data[0] < 0) {
|
||||||
NetworkHooks.openGui((ServerPlayer) player, tile, pos);
|
NetworkHooks.openScreen((ServerPlayer) player, tile, pos);
|
||||||
} else {
|
} else {
|
||||||
var stack = tile.modules.getStackInSlot(data[0]);
|
var stack = tile.modules.getStackInSlot(data[0]);
|
||||||
NetworkHooks.openGui((ServerPlayer) player, new MenuProvider() {
|
NetworkHooks.openScreen((ServerPlayer) player, new MenuProvider() {
|
||||||
@Override
|
@Override
|
||||||
public Component getDisplayName() {
|
public Component getDisplayName() {
|
||||||
return stack.getHoverName();
|
return stack.getHoverName();
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
}
|
}
|
||||||
} else if (handIn == InteractionHand.MAIN_HAND && stack.isEmpty()) {
|
} else if (handIn == InteractionHand.MAIN_HAND && stack.isEmpty()) {
|
||||||
if (!worldIn.isClientSide)
|
if (!worldIn.isClientSide)
|
||||||
NetworkHooks.openGui((ServerPlayer) player, tile, pos);
|
NetworkHooks.openScreen((ServerPlayer) player, tile, pos);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
|
|
|
@ -2,15 +2,11 @@ package de.ellpeck.prettypipes.pipe;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
import net.minecraftforge.client.model.data.ModelData;
|
||||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
|
||||||
import net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -36,18 +32,14 @@ public class PipeRenderer implements BlockEntityRenderer<PipeBlockEntity> {
|
||||||
}
|
}
|
||||||
if (tile.cover != null) {
|
if (tile.cover != null) {
|
||||||
matrixStack.pushPose();
|
matrixStack.pushPose();
|
||||||
ForgeBlockModelRenderer.enableCaching();
|
|
||||||
var renderer = Minecraft.getInstance().getBlockRenderer();
|
var renderer = Minecraft.getInstance().getBlockRenderer();
|
||||||
for (var layer : RenderType.chunkBufferLayers()) {
|
var model = renderer.getBlockModel(tile.cover);
|
||||||
if (!ItemBlockRenderTypes.canRenderInLayer(tile.cover, layer))
|
for (var layer : model.getRenderTypes(tile.cover, RandomSource.create(tile.cover.getSeed(tile.getBlockPos())), ModelData.EMPTY)) {
|
||||||
continue;
|
renderer.getModelRenderer().tesselateBlock(tile.getLevel(), model, tile.cover, tile.getBlockPos(), matrixStack, source.getBuffer(layer), true, RandomSource.create(), tile.cover.getSeed(tile.getBlockPos()), overlay, ModelData.EMPTY, layer);
|
||||||
ForgeHooksClient.setRenderType(layer);
|
|
||||||
renderer.getModelRenderer().tesselateBlock(tile.getLevel(), renderer.getBlockModel(tile.cover), tile.cover, tile.getBlockPos(), matrixStack, source.getBuffer(layer), true, RandomSource.create(), tile.cover.getSeed(tile.getBlockPos()), overlay, EmptyModelData.INSTANCE);
|
|
||||||
}
|
}
|
||||||
ForgeHooksClient.setRenderType(null);
|
|
||||||
ForgeBlockModelRenderer.clearCache();
|
|
||||||
matrixStack.popPose();
|
matrixStack.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
textField.setValue(String.valueOf(StackSizeModuleItem.getMaxStackSize(this.menu.moduleStack)));
|
textField.setValue(String.valueOf(StackSizeModuleItem.getMaxStackSizeForModule(this.menu.moduleStack)));
|
||||||
textField.setMaxLength(4);
|
textField.setMaxLength(4);
|
||||||
textField.setResponder(s -> {
|
textField.setResponder(s -> {
|
||||||
if (s.isEmpty())
|
if (s.isEmpty())
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class StackSizeModuleItem extends ModuleItem {
|
||||||
super("stack_size_module");
|
super("stack_size_module");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMaxStackSize(ItemStack module) {
|
public static int getMaxStackSizeForModule(ItemStack module) {
|
||||||
if (module.hasTag()) {
|
if (module.hasTag()) {
|
||||||
var amount = module.getTag().getInt("max_stack_size");
|
var amount = module.getTag().getInt("max_stack_size");
|
||||||
if (amount > 0)
|
if (amount > 0)
|
||||||
|
@ -42,7 +42,7 @@ public class StackSizeModuleItem extends ModuleItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination) {
|
public int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination) {
|
||||||
var max = StackSizeModuleItem.getMaxStackSize(module);
|
var max = StackSizeModuleItem.getMaxStackSizeForModule(module);
|
||||||
if (StackSizeModuleItem.getLimitToMaxStackSize(module))
|
if (StackSizeModuleItem.getLimitToMaxStackSize(module))
|
||||||
max = Math.min(max, stack.getMaxStackSize());
|
max = Math.min(max, stack.getMaxStackSize());
|
||||||
var amount = 0;
|
var amount = 0;
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class PressurizerBlock extends BaseEntityBlock {
|
||||||
if (tile == null)
|
if (tile == null)
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
if (!worldIn.isClientSide)
|
if (!worldIn.isClientSide)
|
||||||
NetworkHooks.openGui((ServerPlayer) player, tile, pos);
|
NetworkHooks.openScreen((ServerPlayer) player, tile, pos);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class ItemTerminalBlock extends BaseEntityBlock {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
if (!worldIn.isClientSide) {
|
if (!worldIn.isClientSide) {
|
||||||
NetworkHooks.openGui((ServerPlayer) player, tile, pos);
|
NetworkHooks.openScreen((ServerPlayer) player, tile, pos);
|
||||||
tile.updateItems(player);
|
tile.updateItems(player);
|
||||||
}
|
}
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"credit": "Made with Blockbench",
|
"credit": "Made with Blockbench",
|
||||||
"parent": "block/block",
|
"parent": "block/block",
|
||||||
|
"render_type": "cutout",
|
||||||
"textures": {
|
"textures": {
|
||||||
"0": "prettypipes:block/pipe",
|
"0": "prettypipes:block/pipe",
|
||||||
"particle": "prettypipes:block/pipe"
|
"particle": "prettypipes:block/pipe"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"credit": "Made with Blockbench",
|
"credit": "Made with Blockbench",
|
||||||
|
"render_type": "cutout",
|
||||||
"textures": {
|
"textures": {
|
||||||
"0": "prettypipes:block/pipe",
|
"0": "prettypipes:block/pipe",
|
||||||
"particle": "prettypipes:block/pipe"
|
"particle": "prettypipes:block/pipe"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"credit": "Made with Blockbench",
|
"credit": "Made with Blockbench",
|
||||||
"parent": "block/block",
|
"parent": "block/block",
|
||||||
|
"render_type": "cutout",
|
||||||
"textures": {
|
"textures": {
|
||||||
"1": "prettypipes:block/pipe_legs",
|
"1": "prettypipes:block/pipe_legs",
|
||||||
"particle": "prettypipes:block/pipe"
|
"particle": "prettypipes:block/pipe"
|
||||||
|
|
Loading…
Reference in a new issue