I've updated my 1.14.4 mod to 1.15.2 and it turns out sign rendering has been somewhat improved/changed. So I changed from using a direct resource path to the atlas. Good thing is that the sign render for the block works, problem is that the sign render for the sign edit screen doesn't because that uses packets to communicate from server to client and I just don't understand that stuff. So I'm asking for help to get my sign edit screen working, below are images of the issue along with my code. Thank you in advanced.
Sign edit screen:
Sign:
Wood Types:
package biome_enhancments.util;
import java.util.Set;
import it.unimi.dsi.fastutil.objects.ObjectArraySet;
import net.minecraft.block.WoodType;
public class ModWoodTypes extends WoodType
{
private static final Set<WoodType> VALUES = new ObjectArraySet<>();
public static final WoodType BAOBAB = register(new ModWoodTypes("baobab"));
public static final WoodType MANGROVE = register(new ModWoodTypes("mangrove"));
public static final WoodType PALM = register(new ModWoodTypes("palm"));
private final String name;
protected ModWoodTypes(String nameIn) {
super(nameIn);
this.name = nameIn;
}
private static WoodType register(WoodType woodTypeIn) {
VALUES.add(woodTypeIn);
return woodTypeIn;
}
public String getName() {
return this.name;
}
}
Sign Item:
public static final Item BAOBAB_SIGN = new ModSignItem(new Item.Properties().maxStackSize(16).group(ItemGroup.DECORATIONS), ModBlocks.BAOBAB_SIGN, ModBlocks.BAOBAB_WALL_SIGN);
public static final Item MANGROVE_SIGN = new ModSignItem(new Item.Properties().maxStackSize(16).group(ItemGroup.DECORATIONS), ModBlocks.MANGROVE_SIGN, ModBlocks.MANGROVE_WALL_SIGN);
public static final Item PALM_SIGN = new ModSignItem(new Item.Properties().maxStackSize(16).group(ItemGroup.DECORATIONS), ModBlocks.PALM_SIGN, ModBlocks.PALM_WALL_SIGN);
package biome_enhancments.items;
import javax.annotation.Nullable;
import biome_enhancments.tileentity.ModSignTileEntity;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SignItem;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ModSignItem extends SignItem{
public ModSignItem(Properties propertiesIn, Block floorBlockIn, Block wallBlockIn) {
super(propertiesIn, floorBlockIn, wallBlockIn);
}
@Override
protected boolean onBlockPlaced(BlockPos pos, World worldIn, @Nullable PlayerEntity player, ItemStack stack, BlockState state) {
boolean flag = super.onBlockPlaced(pos, worldIn, player, stack, state);
if (!worldIn.isRemote && !flag && player != null) {
player.openSignEditor((ModSignTileEntity)worldIn.getTileEntity(pos));
}
return flag;
}
}
Sign Block:
public static final Block BAOBAB_SIGN = new ModStandingSignBlock(Block.Properties.create(Material.WOOD, MaterialColor.ADOBE).doesNotBlockMovement().hardnessAndResistance(1.0F).sound(SoundType.WOOD), ModWoodTypes.BAOBAB);
public static final Block BAOBAB_WALL_SIGN = new ModWallSignBlock(Block.Properties.create(Material.WOOD, MaterialColor.ADOBE).doesNotBlockMovement().hardnessAndResistance(1.0F).sound(SoundType.WOOD).lootFrom(BAOBAB_SIGN), ModWoodTypes.BAOBAB);
public static final Block MANGROVE_SIGN = new ModStandingSignBlock(Block.Properties.create(Material.WOOD, MaterialColor.OBSIDIAN).doesNotBlockMovement().hardnessAndResistance(1.0F).sound(SoundType.WOOD), ModWoodTypes.MANGROVE);
public static final Block MANGROVE_WALL_SIGN = new ModWallSignBlock(Block.Properties.create(Material.WOOD, MaterialColor.OBSIDIAN).doesNotBlockMovement().hardnessAndResistance(1.0F).sound(SoundType.WOOD).lootFrom(MANGROVE_SIGN), ModWoodTypes.MANGROVE);
public static final Block PALM_SIGN = new ModStandingSignBlock(Block.Properties.create(Material.WOOD, MaterialColor.SAND).doesNotBlockMovement().hardnessAndResistance(1.0F).sound(SoundType.WOOD), ModWoodTypes.PALM);
public static final Block PALM_WALL_SIGN = new ModWallSignBlock(Block.Properties.create(Material.WOOD, MaterialColor.SAND).doesNotBlockMovement().hardnessAndResistance(1.0F).sound(SoundType.WOOD).lootFrom(PALM_SIGN), ModWoodTypes.PALM);
package biome_enhancments.blocks;
import biome_enhancments.tileentity.ModSignTileEntity;
import net.minecraft.block.StandingSignBlock;
import net.minecraft.block.WoodType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class ModStandingSignBlock extends StandingSignBlock {
public ModStandingSignBlock(Properties properties, WoodType woodType) {
super(properties, woodType);
}
@Override
public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new ModSignTileEntity();
}
}
package biome_enhancments.blocks;
import biome_enhancments.tileentity.ModSignTileEntity;
import net.minecraft.block.WallSignBlock;
import net.minecraft.block.WoodType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class ModWallSignBlock extends WallSignBlock {
public ModWallSignBlock(Properties properties, WoodType woodType) {
super(properties, woodType);
}
@Override
public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new ModSignTileEntity();
}
}
Sign Tile Entity:
public static final TileEntityType<ModSignTileEntity> SIGN = TileEntityType.Builder.create(ModSignTileEntity::new , ModBlocks.BAOBAB_SIGN, ModBlocks.BAOBAB_WALL_SIGN, ModBlocks.MANGROVE_SIGN, ModBlocks.MANGROVE_WALL_SIGN, ModBlocks.PALM_SIGN, ModBlocks.PALM_WALL_SIGN).build(null);
package biome_enhancments.tileentity;
import biome_enhancments.init.ModTileEntityTypes;
import net.minecraft.tileentity.SignTileEntity;
import net.minecraft.tileentity.TileEntityType;
public class ModSignTileEntity extends SignTileEntity
{
@Override
public TileEntityType<?> getType() {
return ModTileEntityTypes.SIGN;
}
}
Sign Render:
package biome_enhancments.tileentity;
import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import biome_enhancments.BiomeEnhancements;
import biome_enhancments.blocks.ModStandingSignBlock;
import biome_enhancments.blocks.ModWallSignBlock;
import biome_enhancments.init.ModBlocks;
import net.minecraft.block.AbstractSignBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.StandingSignBlock;
import net.minecraft.block.WallSignBlock;
import net.minecraft.block.WoodType;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.RenderComponentsUtil;
import net.minecraft.client.renderer.Atlases;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.texture.NativeImage;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.tileentity.SignTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.tileentity.SignTileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class ModSignTileEntityRenderer extends TileEntityRenderer<ModSignTileEntity>
{
private final SignTileEntityRenderer.SignModel model = new SignTileEntityRenderer.SignModel();
public ModSignTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
public void render(ModSignTileEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
BlockState blockstate = tileEntityIn.getBlockState();
matrixStackIn.push();
float f = 0.6666667F;
if (blockstate.getBlock() instanceof StandingSignBlock) {
matrixStackIn.translate(0.5D, 0.5D, 0.5D);
float f1 = -((float)(blockstate.get(StandingSignBlock.ROTATION) * 360) / 16.0F);
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f1));
this.model.signStick.showModel = true;
} else {
matrixStackIn.translate(0.5D, 0.5D, 0.5D);
float f4 = -blockstate.get(WallSignBlock.FACING).getHorizontalAngle();
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f4));
matrixStackIn.translate(0.0D, -0.3125D, -0.4375D);
this.model.signStick.showModel = false;
}
matrixStackIn.push();
matrixStackIn.scale(0.6666667F, -0.6666667F, -0.6666667F);
Material material = getMaterial(blockstate.getBlock());
IVertexBuilder ivertexbuilder = material.getBuffer(bufferIn, this.model::getRenderType);
this.model.signBoard.render(matrixStackIn, ivertexbuilder, combinedLightIn, combinedOverlayIn);
this.model.signStick.render(matrixStackIn, ivertexbuilder, combinedLightIn, combinedOverlayIn);
matrixStackIn.pop();
FontRenderer fontrenderer = this.renderDispatcher.getFontRenderer();
float f2 = 0.010416667F;
matrixStackIn.translate(0.0D, (double)0.33333334F, (double)0.046666667F);
matrixStackIn.scale(0.010416667F, -0.010416667F, 0.010416667F);
int i = tileEntityIn.getTextColor().getTextColor();
double d0 = 0.4D;
int j = (int)((double)NativeImage.getRed(i) * 0.4D);
int k = (int)((double)NativeImage.getGreen(i) * 0.4D);
int l = (int)((double)NativeImage.getBlue(i) * 0.4D);
int i1 = NativeImage.getCombined(0, l, k, j);
for(int j1 = 0; j1 < 4; ++j1) {
String s = tileEntityIn.getRenderText(j1, (p_212491_1_) -> {
List<ITextComponent> list = RenderComponentsUtil.splitText(p_212491_1_, 90, fontrenderer, false, true);
return list.isEmpty() ? "" : list.get(0).getFormattedText();
});
if (s != null) {
float f3 = (float)(-fontrenderer.getStringWidth(s) / 2);
fontrenderer.renderString(s, f3, (float)(j1 * 10 - tileEntityIn.signText.length * 5), i1, false, matrixStackIn.getLast().getMatrix(), bufferIn, false, 0, combinedLightIn);
}
}
matrixStackIn.pop();
}
public static Material getMaterial(Block blockIn) {
WoodType woodtype;
if (blockIn instanceof AbstractSignBlock) {
woodtype = ((AbstractSignBlock)blockIn).getWoodType();
} else {
woodtype = WoodType.OAK;
}
return getSignMaterial(woodtype);
}
public static Material getSignMaterial(WoodType woodtype) {
return new Material(Atlases.SIGN_ATLAS, new ResourceLocation(BiomeEnhancements.MOD_ID, "entity/signs/" + woodtype.getName()));
}
}
package biome_enhancments.tileentity;
import biome_enhancments.BiomeEnhancements;
import net.minecraft.client.renderer.Atlases;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = BiomeEnhancements.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModSignTextureStitch {
public static final ResourceLocation BAOBAB = new ResourceLocation(BiomeEnhancements.MOD_ID, "entity/signs/baobab");
public static final ResourceLocation MANGROVE = new ResourceLocation(BiomeEnhancements.MOD_ID, "entity/signs/mangrove");
public static final ResourceLocation PALM = new ResourceLocation(BiomeEnhancements.MOD_ID, "entity/signs/palm");
@SubscribeEvent
public static void onStitchEvent(TextureStitchEvent.Pre event)
{
ResourceLocation stitching = event.getMap().getTextureLocation();
if(!stitching.equals(Atlases.SIGN_ATLAS))
{
return;
}
boolean added = event.addSprite(BAOBAB);
added = event.addSprite(MANGROVE);
added = event.addSprite(PALM);
}
}