Jump to content

MSpace-Dev

Members
  • Posts

    180
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MSpace-Dev

  1. You work it out like this: blockId + (metaData * 4096) For example: 412 + (0 * 4096) = 412 therefore, the blockcrack ID will be 412. So, my question is how do I get the number ID of my block? There is no like ".getBlockID" type thing
  2. Oh, wow. I am such an idiot. I was under the impression that I was running my game on debug mode! All changes I made weren't actually going through. It's working now =p Anyways, new problem. What params do I use in the spawnParticle to change the blockcrack ID? I know in commands, you type a specific number, but I'm not sure where to put that number in the spawnParticle() method.
  3. (Debug mode wasn't on) Re-added if(worldIn.isRemote) {}
  4. Hey everyone, So, I am trying to make a block look like it gets broken when you right click it, without destroying the actual block. I am using playSound() and spawnParticle() to achieve this. But, for some reason, these are not working. I have never used these methods before, so I can't really figure out the reason why they're not working. I know for a fact that they are running because the line, infused_log.carveAmount++ , is working. Here is the method: @Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(worldIn.getTileEntity(pos) != null) { if (worldIn.getTileEntity(pos) instanceof TileEntityInfusedLog) { TileEntityInfusedLog infused_log = (TileEntityInfusedLog) worldIn.getTileEntity(pos); worldIn.playSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_WOOD_BREAK, SoundCategory.BLOCKS, 1000.0f, 1.0f, false); worldIn.spawnParticle(EnumParticleTypes.CLOUD, pos.getX(), pos.getY() + 1.0D, pos.getX(), 0.0, 0.0, 0.0, new int[0]); infused_log.carveAmount++; } } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } Thanks!
  5. Yup, that was the problem! Alright. Kudos to you guys. Liked every single reply, for ya reputation =) So happy that I can carry on now! Thank you!
  6. Awesome, finally got that working. Geez, sorry about that... Now that that is out of the way, back to my main question. I have got this so far: MONSTER TOTEMS EVENT HANDLER: @Mod.EventBusSubscriber public class MonsterTotemsEventHandler { @SubscribeEvent public void mobSpawn(LivingSpawnEvent e) { Utils.getLogger().info("MOB SPAWNED!!!"); BlockPos eventPos = e.getEntity().getPosition(); Iterable<BlockPos> blocks = BlockPos.getAllInBox(eventPos.add(-100.0f, -100.0f, -100.0f), eventPos.add(100.0f, 100.0f, 100.0f)); for (BlockPos pos : blocks) { World world = e.getWorld(); if(world.getTileEntity(pos) != null) { if (world.getTileEntity(pos) instanceof TileEntityTotemBase) { e.getEntity().setFire(100); Utils.getLogger().info("MOB CLOSE TO TILE ENTITY!!!"); } } } } } Anyways, long-story-short, none of the logger messages get outputted to the console, when a mob spawns during night time. Which means this event handler isn't working. MAIN CLASS: (postInit()) public void postInit(FMLPostInitializationEvent event){ proxy.postInit(event); MinecraftForge.EVENT_BUS.register(new MonsterTotemsEventHandler()); } EDIT: I need @Mod.EventHandler on top... don't I...?
  7. I've done that. Still get the same error. MAIN CLASS: public void init(FMLInitializationEvent event){ proxy.init(event); ModTileEntities.init(); } MOD TILE ENTITIES: public class ModTileEntities { @Mod.EventHandler public static void init(){ GameRegistry.registerTileEntity(TileEntityTotemBase.class, "totem_base_i_te"); } }
  8. I call that init() function in ModTileEntities from the main class.
  9. So, I'm getting this error when in-game. A TileEntity type io.github.mspacedev.tiles.TileEntityTotemBase has throw an exception trying to write state. It will not persist. Report this to the mod author java.lang.RuntimeException: class io.github.mspacedev.tiles.TileEntityTotemBase is missing a mapping! Even though, I have reason to believe, that I have mapped the Tile Entity. (Again, new to this) BLOCK CLASS: public class BlockTotemBase extends BlockBase implements ITileEntityProvider { public BlockTotemBase(String name, Material materialIn) { super(name, materialIn); } @Nullable @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityTotemBase(); } } TILE ENTITY TOTEM BASE: public class TileEntityTotemBase extends TileEntity { // Empty } MAIN CLASS INIT: (removed a bunch of unnecessary code, that does not need to be seen) @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION ) public class MonsterTotems { public static void init(FMLInitializationEvent event){ proxy.init(event); ModTileEntities.init(); } } MOD TILE ENTITIES: public class ModTileEntities { public static void init(){ GameRegistry.registerTileEntity(TileEntityTotemBase.class, "totem_base_i"); } } Btw, I register the BlockTotemBase with the same id as the Tile Entity.
  10. Ah, of course! Man, you have been a huge help. Gonna give that a shot!
  11. Awesome, that has helped a lot! Just one thing, I am new to Tile Entities. So, I am not sure how to reference the Tile Entity that I'm looking for. I have "bound" the Tile Entity to the block, using the createTileEntity() method. From here, do I just check for the blockstate, or do I search for the tile entity? Here is my code so far @Mod.EventBusSubscriber public class MonsterTotemsEventHandler { @SubscribeEvent public void mobSpawn(LivingSpawnEvent e) { BlockPos eventPos = e.getEntity().getPosition(); Iterable<BlockPos> blocks = BlockPos.getAllInBox(eventPos.add(-10.0f, -10.0f, -10.0f), eventPos.add(10.0f, 10.0f, 10.0f)); for (BlockPos pos : blocks) { World world = e.getWorld(); if(world.getTileEntity(pos) == ){ // Not sure what to put here << // execute code } } } }
  12. Hello everyone, So, I am making a block that needs to check when any mobs spawn around it. What I want to do is when this LivingSpawnEvent happens, is create an AABB at this event's position, and CHECK if my tile entity is within this box. I have no idea how to do this, and I've tried scouring the web, with no success. I'm also not sure how to create my AABB at this specific event's coords. This is what I have so far. EVENT HANDLER: @Mod.EventBusSubscriber public class MonsterTotemsEventHandler { @SubscribeEvent public void mobSpawn(LivingSpawnEvent e) { BlockPos eventPos = e.getEntity().getPosition(); AxisAlignedBB eventAABB = new AxisAlignedBB(10.0f, 10.0f, 10.0f, 10.0f, 10.0f, 10.0f); // if (tile entity is in AABB) { // execute code here //} } } Thanks!
  13. I have already tried that, sadly it doesn't work
  14. Still having trouble with this. Can't find a solution.
  15. So, I am trying to get the width and height of my current screen size, by extending GuiScreen. Though, for some reason, it's returning 0 for this.width and this.height. Yet when I made an Openable GUI extend GuiScreen, it returns the correct values. I need the screen width and height to put my custom health bar in the bottom right of the screen. I've tried to call initGui() and setWorldAndResolution() to see if they'd get the width and height, but with no avail. public class GuiOverlay extends GuiScreen { private final ResourceLocation bar = new ResourceLocation(Reference.MODID, "textures/blocks/hp_bar.png"); private final int bar_width = 102, bar_height = 8, hp_height = 6; private int hp_width = 100; @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent event){ Minecraft mc = Minecraft.getMinecraft(); mc.renderEngine.bindTexture(bar); Utils.getLogger().info("Width: " + this.width); // returns 0 Utils.getLogger().info("Height: " + this.height); // returns 0 drawTexturedModalRect(width - bar_width, height - bar_height, 0, 0, bar_width, bar_height); // Off the screen due to width/height = 0 drawTexturedModalRect(width - bar_width, height - bar_height, 1, bar_height + 1, hp_width, hp_height); // Off the screen due to width/height = 0 mc.renderEngine.bindTexture(ICONS); } } Any ideas?
  16. I didn't. Just wanted to make that clear for anyone else having the problem.
  17. Awesome, got it working! mc = Minecraft.getMinecraft(); mc.renderEngine.bindTexture(ICONS); Just had to put that at the end.
  18. Hey eveyone, So soething weird is happening. I am trying to render a GameOverlayGUI over my screen. I have created code that makes a custom health bar using widths and getting the player's health. My custom bar works perfectly, but it seems that mc.renderEngine.bindTexture(bar) is overwriting the game's default GameOverlayGUI. Any help is appreciated! public class GuiOverlay extends Gui { private final ResourceLocation bar = new ResourceLocation(Reference.MODID, "textures/gui/hp_bar.png"); private final int bar_width = 102, bar_height = 8, hp_height = 6; private int hp_width = 100; @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent event){ Minecraft mc = Minecraft.getMinecraft(); mc.renderEngine.bindTexture(bar); float playerHealth = mc.player.getHealth(); hp_width = (int)playerHealth * 5; drawTexturedModalRect(0, 0, 0, 0, bar_width, bar_height); drawTexturedModalRect(1, 1, 1, bar_height + 1, hp_width, hp_height); } } In-Game: Texture file: (hp_bar.png)
  19. Hey everyone, So I am trying to render one of my ModBlocks on a custom GUIScreen. The problem is, I have it rendering, but it extremely dark in the GUI. Rendering items looks fine, but the block doesn't. I have tried using standard Minecraft blocks, such as stone or obsidian, but still the same thing. Here are the important bits of my code. (PICTURE BELOW) @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); ItemStack icon3 = new ItemStack(ModBlocks.tin_block); GlStateManager.pushMatrix(); { GlStateManager.translate(centerX + guiWidth / 2 - 16, centerY + guiHeight / 2 + 24, 0); GlStateManager.scale(2, 2, 2); Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(icon3, 0, 0); } GlStateManager.popMatrix(); drawTooltip(icon3.getTooltip(mc.player, false), mouseX, mouseY, centerX, centerY + 40, 16, 16, guiWidth, guiHeight); } private void drawTooltip(List<String> tooltip, int mouseX, int mouseY, int posX, int posY, int itemWidth, int itemHeight, int guiWidth, int guiHeight){ if(mouseX >= posX + guiWidth / 2 - itemWidth && mouseX <= posX + guiWidth / 2 + itemWidth && mouseY >= posY + guiHeight / 2 - itemHeight && mouseY <= posY + guiHeight / 2 + itemHeight) { drawHoveringText(tooltip, mouseX, mouseY); } } (Indents messed up...) Picture:
  20. Can I create the AABB around the tile entity's location, and then perform actions on entities within that AABB? I noticed a method called getEntitiesWithinAABB() So I'm guessing I can iterate through that list, and perform actions on the mob that I'm looking for within this iteration, correct?
  21. Oh, I know how to register a Tile Entity. Thanks for trying to help though! * My actual question was how can I execute events in a Radius from a Tile Entity?
  22. Oh, I was under the impression that when you placed a block in the world, it would create a new instance of the object, and each one would have separate pos variables. Thanks for clearing that up. As for the checking radius thing? Do You have any clue how to do that from a Tile Entity?
  23. Hey again, So I am trying to get the LivingEventSpawn.CheckSpawn event to run within my block class. I'm still quite new to events, and I'm not even sure of you can get events to run inside a block class... but the reason I need to run it here is so that I can check distances from this block's location. Also, I want to ask how I can check entities within a radius from my block. I've looked all around the web and can't find anything too useful. @Mod.EventBusSubscriber public class BlockTorch extends BlockBase { protected static final AxisAlignedBB TORCH_AABB = new AxisAlignedBB(0.3125, 0.0D, 0.3125D, 0.6875D, 0.8125D, 0.6875D); protected static BlockPos pos = null; public BlockTorch(String name, Material materialIn) { super(name, materialIn); this.setHardness(0.2f); this.setHarvestLevel("axe", 0); this.setSoundType(SoundType.WOOD); this.setLightLevel(1.0f); } @SubscribeEvent public void blockMobSpawning(LivingSpawnEvent.CheckSpawn event){ float distance = event.getEntity().getDistanceToEntity(event.getEntity()); Utils.getLogger().info("Distance to spawned Entity: " + distance); } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { this.pos = pos; Utils.getLogger().info("Position Initialized: " + pos); super.onBlockAdded(worldIn, pos, state); } } (Not sure why the indents messed up)
  24. Perfect! I knew it was something like that. It seems to be working perfectly now. Thanks!
×
×
  • Create New...

Important Information

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