Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Beetle90

Members
  • Posts

    10
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Recent Profile Visitors

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

Beetle90's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Resolved!! Just wanted to chime back in here and let anyone else who might have this issue know that the newer versions of Community IntelliJ has the reload changed classes section now under the Run Tab and without a hotkey. That's what I was looking for!
  2. Hey guys, I'm sorry if this isn't the right area to ask for help regarding this but I'm at a loss. I just migrated from Eclipse to IntelliJ because I wanted to utilize the real-time compiling for testing purposes. However, unlike all videos and tutorials I've ran through the Build tab only shows 'Build Project', "Build Module", etc. unlike the Make Project that I'm looking for in order to adjust variables while the client is still open. This may be irrelevant, but I'm getting a warning message regarding an unindexed remote maven repository. Here's a picture of said warning. I appreciate any and all help! Thank you guys!
  3. Hey guys, I've been reading and watching a lot of tutorials on custom GUIs. What I'm looking for hasn't exactly been addressed in anything I've searched for yet though. Similar to how FTB utilities has a nice 'claim chunks' icon that appears to the left of the inventory GUI when a player presses 'E', I'd like to have something similar show up above the player's inventory GUI. Can someone point me in the right direction regarding how to render an interactive Icon on top of the inventory GUI? I'd like to ideally have this be compatible with other mods and no create icon overlapping, though I'm not sure this can be done. Thank you for any help. I'm very new when it comes to GUI, so I apologize if there's a straightforward solution to this that I've yet to understand. --Beetle
  4. Just wanted to let everyone know that I've got it working after changing a lot of the code. I may run into more issues when I push this to multiplayer, but if anyone needs help regarding the solution, just PM me!
  5. Hey guys! I've been trying to understand how Capabilities work. I want to create a simple mod that displays a player's coordinates when given a command, and a player's death coordinates when given that same command with one argument. So far I've gotten the first part down perfectly. The second part has been difficult because I want to store the death coordinates into a capability and then retrieve it when the command is used. The code in it's current state crashes completely. I've been following this tutorial as a guideline: http://www.planetminecraft.com/blog/forge-tutorial-capability-system/ Hopefully someone here can help figure out what's wrong with my code. I'd love to be able to understand what's going wrong. Capabilities seem extremely useful and I'd love to be able to learn how to use them. I know there's a lot to share below, but I can't pinpoint at what location my capability setup is incorrect. I appreciate any and all criticism that will help me improve! Here's my code: main package blazebeetle.mod; import blazebeetle.capabilities.Ideathloc; import blazebeetle.capabilities.deathHandler; import blazebeetle.capabilities.deathProvider; import blazebeetle.commands.coords; import net.minecraft.command.ServerCommandManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; 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.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; @Mod(modid = BlazeBeetle.MODID, version = BlazeBeetle.VERSION) public class BlazeBeetle { public static final String MODID = "blazebeetle"; public static final String VERSION = "0.0.0"; @EventHandler public void serverStart(FMLServerStartingEvent event){ ServerCommandManager manager = (ServerCommandManager) event.getServer().getCommandManager(); manager.registerCommand(new coords()); MinecraftForge.EVENT_BUS.register(new deathHandler()); } @SubscribeEvent public void onPlayerLogsIn(PlayerLoggedInEvent event){ System.out.println("Logged in!!!!!!"); EntityPlayer player = event.player; Ideathloc deathloc = player.getCapability(deathProvider.DEATHLOC_CAP, null); } /* @SubscribeEvent public void onPlayerDeath(LivingDeathEvent event){ System.out.println("I DIED"); if (event.getEntity() instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer)event.getEntityLiving(); Ideathloc deathloc = player.getCapability(deathProvider.DEATHLOC_CAP, null); deathloc.setLoc(player.getPositionVector().xCoord, player.getPositionVector().yCoord, player.getPositionVector().zCoord); System.out.println("set new death loc"); } }*/ } coords command class package blazebeetle.commands; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.ListIterator; import blazebeetle.capabilities.Ideathloc; import blazebeetle.capabilities.deathProvider; import jline.internal.Nullable; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; public class coords extends CommandBase{ @Override public String getCommandName() { return "coords"; } @Override public String getCommandUsage(ICommandSender sender) { return "Displays the player's location to everyone."; } @Override public int getRequiredPermissionLevel() { return 0; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (sender instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer)sender; int dim_id = player.dimension; String dim_string = null; switch (dim_id){ case -1: dim_string = "The Nether"; break; case 0: dim_string = "The Overworld"; break; case 1: dim_string = "The End"; break; default: dim_string = "Dimension " + dim_id; } TextComponentString text = new TextComponentString(TextFormatting.YELLOW + "<" + player.getDisplayNameString() + "> I'm at x=" + (int)(player.getPositionVector().xCoord) + " z=" + (int)(player.getPositionVector().zCoord) + " y=" + (int)(player.getPositionVector().yCoord) + " in " + dim_string); if (args.length == 0){ player.addChatComponentMessage(text); } else if (args.length == 1){ System.out.println("inside length 1"); if (args[0].equalsIgnoreCase("death")){ System.out.println("inside death"); Ideathloc deathloc = player.getCapability(deathProvider.DEATHLOC_CAP,null); player.addChatComponentMessage(new TextComponentString(TextFormatting.YELLOW + "I HAVENT CODED THIS YET!!!")); player.addChatComponentMessage(new TextComponentString(TextFormatting.YELLOW + "<" + player.getDisplayNameString() + "> I died at x=" + (int)deathloc.getLoc().xCoord + " z=" + (int)deathloc.getLoc().zCoord + " y=" + (int)deathloc.getLoc().yCoord + " in SOME FUCKING DIMENSION!!!")); return; } String[] playerList = server.getAllUsernames(); for (int i = 0; i < playerList.length; i++){ if (args[0].equalsIgnoreCase(playerList[i])){ EntityPlayer receiver = server.getEntityWorld().getPlayerEntityByName(playerList[i]); receiver.addChatMessage(text); } } } } } @Override public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { return args.length == 0 ? Collections.<String>emptyList() : getListOfStringsMatchingLastWord(args, server.getAllUsernames()); } } Ideathloc package blazebeetle.capabilities; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.Vec3d; public interface Ideathloc { public void writeLoc(); public NBTTagCompound getLocComp(); public Vec3d getLoc(); public void setLoc(); public void setLoc(double x, double y, double z); } deathloc package blazebeetle.capabilities; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.Vec3d; public class deathloc implements Ideathloc{ private Vec3d location; private NBTTagCompound nbt; double x; double y; double z; public void writeLoc(){ nbt.setDouble("x", this.x); nbt.setDouble("y", this.y); nbt.setDouble("z", this.z); } public NBTTagCompound getLocComp() { return nbt; } public void setLoc() { Vec3d temp = new Vec3d(nbt.getDouble("x"), nbt.getDouble("y"), nbt.getDouble("z")); } @Override public void setLoc(double x, double y, double z) { location = new Vec3d(x, y, z); this.x = x; this.y = y; this.z = z; } @Override public Vec3d getLoc() { return location; } } deathStorage package blazebeetle.capabilities; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability.IStorage; public class deathStorage implements IStorage<Ideathloc>{ @Override public NBTBase writeNBT(Capability<Ideathloc> capability, Ideathloc instance, EnumFacing side) { instance.writeLoc(); return (instance.getLocComp()); } @Override public void readNBT(Capability<Ideathloc> capability, Ideathloc instance, EnumFacing side, NBTBase nbt) { instance.setLoc(); } } deathProvider package blazebeetle.capabilities; import net.minecraft.nbt.NBTBase; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilitySerializable; public class deathProvider implements ICapabilitySerializable<NBTBase>{ @CapabilityInject(Ideathloc.class) public static final Capability<Ideathloc> DEATHLOC_CAP = null; private Ideathloc instance = DEATHLOC_CAP.getDefaultInstance(); @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == DEATHLOC_CAP; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { return capability == DEATHLOC_CAP ? DEATHLOC_CAP.<T> cast(this.instance) : null; } @Override public NBTBase serializeNBT() { return DEATHLOC_CAP.getStorage().writeNBT(DEATHLOC_CAP, this.instance, null); } @Override public void deserializeNBT(NBTBase nbt) { DEATHLOC_CAP.getStorage().readNBT(DEATHLOC_CAP, this.instance, null, nbt); } } deathHandler package blazebeetle.capabilities; import blazebeetle.mod.BlazeBeetle; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class deathHandler { public static final ResourceLocation DEATHLOC_CAP = new ResourceLocation(BlazeBeetle.MODID, "deathloc"); @SubscribeEvent public void attachCapability(AttachCapabilitiesEvent.Entity event){ if (!(event.getEntity() instanceof EntityPlayer)){ event.addCapability(DEATHLOC_CAP, new deathProvider()); } } }
  6. Thanks hugo. Ya, I checked up on Capabilities, something that I've never worked with before. My sound is playing through the World object, so I guess I'd have to change it back to an EntityPlayer in order to work on Capabilities from there. So is the logic behind this something like: I create a capability interface and storage, register it, attach it to the EntityPlayer, and lastly make a handler for the capability to fire whenever my command is initiated? I hope I have this right....
  7. Doesn't vanilla MC already have a command to play a sound at a player? From another forum: Oh! Good to know but sadly I still cant find a way to play the sound, wait 1 second, and then perform the rest of my code.
  8. Thank you everyone for your help! diesieben07, that link was really helpful. Turns out all I needed to do was null the EntityPlayer argument and use a different version of the World's playSound method. Here's the code if anyone falls into a similar issue! entityplayer.worldObj.playSound(null, entityplayer.getPosition().getX(), entityplayer.getPosition().getY(), entityplayer.getPosition().getZ(), SoundEvents.ENTITY_CREEPER_PRIMED, SoundCategory.HOSTILE, 1.0F, 0.5F);
  9. Hi guys, I'm new to the group. It's really great to see one single location for modders to exchange information between one another. I look forward to being a part of the forge community for a long time! My question is about being able to play the creeper primed sound at a player location. I've created a simple command class that runs fine, but It doesn't seem to want to play the sound when I get in-game. Mind helping a newbie out? I noticed there are several versions of the playSound() method and I've tried them all to no avail. There must be something simple that I'm missing. Here's the execute method in question that won't play the sound. I was also wondering if using thread.sleep() is considered alright to insert a delay. I'd love to have a short delay between the sound playing and the rest of my code. @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException{ if (args.length <= 0) { throw new WrongUsageException("Must give player name.", new Object[0]); } if (sender instanceof EntityPlayer){ EntityPlayer entityplayer = args.length >= 1 ? getPlayer(server, sender, args[0]) : getCommandSenderAsPlayer(sender); server.getEntityWorld().playSound(entityplayer.getPosition().getX(), entityplayer.getPosition().getY(), entityplayer.getPosition().getZ(), SoundEvents.ENTITY_CREEPER_PRIMED, SoundCategory.HOSTILE, 1.0F, 0.5F, false); //one of many i've tried. } } Thanks for any help!
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.