Jump to content

Legenes

Members
  • Posts

    139
  • Joined

  • Last visited

Everything posted by Legenes

  1. Hi! I have a question, how can I detect, if the player used right, or left-click in this event? Thanks!
  2. Thank you very much! Now my values are updated when I change them, and they get sent to the client as well. Now the only thing is still in my post above, but I'll think about it a bit more.
  3. Post your code, where the error appeared.
  4. I still didn't manage to make my block's outline stable, but now I have another problem. I get the tile entity with world.getTileEntity, which should be fine, but when I try to access any of its values, they're all 0. I'm accessing them by using ((MyTileEntityType)TileEntity).ExampleVariable. I tried to access its inventory, its energy handler, and even some basic integer values inside it, they aren't null, but they don't have their real values in them, whilst their nbt has those values correctly. Any ideas? I'm sitting on this thing for like a day now...
  5. I recommend this tutorial for you, first: https://www.youtube.com/watch?v=DgY6kKf5rGU&list=PLmaTwVFUUXiBKYYSyrv_uPPoPZtEsCBVJ By the way... in the previous topic, I told you how what .food(MYFOOD) means. The new Item.Properties() is a builder, and you set each of its values by telling it .<the thing I want to set>(<what I want it to be>). For example, this piece of code: new Item.Properties().addToolType(ToolType.PICKAXE, 3) makes your item a pickaxe that has a level of iron (Don't use it this way, it's only going to mine everything that needs at least an iron pickaxe, it will be slow as you hand, to create proper tools use the PickaxeItem, AxeItem and the other classes). Another example, this piece of code: new Item.Properties().maxStackSize(16) makes it, so that your item stacks in 16, instead of 64. These builders are easy to use. If you want to set multiple things, you continue the line, like this: new Item.Properties().maxStackSize(16).food(Foods.APPLE) This makes your item stack in 16, AND make it a food that has the same values as an apple. This Foods.APPLE is the same that I made in the previous topic, named MYFOOD. It could be named everything you want, BLUEBERRY, PEAR, GRAPE, it doesn't matter. It only sets the values of the food itself. It's used like this in a really unrealistic example: public class ModClass { // The foods are declared with a builder as well. Here I set it like this: new Food.Builder().<Always edible>().<Fast>().<Meat>().<How much it fills>(8).<How long it lasts>(3.0f).build() // You won't always need to close your line with .build(). Some classes need it, some not. public static final Food ExampleFood = new Food.Builder().setAlwaysEdible().fastToEat().meat().hunger(8).saturation(3.0f).build() // Your register event, I don't know how you made your one. public static void RegisterItems(final RegistryEvent.Register<Item> event) { event.getRegistry().register(new BasicItem(new Item.Properties().group(/*item group, you need to set this, here: ItemGroup.FOOD */).food(/*anything you made, here: ExampleFood */), name)); } } If you still don't understand how it works after this, it means you can't program in java / with any version of Forge at all. This syntax is really basic and used almost everywhere.
  6. So I managed to make my rendering almost perfect. It renders what I want, and how I want it to. It works from all sides now. My wrench is currently the Diamond Hoe for testing, of course, I'll change that. My only problem is that the Y-axis isn't affected by the partial ticks, and it makes my outline fuzz while flying / while the sneak animation goes on. Any ideas what to add so it's stable and not fuzzy?
  7. I was able to make it appear at the right place, but it's still only visible from 3 sides, and when I sneak its position gets lower than it should be. Any ideas?
  8. You have a class where you store all your block's and item's variables. You declare a "food" variable as I showed you here. Then, when you register them, by default in your main mod class, at the event registry, you add this food variable, as the food property. In THIS example, the food variable's name is MYFOOD.
  9. So... I have some kind of a rendering going on, but for some reason, my outline only renders if I look at the block from 2 specific sides, and the outline's Y value is always the player's height. public class ModSelectionBoxes { public static boolean Draw(DrawBlockHighlightEvent event) { if(event.getTarget().getType() == RayTraceResult.Type.BLOCK) { BlockPos blockPos = new BlockPos(event.getTarget().getHitVec()); BlockState blockState = Minecraft.getInstance().world.getBlockState(blockPos); TileEntity tileEntity = Minecraft.getInstance().world.getTileEntity(blockPos); if (tileEntity instanceof BatteryTile) { ClientPlayerEntity player = Minecraft.getInstance().player; GlStateManager.enableBlend(); GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.lineWidth(2.5F); GlStateManager.disableTexture(); GlStateManager.depthMask(false); AxisAlignedBB box1 = new AxisAlignedBB(blockPos.getX() + 0.0f, blockPos.getY() + 0.0f, blockPos.getZ() + 0.0f, blockPos.getX() + 1.0f, blockPos.getY() + 1.0f, blockPos.getZ() + 1.0f); if (blockState.getMaterial() != Material.AIR && event.getInfo().getRenderViewEntity().getEntityWorld().getWorldBorder().contains(blockPos)) { float partialTicks = event.getPartialTicks(); double d3 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks; double d4 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks; double d5 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks; WorldRenderer.drawSelectionBoundingBox(box1.grow(0.0020000000949949026D).offset(-d3, -d4, -d5), 1.0F, 1.0F, 1.0F, 1.0F); } GlStateManager.depthMask(true); GlStateManager.enableTexture(); GlStateManager.disableBlend(); return true; } } return false; } } By the way... this is how I call it: @SubscribeEvent public static void onBlockHighlight(final DrawBlockHighlightEvent event) { event.setCanceled(ModSelectionBoxes.Draw(event)); } Any idea how to fix it?
  10. You copied it to the .minecraft/mods folder? The file you copied is a .jar file? Have you tried to use the latest version of forge instead of the recommended? ( Currently: 28.1.96 ) Where did you get the mod from? You always should use curseforge for getting mods.
  11. I want to make myself a wrench, so when I click my machines side with it, it sets it to closed, normal, out, or in, I'm able to implement that. What I want to do is to create the same outline but white, and then to make simple line symbols on the sides of the block. I may want to make it so every side of the highlight is visible, not just what I should see.
  12. That's the Food type that we just created in my example.
  13. Okay, I moved it to the bus=Mod.EventBusSubscriber.Bus.FORGE bus, now it gets called. So... how should I draw in it? The only thing I managed to do is to hide the outline of my own block.
  14. First, you need to create a food type: public static final Food MYFOOD = (new Builder()).hunger(4).saturation(0.3F).build(); Then, when you register an item, you include it in its properties: event.getRegistry().register("myfood", new Item((new Item.Properties().food(MYFOOD)).group(ItemGroup.FOOD))); It's that easy.
  15. Hi! As the title says, I want to make a custom bounding box for my block. However, when I try to register my event, it doesn't get called. What did I do wrong? This is in my main class: @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { // Other events // ... @SubscribeEvent public void onBlockHighlight(final DrawBlockHighlightEvent event) throws Exception { // For testing event.setCanceled(true); // Currently empty ModSelectionBoxes.Draw(event); } } If my method finally gets called, what should I use to draw my bounding box?
  16. Finally, here's my working implementation: private final IIntArray fields = new IIntArray() { public int get(int index) { switch(index) { case 0: return MachineBlockTile.this.counter; case 1: return MachineBlockTile.this.burnTime; default: return 0; } } public void set(int index, int value) { switch(index) { case 0: MachineBlockTile.this.counter = value; break; case 1: MachineBlockTile.this.burnTime = value; break; } } public int size() { return 2; } }; Thanks for the help!
  17. It is, but I get the point. import net.minecraft.util.IntArray;
  18. Okay, so I need to implement my own IIntArray, I'm so dumb, sry. I didn't look at the AbstractFurnaceTileEntity.
  19. Well... I have this only: private IIntArray fields = new IntArray(2); This is in my TileEntity's class.
  20. It super weird... the values are only updated when the GUI is opened, after that it doesn't track them.
  21. I figured it out, and now I use the correct method, but thanks anyway ☺️. (It works.)
  22. I tried to pass an IIntArray as the vanilla container does, with the values I need, I save it in a variable and I use this.trackIntArray(), but it only updates when I open the block. Am I missing something? private IIntArray fields; public MachineBlockContainer(int id, World clientWorld, BlockPos pos, PlayerInventory playerInv, PlayerEntity player, IIntArray Fields) { super(MachineBlock_Container, id); //* other stuff *// fields = Fields; //* other stuff *// this.trackIntArray(Fields); }
  23. I found out that it's most likely that I need to use the net.minecraftforge.common.ForgeHooks.getBurnTime() instead.
  24. I found this in the IForgeItem class: /** * @return the fuel burn time for this itemStack in a furnace. Return 0 to make * it not act as a fuel. Return -1 to let the default vanilla logic * decide. */ default int getBurnTime(ItemStack itemStack) { return -1; } I don't know if the "vanilla" logic is failing, or I need to use something else, but this is weird.
  25. Sorry, I may have said something incorrectly. This block is like a furnace but without an output. I want to be able to see how much more the item inside is going to last as a fuel, like the little flame in the furnace. That depends on the currently burnt item's burn time (where the exampleItemStack.getBurnTime() always returns -1 for some reason) and how many ticks did I burn it for. I want to sync the the little flame if you get what I mean.
×
×
  • Create New...

Important Information

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