Jump to content

fuzzybat23

Members
  • Posts

    131
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

fuzzybat23's Achievements

Creeper Killer

Creeper Killer (4/8)

2

Reputation

  1. This only pulls the total number of villagers, adult and child combined. WorldServer worldServer = DimensionManager.getWorld(player.dimension); Village village = worldServer.getVillageCollection().getNearestVillage(player.getPosition(), 5000); int numVillagers = village.getNumVillagers(); Is there a way to split this into the number of adult villagers and the number of child villagers?
  2. IntelliJ gave me a warning that bus in FMLCommonHandler.instance().bus().register(instance); is deprecated. Is there something else I should be using in the place of that line of code?
  3. Right now, I'm trying to get at least the position of the nearest village, say within a radius of x, which at the moment is 10,000. I scraped this together, but it's firing a null exception when trying to populate my village variable. Any pointers? package com.fuzzybat23; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.village.Village; import net.minecraft.village.VillageCollection; import net.minecraft.world.WorldServer; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.ModMetadata; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @net.minecraftforge.fml.common.Mod(modid = "villageinfo", version = "1.0", clientSideOnly = true, acceptedMinecraftVersions = "[1.12, 1.13]") public class VillageInfo { @net.minecraftforge.fml.common.Mod.Instance("VillageInfo") public static final String MODID = "villageinfo"; @Mod.Instance public static VillageInfo instance; public static final Logger logger = LogManager.getLogger(); @Mod.EventHandler @SideOnly(Side.CLIENT) public void preInit(FMLPreInitializationEvent event) { ModMetadata data = event.getModMetadata(); data.autogenerated = false; data.version = "1.0"; data.name = "Village Info"; data.description = "Displays nearby village info."; data.authorList.add("Fuzzybat23"); data.url = "https://minecraft.curseforge.com/members/fuzzybat23/projects"; data.credits = "Bats everywhere."; data.logoFile = "assets/logo/logo.png"; FMLCommonHandler.instance().bus().register(instance); MinecraftForge.EVENT_BUS.register(instance); } @SubscribeEvent public void onRenderTextOverlay(RenderGameOverlayEvent.Text event) { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.player; if(mc.gameSettings.showDebugInfo) getVillageData(event, player); } private void getVillageData(RenderGameOverlayEvent.Text event, EntityPlayer player) { if(player == null) return; WorldServer worldServer = DimensionManager.getWorld(player.dimension); VillageCollection villageCollection = null; Village village = villageCollection.getNearestVillage(player.getPosition(),10000); event.getLeft().add("Test1: " + worldServer.toString()); if(village != null) event.getLeft().add("Test2: " + village.toString()); } }
  4. I was rooting around through BlockDoor.java looking for something unrelated and I saw a few snippets that sparked inspiration. Ran and tested this and it seems to work just fine public static boolean isDoubleDoor(World world, BlockPos pos, EnumFacing offsetPos) { String RIGHT = "RIGHT"; String LEFT = "LEFT"; boolean flag = false; IBlockState targetState = world.getBlockState(pos); Block targetBlock = targetState.getBlock(); IBlockState offsetState = world.getBlockState(pos.offset(offsetPos)); Block offsetBlock = offsetState.getBlock(); //Get correct blockState, including hinge, for targeted door. if(targetState.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER) if(targetState.getBlock() == targetBlock) targetState = world.getBlockState(pos.up()); BlockDoor.EnumHingePosition targetHinge = targetState.getValue(BlockDoor.HINGE); //get correct blockState, including hinge, for offset door. if(offsetState.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER) if(offsetState.getBlock() == offsetBlock) offsetState = world.getBlockState(pos.offset(offsetPos).up()); BlockDoor.EnumHingePosition offsetHinge = offsetState.getValue(BlockDoor.HINGE); logger.info("(targetHinge)(name)" + targetHinge.name() + "=? (offsetHinge)(name)" + offsetHinge.name() ); if(((targetHinge.name() == RIGHT) && (offsetHinge.name() == LEFT)) || ((targetHinge.name() == LEFT) && (offsetHinge.name() == RIGHT))) flag = true; return flag; } First checks if it's the lower half of the door and if so, resets the blockState to the upper half. Then it grabs the side of the door the hinge is on and checks if hinges on the two doors are on the opposite outer sides.
  5. I forgot to add @net.minecraftforge.fml.common.Mod just before the public class HorseInfo Anyway, it does seem to work.
  6. Or I could be an idiot and realize it isn't even loading the mod when I run the client in IntelliJ..
  7. I added that just after where I declared my mc and player variables, just before entering the first if statement. Nothing happened still. It's like it isn't even subscribing to the RenderGameOverlayEvent.Text properly.
  8. I added some logger bits to help debug. It doesn't seem to be registering when it enters the debug screen. The horse stuff might actually work, but it doesn't seem to be even getting that far. It should be listening for the RenderGameOverlayEvent, when text is drawn on the screen, and check if it's the debug info being shown. @SideOnly(Side.CLIENT) @SubscribeEvent public void onLookHorse(RenderGameOverlayEvent.Text event) { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = Minecraft.getMinecraft().player; if(mc.gameSettings.showDebugInfo) { logger.info("Debug screen successfully entered.."); if(mc.objectMouseOver != null && mc.objectMouseOver.entityHit instanceof EntityHorse ) { logger.info("objectMouseOver is a horse.."); getHorseInfo(event, player, (EntityHorse)mc.objectMouseOver.entityHit); } } }
  9. Basically, I'm trying to determine if the entity the player is currently looking at is a horse. Does this sound about right? @SubscribeEvent public void isHorse(RenderGameOverlayEvent.Text event) { Minecraft mc = Minecraft.getMinecraft(); If(mc.gameSettings.showDebugInfo) if(mc.objectMouseOver != null && mc.objectMouseOver.entityHit instanceof EntityHorse) { //Do stuff if it's a horse } }
  10. Oh crap, that code is from a bukkit plugin x.x I just decompiled it again and checked the imports. Dunno how I missed that before
  11. You said that the hinge is on the top half of the door, and the hinge side is used to determine if the doors face each other, right? I found this in an older mod, but I'm not sure what the updated code would look like. I know that this is definitely outdated, though, but from what I can tell it did exactly that. Determined if it was the upper or lower part of the door being interacted with and set a door variable to the top portion. Block blockBottom = block.getRelative(BlockFace.DOWN); Block blockTop = block.getRelative(BlockFace.UP); Block blockNearBottom = blockBottom.getRelative(BlockFace.NORTH); Block blockNearTop = blockTop.getRelative(BlockFace.NORTH); Door door = (Door)block.getState().getData(); Door doorTop = (Door)block.getState().getData(); Door doorBottom = (Door)block.getState().getData(); Door doorNearBottom = (Door)block.getState().getData(); Door doorNearTop = (Door)block.getState().getData(); if (door.isTopHalf()) { blockTop = block; doorTop = door; doorBottom = (Door)blockBottom.getState().getData(); } else { blockBottom = block; doorBottom = door; doorTop = (Door)blockTop.getState().getData(); } I don't think getRelative exists anymore, and Door isn't a type anymore, it's now BlockDoor.
  12. Also, does this look about right as far as looping through the enumfacing? Passing in the right click event to generate the new target block, using offset(facing) to offset targetblock from block. public void checkForDoors(PlayerInteractEvent.RightClickBlock event, Block block) { for(EnumFacing facing : EnumFacing.HORIZONTALS) { Block targetblock = event.getWorld().getBlockState(event.getPos().offset(facing)).getBlock(); if(targetblock == block) //Do stuff if block that is offset to original block is same as original block } }
  13. Mmmm, so instead of this: public static boolean isWoodenDoor(Block block) { if(block == Blocks.ACACIA_DOOR || block == Blocks.BIRCH_DOOR || block == Blocks.DARK_OAK_DOOR || block == Blocks.JUNGLE_DOOR || block == Blocks.OAK_DOOR || block == Blocks.SPRUCE_DOOR) return true; return false; } Use something like this? public static boolean isWoodenDoor(IBlockState state) { if(state.getBlock() instanceof BlockDoor && state.getMaterial() == Material.WOOD) return true; return false; }
  14. Second phase of what I'm doing is determining if an adjacent block contains a door. In other words, two doors side by side. Then figure out if those doors are mirror to each other, and when one of the two is right clicked, it will send a door toggle to the other opening it automatically. Say you're standing in the world facing north and you place a door in front of you. It's hinges are facing east. You place a door next to it one block to the west. It's hinges are facing west. You have a set of proper double doors now.
×
×
  • Create New...

Important Information

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