Jump to content

Tschipp

Forge Modder
  • Posts

    307
  • Joined

  • Last visited

Everything posted by Tschipp

  1. Nope, as I mentioned, I'm using a oreDictionary entry, in this case "listAllwater"
  2. I was just about to ask the same question, but then I saw this thread. This all works for me, but after i've used the item once in crafting (meaning its damaged), I can no longer use it. Note that I am using a shapeless OreDict recipe.
  3. I made an implementation of WorldSavedData., but the values don't get shared with client and server, and I'm not sure how to connect them. I also ended up saving the seed instead of all the item ids, makes it a bit easier. This is the event: @SubscribeEvent public void onWorldLoad(WorldEvent.Load event) { World world = event.getWorld(); long seed = Math.abs(world.getSeed()); WorldSeedSavedData.getInstance(world).setSeed(seed); WorldSeedSavedData.getInstance(world).markDirty(); } And this is my WorldSavedData: package tschipp.buildingblocks.util; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraft.world.storage.MapStorage; import tschipp.buildingblocks.BBMod; public class WorldSeedSavedData extends WorldSavedData { private static final String DATA_NAME = BBMod.MODID + "_SEED"; private long seed; public WorldSeedSavedData() { super(DATA_NAME); } @Override public void readFromNBT(NBTTagCompound tag) { this.seed = tag.getLong("seed"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { tag.setLong("seed", this.seed); return tag; } public void setSeed(long seed) { this.seed = seed; } public long getSeed() { return this.seed; } public static WorldSeedSavedData getInstance(World world) { MapStorage storage = world.getPerWorldStorage(); WorldSeedSavedData instance = (WorldSeedSavedData) storage.getOrLoadData(WorldSeedSavedData.class, DATA_NAME); if (instance == null) { instance = new WorldSeedSavedData(); storage.setData(DATA_NAME, instance); } return instance; } }
  4. Ah ok. Now that you mention it: Will JEI be able to see my recepies by default? Because that kinda ruins the purpose of secret crafting recipes. EDIT: Also, I should maybe add, that I plan on adding multiple different recipes, with all having different items, so I'm not sure storing the items is a good idea.
  5. Thanks, this is exactly what I needed. I didn't know you could create randoms with a seed. Also, can you elaborate on why I should send the packet at these specific events? They do not have anything to do with crafting right? Also how would the PacketHandler look like?
  6. lol I suggest you do a ray cast and then teleport the player to the position that was hit.
  7. Alright, some progress has been made: The mod generates a recipe that creates gold blocks. It takes one ingredient. That ingredient is defined by the world's seed. So what I'm doing, is when checking if the recipes match, I get the world seed, get the log from that number, and then get a item/block corresponding to that id. The problem is, that the matches() method gets executed twice. Once of the client side and once on the server side. The client side gets executed first, then the server side. The client side passes an instance of WorldClient as world, which makes it impossible to get the seed from that. The server side passes a WorldServer, everything there works fine. The crafting recipe actually works, the problem is that the output item isn't displayed, because the client version of the matches() method returns false. I hope I was clear enough, but just in case, here is my code: private static long seed; private static int seedLog; private static Item worldItem; public boolean matches(InventoryCrafting inv, World world) { seed = world.getSeed(); seedLog = (int) Math.log(Math.abs(seed) / 10); worldItem = Item.getItemById(seedLog); ItemStack stack = ItemStack.EMPTY; for (int i = 0; i < inv.getSizeInventory(); ++i) { ItemStack currentstack = inv.getStackInSlot(i); if (!currentstack.isEmpty()) { Item current = currentstack.getItem(); if(worldItem != null && current == worldItem) { return true; } } } return false; } Also, here is a gif demonstrating what is happening: GIF
  8. Ah yes, very good. So for example, I could create an item that when right clicked registers the crafting recipe for the given world. But how would I make it so that other worlds don't have access to that recipe?
  9. I have some experience with IRecipes so that can be done. I was hoping to not have to make a new Crafting table tough, darn. I'll look into it, thanks.
  10. So I had this idea for a mod that adds randomly generated crafting recepies that are specific to one world/seed. I have already tested some stuff and it turns out that you can add new recepies at runtime, but these recepies of course then also persist over saves and could cause problems with multiplayer servers. I am just wondering? Is something like this possible? Can you point me in a direction?
  11. Hm. I am quite struggling with the world.spawnParticle method. Can you point me in a direction?
  12. So In 1.10, the colorMultiplier Method just passed null as IBlockAccess when the player sprinted over a block or broke it. Now in 1.11, it passes an instance of WorldClient. It is easy to check if the passed Object is an instance of WorldClient or not, the problem is just that I need to access a Tile Entity to extract data used for rendering the color. With WorldClient getTileEntity always returns null. I hope you understand my problem, this is my code: @Override @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) { if (worldIn != null && pos != null) { TileEntityConcrete tile = (TileEntityConcrete) worldIn.getTileEntity(pos); if(tile != null) { int color = tile.getColor(); return color; } return -1; } else { return -1; } }
  13. You are talking about the file path in the model files, right? Because that would mean that I have to change every file, as I said. Anyway, I have already written a script that does the job just fine.
  14. Ah, I see. Yes, that has actually happened to me. I had named some files differently while working on them, but when I built it into a jar the textures didn't show up ingame.
  15. Well I guess I could, I just have no clue how to or where to even start... I guess I'll try googling some stuff
  16. I am in the process of updating my 1.10 mod to 1.11. I used uppercase and lowercase letters for model and texture names, but as of 1.11 it all needs to be lowercase (for some reason...) I found a program that could bulk rename all the files to lowercase, so that is done. Now I *just* need to change all the contents of the files to lowercase. Do you know of any program/command that can convert entire folder contents to lowercase? I have like 1 million model files, so editing them all by hand would be a pain...
  17. I'm trying to make somewhat of a library to make registering Blocks and Items less tedious. I wondered if it was possible to make a method that not only registers the Block, but also registers the Render for that block. I use ModelLoader, so it can be used simultaneously with block creation in preInit. It works as expected on Client, but obviously crashes on Servers because the ModelLoader class doesn't exist. So I added a SideOnly statement before my method. I call that method from my constructor, the problem is that the server now tries to call a method that I made Client Side only. Is there a way to only call the method on the Client side? This is my code: public class TSBlockTextured extends TSBlock { public TSBlockTextured(String name, Material blockMaterialIn, MapColor blockMapColorIn, String modid) { super(name, blockMaterialIn, blockMapColorIn, modid); registerTexture(name, modid); } @SideOnly(Side.CLIENT) private void registerTexture(String name, String modid) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(modid + ":" + name, "inventory")); } }
  18. I figured it out, thanks for the help!
  19. It still is erroring though
  20. I think I'm already using a lambda for my BlockGravelGrass class: Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((state, worldIn, pos, tintIndex) -> { if(worldIn != null && pos != null && tintIndex == 0) { return BiomeColorHelper.getGrassColorAtPos(worldIn, pos); } return -1; }, BBBlocks.gravelGrass);
  21. So should I just not implement IItemColor? Are there other ways of adding a color to an item (and block)? I would've guessed making getColorFromItemStack() SideOnly(Side.CLIENT) would be enough to fix this... I can't implement the interface client side only, right?
  22. Wand: package tschipp.creativePlus.items; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class Wand extends Item implements IItemColor{ public Vec3d pos1; public Vec3d pos2; public Vec3d difference; public Vec3d posToPlaceBlock; public IBlockState mat; public Wand() { this.setMaxStackSize(1); } @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> subItems) { NBTTagCompound subTag = new NBTTagCompound(); subTag.setString("material", "minecraft:stone"); subTag.setInteger("damage", 0); subTag.setDouble("pos1x", 0); subTag.setDouble("pos1y", 0); subTag.setDouble("pos1z", 0); subTag.setDouble("pos2x", 0); subTag.setDouble("pos2y", 0); subTag.setDouble("pos2z", 0); subTag.setBoolean("hasSetPos1", false); subTag.setBoolean("hasSetPos2", false); ItemStack stack = new ItemStack(item, 1, 0); stack.setTagCompound(subTag); subItems.add(stack); } @Override @SideOnly(Side.CLIENT) public String getItemStackDisplayName(ItemStack stack) { if(stack.getTagCompound() != null) { Block block = Block.getBlockFromName(stack.getTagCompound().getString("material")); IBlockState state = block.getStateFromMeta(stack.getTagCompound().getInteger("damage")); ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state)); return "Line Wand (" + blockStack.getDisplayName() +")"; } else { return "" + I18n.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name"); } } @Override @SideOnly(Side.CLIENT) public int getColorFromItemstack(ItemStack stack, int tintIndex) { { Block block = Block.getBlockFromName(stack.getTagCompound().getString("material")); IBlockState state = block.getStateFromMeta(stack.getTagCompound().getInteger("damage")); if(block.getMapColor(state).colorValue == 000) { System.out.println(block.getMapColor(state)); return 201196; } else { return block.getMapColor(state).colorValue; } } } @Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { World world = player.worldObj; if(pos.getX() < 0) { pos2 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()); } if(pos.getX() > 0) { pos2 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()); } if(pos.getZ() < 0) { pos2 = new Vec3d(pos.getX(), pos.getY(), pos.getZ()-0.5); } if(pos.getX() > 0) { pos2 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() < 0 && pos.getZ() < 0) { pos2 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()-0.5); } if(pos.getX() > 0 && pos.getZ() > 0) { pos2 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() < 0 && pos.getZ() > 0) { pos2 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() > 0 && pos.getZ() < 0) { pos2 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()-0.5); } NBTTagCompound subTag = stack.getTagCompound(); subTag.setDouble("pos2x", pos2.xCoord); subTag.setDouble("pos2y", pos2.yCoord); subTag.setDouble("pos2z", pos2.zCoord); subTag.setBoolean("hasSetPos2", true); stack.setTagCompound(subTag); if(!world.isRemote) { player.addChatMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE + "Set Pos2 at X: " + (int)pos2.xCoord + ", Y: " + (int)pos2.yCoord + ", Z: " + (int)pos2.zCoord)); } world.scheduleBlockUpdate(pos, world.getBlockState(pos).getBlock(), 0, 1); return EnumActionResult.PASS; } @Override public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer playerIn, EnumHand hand) { if(stack.getTagCompound().getBoolean("hasSetPos1") && stack.getTagCompound().getBoolean("hasSetPos2") && playerIn.isSneaking()) { NBTTagCompound nbt = stack.getTagCompound(); Vec3d setPos1 = new Vec3d(nbt.getDouble("pos1x"), nbt.getDouble("pos1y"), nbt.getDouble("pos1z")); Vec3d setPos2 = new Vec3d(nbt.getDouble("pos2x"), nbt.getDouble("pos2y"), nbt.getDouble("pos2z")); difference = setPos1.subtractReverse(setPos2).normalize(); posToPlaceBlock = setPos1; if(setPos1.xCoord > 0 && setPos2.xCoord < 0 || setPos1.xCoord < 0 && setPos2.xCoord > 0 || setPos1.zCoord > 0 && setPos2.zCoord < 0 || setPos1.zCoord < 0 && setPos2.zCoord > 0 || setPos1.yCoord > 256 || setPos2.yCoord > 256 || setPos1.yCoord < 0 || setPos2.yCoord < 0) { if(!world.isRemote) { playerIn.addChatComponentMessage(new TextComponentString(TextFormatting.RED +"Don't try to create lines from positive X to negative X, Z, or Y")); } } else { if(compare(setPos1, setPos2)) { pos1 = null; if(!world.isRemote) { world.setBlockState(new BlockPos((int)setPos1.xCoord, (int)setPos1.yCoord, (int)setPos1.zCoord), Block.getBlockFromName(stack.getTagCompound().getString("material")).getStateFromMeta(stack.getTagCompound().getInteger("damage")), 2); BlockPos pos2 = new BlockPos((int)setPos1.xCoord, (int)setPos1.yCoord, (int)setPos1.zCoord); world.scheduleBlockUpdate(pos2, world.getBlockState(pos2).getBlock(), 0, 1); } pos2 = null; } else { while (!compare(setPos1, setPos2)) { posToPlaceBlock = posToPlaceBlock.add(difference); if(!world.isRemote) { world.setBlockState(new BlockPos((int)posToPlaceBlock.xCoord, (int)posToPlaceBlock.yCoord, (int)posToPlaceBlock.zCoord), Block.getBlockFromName(stack.getTagCompound().getString("material")).getStateFromMeta(stack.getTagCompound().getInteger("damage")), 2); } } } } } return new ActionResult(EnumActionResult.SUCCESS, stack); } public boolean compare(Vec3d setPos1, Vec3d setPos2) { if(Math.abs(setPos1.xCoord) <= Math.abs(setPos2.xCoord) && Math.abs(setPos1.zCoord) <= Math.abs(setPos2.zCoord)) { return Math.abs(posToPlaceBlock.xCoord) >= Math.abs(setPos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) >= Math.abs(setPos2.zCoord); } else if(Math.abs(setPos1.xCoord) >= Math.abs(setPos2.xCoord) && Math.abs(setPos1.zCoord) >= Math.abs(setPos2.zCoord)) { return Math.abs(posToPlaceBlock.xCoord) <= Math.abs(setPos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) <= Math.abs(setPos2.zCoord); } else if(Math.abs(setPos1.xCoord) <= Math.abs(setPos2.xCoord) && Math.abs(setPos1.zCoord) >= Math.abs(setPos2.zCoord)) { return Math.abs(posToPlaceBlock.xCoord) >= Math.abs(setPos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) <= Math.abs(setPos2.zCoord); } else if(Math.abs(setPos1.xCoord) >= Math.abs(setPos2.xCoord) && Math.abs(setPos1.zCoord) <= Math.abs(setPos2.zCoord)) { return Math.abs(posToPlaceBlock.xCoord) <= Math.abs(setPos2.xCoord) && Math.abs(posToPlaceBlock.zCoord) >= Math.abs(setPos2.zCoord); } else { return true; } } /* public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) { World world = player.worldObj; if(player.isSneaking()) { mat = world.getBlockState(pos); NBTTagCompound subTag = itemstack.getTagCompound(); subTag.setString("material", mat.getBlock().getRegistryName().getResourceDomain() + ":" + mat.getBlock().getRegistryName().getResourcePath()); subTag.setInteger("damage", mat.getBlock().getMetaFromState(mat)); Block block = (Block)Block.REGISTRY.getObject(new ResourceLocation(itemstack.getTagCompound().getString("material"))); itemstack.setTagCompound(subTag); if(!world.isRemote) { player.addChatComponentMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE +"Material set to: " + net.minecraft.util.text.translation.I18n.translateToLocal(net.minecraft.util.text.translation.I18n.translateToLocal(block.getLocalizedName())))); } world.scheduleBlockUpdate(pos, world.getBlockState(pos).getBlock(), 0, 1); } else { if(pos.getX() < 0) { pos1 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()); } if(pos.getX() > 0) { pos1 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()); } if(pos.getZ() < 0) { pos1 = new Vec3d(pos.getX(), pos.getY(), pos.getZ()-0.5); } if(pos.getX() > 0) { pos1 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() < 0 && pos.getZ() < 0) { pos1 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()-0.5); } if(pos.getX() > 0 && pos.getZ() > 0) { pos1 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() < 0 && pos.getZ() > 0) { pos1 = new Vec3d(pos.getX()-0.5, pos.getY(), pos.getZ()+0.5); } if(pos.getX() > 0 && pos.getZ() < 0) { pos1 = new Vec3d(pos.getX()+0.5, pos.getY(), pos.getZ()-0.5); } NBTTagCompound subTag = itemstack.getTagCompound(); subTag.setDouble("pos1x", pos1.xCoord); subTag.setDouble("pos1y", pos1.yCoord); subTag.setDouble("pos1z", pos1.zCoord); subTag.setBoolean("hasSetPos1", true); itemstack.setTagCompound(subTag); if(!world.isRemote) { player.addChatComponentMessage(new TextComponentString(TextFormatting.LIGHT_PURPLE +"Set Pos1 at X: " + (int)pos1.xCoord + ", Y: " + (int)pos1.yCoord + ", Z: " + (int)pos1.zCoord)); } world.scheduleBlockUpdate(pos, world.getBlockState(pos).getBlock(), 0, 1); } return true; } */ @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { Block block = Block.getBlockFromName(stack.getTagCompound().getString("material")); IBlockState state = block.getStateFromMeta(stack.getTagCompound().getInteger("damage")); ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state)); tooltip.add("Draws a straight line from two points"); tooltip.add("Material: " + blockStack.getDisplayName()); tooltip.add("Pos1 = X: " + stack.getTagCompound().getDouble("pos1x") + ", Y: " + stack.getTagCompound().getDouble("pos1y") + ", Z: " + stack.getTagCompound().getDouble("pos1z")); tooltip.add("Pos2 = X: " + stack.getTagCompound().getDouble("pos2x") + ", Y: " + stack.getTagCompound().getDouble("pos2y") + ", Z: " + stack.getTagCompound().getDouble("pos2z")); } } BlockGravelGrass: package tschipp.buildingblocks.blocks; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; import tschipp.buildingblocks.BBMod; import tschipp.buildingblocks.items.BBItems; 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.client.renderer.color.IBlockColor; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; 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; public class BlockGravelGrass extends Block implements IBlockColor { public BlockGravelGrass(Material materialIn) { super(materialIn, MapColor.STONE); this.blockHardness = 0.8F; this.blockResistance = 3.5F; this.setSoundType(SoundType.PLANT); this.setUnlocalizedName("gravelGrass"); this.setCreativeTab(BBMod.buildingBlocks); this.setHarvestLevel("shovel", 0); } @Override @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) { return 0; } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } @Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) { return true; } @Override public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { List<ItemStack> drops = new ArrayList<ItemStack>(); drops.add(new ItemStack(Blocks.DIRT, 1)); drops.add(new ItemStack(BBItems.pebbles, 1)); return drops; } }
  23. Ah I see, makes sense While this is true, that's not actually what that does. The "shade" tag is what controls whether the block's model itself uses lighting information or is fullbright (i.e. even in a pitch dark room you can still see it, as if the block itself was "glowing").
×
×
  • Create New...

Important Information

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