Jump to content

Tschipp

Forge Modder
  • Posts

    307
  • Joined

  • Last visited

Everything posted by Tschipp

  1. I didn't change any of my code, just the block model. In the shouldSideBeRendered method I check if the side is touching air. If it is, I return false.
  2. Alright, I made some progress: The sides now all get rendered, the problem is, they get rendered even when touching air. How do I need to alter my code / blockmodel? here is my model, I made it using MrCrayfish's model maker, because I have no idea how to model by hand: { "textures": { }, "elements": [ { "name": "Cube", "from": [ 0.0, 0.0, 0.0 ], "to": [ 0.0, 16.0, 16.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] } } }, { "name": "Cube", "from": [ 0.0, 0.0, 0.0 ], "to": [ 16.0, 16.0, 0.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] } } }, { "name": "Cube", "from": [ 16.0, 0.0, 0.0 ], "to": [ 16.0, 16.0, 16.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] } } }, { "name": "Cube", "from": [ 0.0, 0.0, 16.0 ], "to": [ 16.0, 16.0, 16.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] } } }, { "name": "Cube", "from": [ 0.0, 16.0, 0.0 ], "to": [ 16.0, 16.0, 16.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] } } }, { "name": "Cube", "from": [ 0.0, 0.0, 0.0 ], "to": [ 16.0, 0.0, 16.0 ], "shade": false, "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] } } } ] }
  3. I just realized I'm probably a idiot for using a block model that only has one element. I'll add some planes and get back to you. I am using the cube_all model
  4. I am using the cube_all model
  5. Is that all I have to do or do I have to change some code as well?
  6. I'm trying to make a block that only renders it's side when it touches a block that is not air. This sort of works so far, the problem is that the block is only visible from the outside. Here is a screenshot to explain: The block is only visible through the grass, not if I stand inside or behind the block. I think, what I need to do is tell the game to render the insides of the block as well. How would I do that? Block Class: package tschipp.buildingblocks.blocks; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import tschipp.buildingblocks.BBMod; public class BlockOvergrowth extends Block implements IShearable { public static final AxisAlignedBB boundingBox = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0625D, 0.0625D,0.0625D); public BlockOvergrowth() { super(Material.PLANTS, MapColor.GRASS); this.setCreativeTab(BBMod.buildingBlocks); this.setUnlocalizedName("overgrowth"); this.setSoundType(SoundType.PLANT); this.setHardness(0.1F); this.setResistance(1F); } @Override public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos) { return true; } @Override @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return boundingBox; } @Nullable @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { return NULL_AABB; } @Override public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) { return true; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } @Override public boolean isCollidable() { return false; } @Deprecated @Override public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess world, BlockPos pos, EnumFacing side) { Block nextTo = world.getBlockState(pos.offset(side)).getBlock(); if(nextTo != Blocks.AIR) { return true; } return false; } @Override public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { List<ItemStack> drops = new ArrayList<ItemStack>(); drops.add(new ItemStack(BBBlocks.overgrowth)); return drops; } }
  7. I can try that when I get home... The weird thing is... when I just set the displaname by typing event.setDisplayname("TestName") in the NameFormat event, it seems to display fine...
  8. I don't know, how would I do that?
  9. I'm trying to make a Command that changes the Player's Display Name. It stores that name in the player's NBT. When I use the command it sort of works, it only changes my name in chat and in death messages. When trying on a LAN world the display name is still Player... I'm not sure why this is happening. I copy the data from the dead player to the new one fine, that can't be the problem. I also try refreshing the name using player.refreshDisplayName() but that doesn't seem to do anything. I've also tried manually firing the event, no luck there. EDIT: I did some work and also added a Packet. I have little experience with packets so I'm probably doing something completely wrong, please don't blame me. In any case, whatever I did didn't seem to fix anything. This is my main Class (My events are at the bottom): package tschipp.fakename; import tschipp.creativePlus.network.NoisePacket; import tschipp.creativePlus.network.NoisePacketHandler; import tschipp.creativePlus.network.RadiusPacket; import tschipp.creativePlus.network.RadiusPacketHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = "fakename", name = "Fake Name", version = "1.0") public class FakeName { @Instance(value = "fakename") public static FakeName instance; public static SimpleNetworkWrapper network; @EventHandler public void preInit(FMLPreInitializationEvent event) { network = NetworkRegistry.INSTANCE.newSimpleChannel("FakeNameChannel"); network.registerMessage(FakeNamePacketHandler.class, FakeNamePacket.class, 0, Side.SERVER); } @EventHandler public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } @EventHandler public void serverLoad(FMLServerStartingEvent event) { event.registerServerCommand(new CommandFakeName()); } /*@SubscribeEvent public void onChat(ServerChatEvent event) { EntityPlayerMP player = event.getPlayer(); NBTTagCompound tag = player.getEntityData(); String username = event.getUsername(); String message = event.getMessage(); String component = event.getComponent().getFormattedText(); if(tag.hasKey("fakename") && !tag.hasKey("oldfakename")) { event.setComponent(new TextComponentString(event.getComponent().getUnformattedText().replace(username, tag.getString("fakename")))); } if(tag.hasKey("fakename") && tag.hasKey("oldfakename")) { event.setComponent(new TextComponentString(event.getComponent().getUnformattedText().replace(tag.getString("oldfakename"), tag.getString("fakename")))); } System.out.println(tag); } */ @SubscribeEvent public void renderName(PlayerEvent.NameFormat event) { NBTTagCompound tag = event.getEntityLiving().getEntityData(); if(tag.hasKey("fakename")) { event.setDisplayname(tag.getString("fakename")); event.setDisplayname(tag.getString("fakename")); } else { event.setDisplayname(event.getUsername()); } } //Makes Sure that the Data persists on Death @SubscribeEvent public void onClone(PlayerEvent.Clone event) { EntityPlayer oldPlayer = event.getOriginal(); EntityPlayer newPlayer = event.getEntityPlayer(); if(oldPlayer.getEntityData().hasKey("fakename")) { String fakename = oldPlayer.getEntityData().getString("fakename"); newPlayer.getEntityData().setString("fakename", fakename); PlayerEvent.NameFormat event2 = new PlayerEvent.NameFormat(newPlayer, fakename); MinecraftForge.EVENT_BUS.post(event2); } } } This is my Command Class: package tschipp.fakename; import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; public class CommandFakeName extends CommandBase implements ICommand { private final List names; public CommandFakeName() { names = new ArrayList(); names.add("fakename"); names.add("fn"); } @Override public int compareTo(ICommand o) { return 0; } @Override public String getCommandName() { return "fakename"; } @Override public String getCommandUsage(ICommandSender sender) { return "/fakename <mode> <args...>"; } public String getCommandUsageReal() { return "/fakename real <fakename> "; } public String getCommandUsageClear() { return "/fakename clear <player>"; } public String getCommandUsageSet() { return "/fakename set <player> <fakename> OR /fakename set <fakename>"; } @Override public List<String> getCommandAliases() { return this.names; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if(args.length > 0) { if (args[0].toLowerCase().equals("set")) { // Handling set <Playername> <Fakename> if (args.length == 3) { String playername = args[1]; String fakename = args[2]; EntityPlayerMP player = CommandBase.getPlayer(server, sender, playername); NBTTagCompound tag = player.getEntityData(); fakename = fakename.replace("&", "§"); tag.setString("fakename", fakename); if (sender.getCommandSenderEntity() != null && sender.getCommandSenderEntity() instanceof EntityPlayerMP && !playername.equals(((EntityPlayer) sender).getGameProfile().getName())) { sender.addChatMessage(new TextComponentString(playername + "'s name is now " + fakename)); } player.addChatMessage(new TextComponentString("Your name is now " + fakename)); FakeName.network.sendToAll(new FakeNamePacket(tag)); player.refreshDisplayName(); } // Handling set <Fakename> else if (args.length == 2) { String fakename = args[1]; EntityPlayerMP player = CommandBase.getPlayer(server, sender, sender.getName()); NBTTagCompound tag = player.getEntityData(); fakename = fakename.replace("&", "§"); tag.setString("fakename", fakename); player.addChatMessage(new TextComponentString("Your name is now " + fakename)); FakeName.network.sendToAll(new FakeNamePacket(tag)); player.refreshDisplayName(); } else { throw new WrongUsageException(this.getCommandUsageSet()); } // Handling real <Fakename> } else if (args[0].toLowerCase().equals("real")) { if (args.length == 2) { String fakename = args[1]; String[] allNames = server.getAllUsernames(); for (int i = 0; i < allNames.length; i++) { EntityPlayerMP testingPlayer = CommandBase.getPlayer(server, sender, allNames[i]); if (testingPlayer.getEntityData() != null && testingPlayer.getEntityData().hasKey("fakename")) { String fakeNamePlayer = testingPlayer.getEntityData().getString("fakename"); String toRemove; while (fakeNamePlayer.contains("§")) { toRemove = fakeNamePlayer.substring((fakeNamePlayer.indexOf("§")), fakeNamePlayer.indexOf("§") + 2); fakeNamePlayer = fakeNamePlayer.replace(toRemove, ""); } if(fakeNamePlayer.toLowerCase().equals(fakename.toLowerCase())) { sender.addChatMessage(new TextComponentString(fakeNamePlayer + "'s real name is " + testingPlayer.getGameProfile().getName())); return; } } if (i == allNames.length - 1) { sender.addChatMessage(new TextComponentString(TextFormatting.RED + "There is no Player with the Fake Name '" + fakename + "'")); } } } else { throw new WrongUsageException(this.getCommandUsageReal()); } } //Handling clear <playername> else if (args[0].toLowerCase().equals("clear")) { if (args.length == 2) { String playername = args[1]; EntityPlayerMP player = CommandBase.getPlayer(server, sender, playername); if(player.getEntityData() != null && player.getEntityData().hasKey("fakename")) { player.getEntityData().removeTag("fakename"); sender.addChatMessage(new TextComponentString(playername+"'s Fake Name was removed")); player.refreshDisplayName(); } else { sender.addChatMessage(new TextComponentString(TextFormatting.RED + "The provided Player does not have a Fake Name")); } } else { throw new WrongUsageException(this.getCommandUsageClear()); } } } else { throw new WrongUsageException(this.getCommandUsage(sender)); } } @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { return true; } @Override public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { if (args.length > 0) { if (args.length == 1) { return CommandBase.getListOfStringsMatchingLastWord(args, "set", "real", "clear"); } if (args.length == 2 && (args[0].equals("set") || args[0].equals("clear"))) { return CommandBase.getListOfStringsMatchingLastWord(args, server.getAllUsernames()); } else { return Collections.<String>emptyList(); } } return Collections.<String>emptyList(); } @Override public boolean isUsernameIndex(String[] args, int index) { return false; } @Override public int getRequiredPermissionLevel() { return 4; } } Packet: package tschipp.fakename; import io.netty.buffer.ByteBuf; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; public class FakeNamePacket implements IMessage { public NBTTagCompound tag; public FakeNamePacket() { } public FakeNamePacket(NBTTagCompound tag) { this.tag = tag; } @Override public void fromBytes(ByteBuf buf) { this.tag = ByteBufUtils.readTag(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeTag(buf, this.tag); } } Packet Handler: package tschipp.fakename; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; import net.minecraft.util.IThreadListener; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import tschipp.creativePlus.items.CustomItems; import tschipp.creativePlus.network.NoisePacket; public class FakeNamePacketHandler implements IMessageHandler<FakeNamePacket, IMessage>{ @Override public IMessage onMessage(final FakeNamePacket message, final MessageContext ctx) { IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.worldObj; mainThread.addScheduledTask(new Runnable(){ EntityPlayerMP player = ctx.getServerHandler().playerEntity; @Override public void run() { NBTTagCompound tag = message.tag; NBTTagCompound playerTag = player.getEntityData(); playerTag.setString("fakename", tag.getString("fakename")); } }); return null; } } This is all my code. There is no more.
  10. How do I do that? Also I did some more testing and noticed that the block's color gets reset even when the chunk gets unloaded...
  11. I added this to my onLoad() method in my TileEntity class. @Override public void onLoad() { if(worldObj.isRemote) {this.worldObj.sendPacketToServer(getUpdatePacket());} } It just kicks me out of the world.
  12. I don't think so. All my other Blocks work too. As I said earlier, I was able to see the TileEntity using Worldedit. Here is my ClientProxy just in case I am derping. public class ClientProxy extends CommonProxy { public void preInit(FMLPreInitializationEvent event) { super.preInit(event); } public void init(FMLInitializationEvent event) { super.init(event); ItemRenderRegister.registerItems(); BlockRenderRegister.registerBlocks(); Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new BlockConcreteDyeable(Material.ROCK), MoreBlocks.concreteDyeable); } public void postInit(FMLPostInitializationEvent event) { super.postInit(event); } }
  13. Yes. In my CommonProxy in preInit GameRegistry.registerTileEntity(TileEntityConcrete.class, "bbconcrete"); Try sending the update packet, somewhere other than right click. Where for example? I'm already trying to send it in the updateTick method, but that seems to do nothing.
  14. Yes. In my CommonProxy in preInit GameRegistry.registerTileEntity(TileEntityConcrete.class, "bbconcrete");
  15. I made some Changes, it sort of works now, the color of the block updates when right clicked and uses the correct color from NBT. But on re-entering the world all the blocks are still black. I debugged at colorMultiplier and found that the tileentity's tag is null. Why is that? The block gets recoloured correctly when right clicked, but it goes away on reloading the world. I might have a ton of unneccesary or stupid code everywhere, but please don't blame me, as it is my first time working with tile entities. Here is an image to make it a bit clearer what i'm trying to do. This is my current code: Block Class: package tschipp.buildingblocks.blocks; import java.util.Random; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import tschipp.buildingblocks.blocks.tileentity.TileEntityConcrete; public class BlockConcrete extends Block implements IBlockColor{ public BlockConcrete(Material material) { super(material, MapColor.GRAY); this.setHardness(3.5F); this.setResistance(8F); this.setTickRandomly(true); } //FOR TESTING PURPOSES @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { TileEntityConcrete tile = (TileEntityConcrete) world.getTileEntity(pos); NBTTagCompound tag = new NBTTagCompound(); tile.setColor(tile.getColor() + 1000); tile.writeToNBT(tag); if(player instanceof EntityPlayerMP) { ((EntityPlayerMP) player).connection.sendPacket(new SPacketUpdateTileEntity(pos, 0, tag)); } world.notifyBlockOfStateChange(pos, this); tile.markDirty(); } return true; } @Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { TileEntityConcrete tile = (TileEntityConcrete) world.getTileEntity(pos); NBTTagCompound tag = new NBTTagCompound(); tile.writeToNBT(tag); if(world.isRemote) { world.sendPacketToServer(new SPacketUpdateTileEntity(pos, -1, tag)); } } @Override public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT_MIPPED; } @Override public boolean hasTileEntity(IBlockState state) { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityConcrete(); } @SideOnly(Side.CLIENT) @Override public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) { TileEntityConcrete tile = (TileEntityConcrete) worldIn.getTileEntity(pos); int color = tile.getColor(); return color; } } Tile Entity Class: package tschipp.buildingblocks.blocks.tileentity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityConcrete extends TileEntity { protected int color; @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); this.color = tag.getInteger("color"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { if (tag == null) { NBTTagCompound comp = new NBTTagCompound(); comp.setInteger("color", this.color); return super.writeToNBT(comp); } else { tag.setInteger("color", this.color); return super.writeToNBT(tag); } } @Override public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(pos, -1, this.getUpdateTag()); } @Override public void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.SPacketUpdateTileEntity pkt) { readFromNBT(pkt.getNbtCompound()); worldObj.markBlockRangeForRenderUpdate(this.pos, this.pos); } @Override public NBTTagCompound getUpdateTag() { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("color", this.getColor()); return tag; } @Override public boolean receiveClientEvent(int id, int type) { return true; } public int getColor() { return this.color; } public void setColor(int color) { this.color = color; } }
  16. How would I go about synchronizing the color value with the client? Packets? I had this null check because it used to crash sometimes for some reason... I just thought that markDirty makes sure the values are saved.
  17. Yes, as I said, I was able to check it's values using McEdit
  18. I used to use getColor, but I switched to this, trying to find why it isn't working. It makes no (visual) difference. Why shouldn't I implement ITileEntityProvider? Anyway, I did what you said but sadly it doesn't change anything
  19. Idk if it is a clean way to do this, but I just used in Block#onBlockStartBreak: if(world.isRemote) { this.side = Minecraft.getMinecraft().objectMouseOver.sideHit; }
  20. I'm trying to make a block that stores a color value as NBT and then retrieves that color value and visualizes it in form of a block tint (Similarly to Openblocks' Canvas). When I place the block in the world it works, and gives the block the default color of 10000. But when I relog the world, all blocks are rendered black (color multiplier is 0) I looked at all the black blocks using an NBT editor, but they still have the same color value of 10000, that I gave them from the start. What is happening? TileEntity Class: package tschipp.buildingblocks.blocks.tileentity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class TileEntityConcrete extends TileEntity { protected int color = 10000; @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); this.markDirty(); this.color = tag.getInteger("color"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { if (tag == null) { NBTTagCompound comp = new NBTTagCompound(); comp.setInteger("color", this.color); this.markDirty(); return super.writeToNBT(comp); } else { tag.setInteger("color", this.color); this.markDirty(); return super.writeToNBT(tag); } } public int getColor() { return this.color; } } Block Class: package tschipp.buildingblocks.blocks; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import tschipp.buildingblocks.blocks.tileentity.TileEntityConcrete; public class BlockConcrete extends Block implements ITileEntityProvider, IBlockColor{ public BlockConcrete(Material material) { super(material, MapColor.GRAY); this.setHardness(3.5F); this.setResistance(8F); } //FOR TESTING PURPOSES @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!world.isRemote) { TileEntityConcrete tile = (TileEntityConcrete) world.getTileEntity(pos); NBTTagCompound tag = new NBTTagCompound(); tile.writeToNBT(tag); if(tag.hasKey("color")) { tag.setInteger("color", tag.getInteger("color") + 1000); System.out.println(tag.getInteger("color")); tile.readFromNBT(tag); world.scheduleBlockUpdate(pos, this, 1, 1); } else { tag.setInteger("color", 1000); tile.readFromNBT(tag); } } return true; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityConcrete(); } @SideOnly(Side.CLIENT) @Override public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) { TileEntityConcrete tile = (TileEntityConcrete) worldIn.getTileEntity(pos); NBTTagCompound tag = new NBTTagCompound(); tile.writeToNBT(tag); int color = tag.getInteger("color"); return color + 10000; } }
  21. I'm on 1.8.9 because I am slow And yes, I called it in the wrong place. It works now! Thanks!
  22. I am trying to make a fire for my mod, that looks basically like the vanilla fire, but in grey. In my RenderingRegistry for Blocks I added this line: ModelLoader.setCustomStateMapper(BedrockiumBlocks.bedrockiumFire, new StateMap.Builder().ignore(BlockFire.AGE).build()); If I understand it correctly, it should ignore the AGE Property when looking for the model, but in the console I get this error: [15:35:21] [Client thread/ERROR] [FML]: Model definition for location be:bedrockiumFire#age=8,alt=true,east=true,flip=false,north=true,south=true,upper=1,west=false not found It is still looking for a model with the age of 8. What am I doing wrong?
  23. what are you trying to do? Where are you trying to store this boolean? On a block? Item? Entity? World? Explain yourself, show code
  24. He has: Here is my block class: Hidden package top.mod.block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.BlockRenderLayer; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class PlatinumBlock extends BlockBase { public PlatinumBlock(Material mat) { super(mat); setHardness(6F); setResistance(6F); setHarvestLevel("pickaxe", 3); this.setSoundType(SoundType.METAL); } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } public boolean isFullCube(IBlockState state) { return false; } protected boolean canSilkHarvest() { return true; } }[/Code]
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.