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

PlanetTeamSpeak

Members
  • Posts

    49
  • Joined

  • Last visited

Everything posted by PlanetTeamSpeak

  1. I got it working now, it has to be played with EntityPlayer.playSound() instead of SoundHandler.playSound(), but it doesn't repeat and it's still fixed to a blockpos.
  2. I have now made a class according to MovingSoundMinecart, but once played it doesn't do anything. EasterEgg.java: package com.ptsmods.morecommands.miscellaneous; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.MovingSound; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; public class EasterEgg extends MovingSound { protected EasterEgg(SoundEvent sound, SoundCategory category) { super(sound, category); volume = 1F; pitch = 0F; repeat = true; repeatDelay = 190; } @Override public void update() { xPosF = Minecraft.getMinecraft().player.getPosition().getX() + 0.5F; yPosF = Minecraft.getMinecraft().player.getPosition().getX() + 0.5F; zPosF = Minecraft.getMinecraft().player.getPosition().getY() + 0.5F; donePlaying = !Reference.easterEggLoopEnabled; } }
  3. If that method for starting command prompt doesn't work, you can always press the windows key, type cmd and click enter.
  4. Every method that plays a sound (EntityPlayer.playSound(), EntityPlayerSP.playSound() and SoundHandler.playSound()) all play sounds at a fixed BlockPos, is there any way to make this sound play directly to the player with the sound following the player just like how music works? This has to be done on the client side FYI.
  5. It's still not working, same as before, not doing anything. And yes, I am sure I am calling it on the client side.
  6. I was able to play the sound without registering it, but somehow it broke, do you have any clues on how to register sounds though? I couldn't find how to do it in 1.12 Edit: The mod is actually meant for 1.11 up until 1.12.1, it's just commands so it works on all version mentioned.
  7. I have made a class implementing ISound, but when I try to play it with Minecraft.getMinecraft().getSoundHandler().playSound(new EasterEgg()), nothing happens not even an error in the console saying the sound doesn't exist. EasterEgg.java: package com.ptsmods.morecommands.miscellaneous; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.Sound; import net.minecraft.client.audio.SoundEventAccessor; import net.minecraft.client.audio.SoundHandler; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; public class EasterEgg implements ISound { private ResourceLocation location; private SoundEventAccessor soundEvent; private Sound sound; public EasterEgg() { location = new ResourceLocation("morecommands:easteregg"); try { createAccessor(Minecraft.getMinecraft().getSoundHandler()); } catch (Throwable e) {} } @Override public ResourceLocation getSoundLocation() { return location; } @Override public SoundEventAccessor createAccessor(SoundHandler handler) { soundEvent = handler.getAccessor(location); if (soundEvent == null) sound = SoundHandler.MISSING_SOUND; else sound = soundEvent.cloneEntry(); return soundEvent; } @Override public Sound getSound() { return sound; } @Override public SoundCategory getCategory() { return SoundCategory.PLAYERS; } @Override public boolean canRepeat() { return true; } @Override public int getRepeatDelay() { return 10; } @Override public float getVolume() { return 100; } @Override public float getPitch() { return 0; } @Override public float getXPosF() { return 0; } @Override public float getYPosF() { return 0; } @Override public float getZPosF() { return 0; } @Override public AttenuationType getAttenuationType() { return AttenuationType.LINEAR; } } Sounds.json: { "easteregg": { "category": "players", "sounds": [ { "name": "morecommands:easteregg", "stream": true } ] } }
  8. Apparently it was erroring because I didn't have sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. compileJava { sourceCompatibility = targetCompatibility = '1.8' } in build.gradle, not sure why it needs it, but it works fine now and the NoSuchMethod error has been fixed. Thanks for the help!
  9. After a while of trying to figuring out how, I managed to build the mod with shadowjar, but the problem is still here. According to javadecompilers.com it still says ClientCommandHandler.instance.registerCommand(ICommand). I built it with the command gradlew shadowJar (since gradlew build gave an error saying MISSING REPLACEMENT DATA FOR MAPPING_CHANNEL) with the following build.gradle: buildscript { repositories { jcenter() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' } } plugins { id 'com.github.johnrengelman.shadow' version '1.2.4' } apply plugin: 'net.minecraftforge.gradle.forge' version = "1.26.1" group = "com.ptsmods.morecommands" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "MoreCommands" sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. compileJava { sourceCompatibility = targetCompatibility = '1.8' } minecraft { version = "1.12-14.21.1.2387" runDir = "run" mappings = "snapshot_20170624" makeObfSourceJar = false } dependencies { compile 'org.javassist:javassist:3.22.0-CR2' compile 'org.reflections:reflections:0.9.10' compile 'org.yaml:snakeyaml:1.18' compile 'com.google.guava:guava:23.0' } shadowJar { dependencies { include(dependency('org.javassist:javassist:3.22.0-CR2')) include(dependency('org.reflections:reflections:0.9.10')) include(dependency('org.yaml:snakeyaml:1.18')) include(dependency('com.google.guava:guava:23.0')) } classifier '' // Replace the default JAR } reobf { shadowJar {} // Reobfuscate the shadowed JAR } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' // replace version and mcversion expand 'version': project.version, 'mcversion': project.minecraft.version } // copy everything else, that's not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } } tasks.withType(JavaCompile) { options.encoding = 'UTF-8' options.compilerArgs.add('-Xlint:unchecked') } tasks.withType(Javadoc) { options.encoding = 'UTF-8' } task javadocJar(type: Jar, dependsOn: javadoc) { from javadoc.destinationDir classifier = 'javadoc' } artifacts { archives javadocJar archives shadowJar }
  10. According to javadecompilers.com, it doesn't. Maybe this is because I build it with a custom made gradle task? Which is task renameJar(type: Jar) { manifest { attributes 'Implementation-Title': 'MoreCommands', 'Implementation-Version': version, 'Main-Class': 'com.ptsmods.morecommands.MoreCommands' } baseName = 'morecommands_' + version + '_mc1.11-1.12.1' from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } with jar }
  11. https://gist.github.com/PlanetTeamSpeakk/9886ec553ab5af1f6d9a1488ba19b1ff
  12. But that's exactly what didn't work, I built my mod, put it in %appdata%/.minecraft/mods, ran Minecraft and it said ClientCommandHandler.instance.registerCommand(ICommand) wasn't a function.
  13. And how would I do that? I don't think I've ever had to that before.
  14. It crashed the game when loading, not a server and thanks to the @SideOnly annotation, which the link you posted apparently says not to use, it only loads on the client.
  15. package com.ptsmods.morecommands; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Set; import org.reflections.Reflections; import com.ptsmods.morecommands.commands.chelp.Commandchelp; import com.ptsmods.morecommands.commands.enchant.Commandenchant; import com.ptsmods.morecommands.commands.fixTime.CommandfixTime; import com.ptsmods.morecommands.miscellaneous.CommandBase; import com.ptsmods.morecommands.miscellaneous.CommandType; import com.ptsmods.morecommands.miscellaneous.IncorrectCommandType; import com.ptsmods.morecommands.miscellaneous.Reference; import com.ptsmods.morecommands.miscellaneous.Reference.LogType; import net.minecraft.block.Block; import net.minecraft.client.settings.KeyBinding; import net.minecraft.command.ICommand; import net.minecraft.init.Blocks; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public abstract class Initialize { public static void registerCommands(FMLServerStartingEvent event) { Reference.print(LogType.INFO, "Registering MoreCommands server sided commands."); ICommand[] nonRegistryCommands = new ICommand[] {new CommandfixTime(), new Commandenchant()}; ICommand[] commands; try { commands = Reference.getCommandRegistry(CommandType.SERVER).toArray(new ICommand[0]); } catch (IncorrectCommandType e1) { e1.printStackTrace(); return; } Integer counter = 0; Integer fails = 0; List<String> failList = new ArrayList<>(); for (ICommand command : commands) try { event.registerServerCommand(command); counter += 1; } catch (Exception e) {fails += 1; failList.add(command.getName()); continue;} for (ICommand command : nonRegistryCommands) try { event.registerServerCommand(command); counter += 1; } catch (Exception e) { fails += 1; failList.add(command.getName()); e.printStackTrace(); continue; } Reference.print(LogType.INFO, "Successfully registered " + counter.toString() + " server sided commands, with " + fails.toString() + " fails."); if (!(failList.size() == 0)) Reference.print(LogType.INFO, "Failed to register " + CommandBase.joinNiceString(failList.toArray(new String[0]))); } @SideOnly(Side.CLIENT) public static void registerClientCommands() { Reference.print(LogType.INFO, "Registering MoreCommands client sided commands."); ICommand[] nonRegistryCommands = new ICommand[] {new Commandchelp()}; ICommand[] commands; try { commands = Reference.getCommandRegistry(CommandType.CLIENT).toArray(new ICommand[0]); } catch (IncorrectCommandType e1) { e1.printStackTrace(); return; } Integer counter = 0; Integer fails = 0; List<String> failList = new ArrayList<>(); for (ICommand command : commands) try { ClientCommandHandler.instance.registerCommand(command); counter += 1; } catch (Exception e) {fails += 1; failList.add(command.getName()); continue;} for (ICommand command : nonRegistryCommands) try { ClientCommandHandler.instance.registerCommand(command); counter += 1; } catch (Exception e) { fails += 1; failList.add(command.getName()); e.printStackTrace(); continue; } Reference.print(LogType.INFO, "Successfully registered " + counter.toString() + " client sided commands, with " + fails.toString() + " fails."); if (!(failList.size() == 0)) Reference.print(LogType.INFO, "Failed to register " + CommandBase.joinNiceString(failList.toArray(new String[0]))); } public static void setupBlockLists() { Reference.print(LogType.INFO, "Setting up the MoreCommands block blacklist."); Block[] blacklist = {Blocks.AIR, Blocks.LAVA, Blocks.CACTUS, Blocks.MAGMA, Blocks.ACACIA_FENCE, Blocks.ACACIA_FENCE_GATE, Blocks.BIRCH_FENCE, Blocks.BIRCH_FENCE_GATE, Blocks.DARK_OAK_FENCE, Blocks.DARK_OAK_FENCE_GATE, Blocks.JUNGLE_FENCE, Blocks.JUNGLE_FENCE_GATE, Blocks.NETHER_BRICK_FENCE, Blocks.OAK_FENCE, Blocks.OAK_FENCE_GATE, Blocks.SPRUCE_FENCE, Blocks.SPRUCE_FENCE_GATE, Blocks.FIRE, Blocks.WEB, Blocks.MOB_SPAWNER, Blocks.END_PORTAL, Blocks.END_PORTAL_FRAME, Blocks.TNT, Blocks.IRON_TRAPDOOR, Blocks.TRAPDOOR, Blocks.BREWING_STAND}; Integer counter = 0; for (Block element : blacklist) { Reference.addBlockToBlacklist(element); counter += 1; } Reference.print(LogType.INFO, "Successfully set up the block blacklist and added " + counter.toString() + " blocks."); Reference.print(LogType.INFO, "Setting up the MoreCommands block whitelist."); Block[] whitelist = {Blocks.AIR, Blocks.DEADBUSH, Blocks.VINE, Blocks.TALLGRASS, Blocks.ACACIA_DOOR, Blocks.BIRCH_DOOR, Blocks.DARK_OAK_DOOR, Blocks.IRON_DOOR, Blocks.JUNGLE_DOOR, Blocks.OAK_DOOR, Blocks.SPRUCE_DOOR, Blocks.DOUBLE_PLANT, Blocks.RED_FLOWER, Blocks.YELLOW_FLOWER, Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM, Blocks.WATERLILY, Blocks.BEETROOTS, Blocks.CARROTS, Blocks.WHEAT, Blocks.POTATOES, Blocks.PUMPKIN_STEM, Blocks.MELON_STEM, Blocks.SNOW_LAYER}; counter = 0; for (Block element : whitelist) { Reference.addBlockToWhitelist(element); counter += 1; } Reference.print(LogType.INFO, "Successfully set up the block whitelist and added " + counter.toString() + " blocks."); } public static void setupCommandRegistry() { Set<Class<? extends CommandBase>> commands = new Reflections("com.ptsmods.morecommands.commands").getSubTypesOf(CommandBase.class); for (Class<? extends CommandBase> command : commands) { try { Reference.addCommandToRegistry(command.newInstance().getCommandType(), command.newInstance()); command.newInstance().getPermission(); // just so it's registered in the permissions. } catch (IncorrectCommandType e) { e.printStackTrace(); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } catch (NoClassDefFoundError e) {}; } } @SideOnly(Side.CLIENT) public static void registerKeyBinds() { HashMap<String, KeyBinding> keyBindings = Reference.getKeyBindings(); for (String keyBinding : keyBindings.keySet()) ClientRegistry.registerKeyBinding(keyBindings.get(keyBinding)); } } It's being called from postInit, it used to work just fine but I have been getting a lot of errors lately which idk where they came from.
  16. I have made a client command command which I registered with ClientCommandHandler.instance.registerCommand(new Commandcalc()); which works fine in Eclipse but once compiled and loaded with forge it says NoSuchMethod, any ideas?
  17. I have made an overlay gui with some information of the player but when you hover over an entity it dissapears. InfoOverlay.class: package com.ptsmods.morecommands.miscellaneous; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.EnumSkyBlock; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class InfoOverlay extends Gui { private Minecraft mc; public InfoOverlay() { this.mc = Minecraft.getMinecraft(); this.zLevel = Float.MAX_VALUE; try { Reference.loadInfoOverlayConfig(); } catch (IOException e) { e.printStackTrace(); } drawStrings(parseInfoOverlayConfig(Reference.getInfoOverlayConfig()).toArray(new String[0])); } private void drawString(String string, int row) { int defaultHeight = 2; int defaultWidth = 2; if (Reference.setVariables.containsKey("defaultHeight") && Reference.isInteger(Reference.setVariables.get("defaultHeight"))) defaultHeight = Integer.parseInt(Reference.setVariables.get("defaultHeight")); if (Reference.setVariables.containsKey("defaultWidth") && Reference.isInteger(Reference.setVariables.get("defaultWidth"))) defaultWidth = Integer.parseInt(Reference.setVariables.get("defaultWidth")); drawString(this.mc.fontRenderer, string, defaultWidth, row*10 + defaultHeight, Integer.parseInt("FFFFFF", 16)); } private void drawStrings(String... strings) { for (int x = 0; x < strings.length; x++) { drawString(strings[x], x); } } private TextFormatting getRandomColor() { if (Reference.Random.randInt(101) == 0) { Reference.lastColor = Reference.getRandomColor("WHITE"); } return Reference.lastColor; } private List<String> parseInfoOverlayConfig(List<String> config) { Minecraft mc = Minecraft.getMinecraft(); List<String> output = new ArrayList<String>(); Reference.setVariables = new HashMap<String, String>(); try { for (String line : config) { if (line.startsWith("var ")) { if (line.split(" ").length == 4) Reference.setVariables.put(line.split(" ")[1], line.split(" ")[3]); } else { line = line.replaceAll("\\{playerName\\}", mc.player.getName()) .replaceAll("\\{x\\}", String.format("%f", mc.player.getPositionVector().x)) .replaceAll("\\{y\\}", String.format("%f", mc.player.getPositionVector().y)) .replaceAll("\\{z\\}", String.format("%f", mc.player.getPositionVector().z)) .replaceAll("\\{chunkX\\}", "" + mc.player.chunkCoordX) .replaceAll("\\{chunkY\\}", "" + mc.player.chunkCoordY) .replaceAll("\\{chunkZ\\}", "" + mc.player.chunkCoordZ) .replaceAll("\\{yaw\\}", "" + MathHelper.wrapDegrees(mc.player.rotationYaw)) .replaceAll("\\{pitch\\}", "" + MathHelper.wrapDegrees(mc.player.rotationPitch)) .replaceAll("\\{biome\\}", mc.world.getBiome(mc.player.getPosition()).getBiomeName()) .replaceAll("\\{difficulty\\}", mc.world.getWorldInfo().getDifficulty().name()) .replaceAll("\\{blocksPerSec\\}", String.format("%f", Reference.blocksPerSecond)) .replaceAll("\\{toggleKey\\}", Reference.getKeyBindingByName("toggleOverlay").getDisplayName()) .replaceAll("\\{configFile\\}", new File("config/MoreCommands/infoOverlay.txt").getAbsolutePath().replaceAll("\\\\", "\\\\\\\\")) // replacing 1 backslash with 2 so backslashes actually show .replaceAll("\\{facing\\}", Reference.getLookDirectionFromLookVec(mc.player.getLookVec())) .replaceAll("\\{time\\}", Reference.parseTime(FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(mc.player.dimension).getWorldTime() % 24000L, false)) .replaceAll("\\{UUID\\}", mc.player.getUniqueID().toString()) .replaceAll("\\{holding\\}", Reference.getLocalizedName(mc.player.getHeldItemMainhand().getItem())) .replaceAll("\\{rainbow\\}", "" + getRandomColor()) .replaceAll("\\{easterEgg\\}", ":O, you found the easter egg!") .replaceAll("\\{xp\\}", "" + mc.player.experienceTotal) .replaceAll("\\{xpLevel\\}", "" + mc.player.experienceLevel) .replaceAll("\\{gamemode\\}", FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(mc.player.getName()).interactionManager.getGameType().getName()) .replaceAll("\\{fps\\}", "" + mc.getDebugFPS()) .replaceAll("\\{blockLight\\}", "" + mc.world.getChunkFromBlockCoords(mc.player.getPosition()).getLightFor(EnumSkyBlock.BLOCK, mc.player.getPosition())) .replaceAll("\\{skyLight\\}", "" + mc.world.getChunkFromBlockCoords(mc.player.getPosition()).getLightFor(EnumSkyBlock.SKY, mc.player.getPosition())) .replaceAll("\\{lookingAtX\\}", "" + mc.objectMouseOver.getBlockPos().getX()) .replaceAll("\\{lookingAtY\\}", "" + mc.objectMouseOver.getBlockPos().getY()) .replaceAll("\\{lookingAtZ\\}", "" + mc.objectMouseOver.getBlockPos().getZ()) .replaceAll("\\{lookingAt\\}", "" + Reference.getLocalizedName(mc.world.getBlockState(mc.objectMouseOver.getBlockPos()).getBlock())) .replaceAll("\\{isSingleplayer\\}", "" + FMLCommonHandler.instance().getMinecraftServerInstance().isSinglePlayer()); if (line.equals("") || !line.split("//")[0].equals("")) output.add(line.split("//")[0]); } } } catch (NullPointerException e) {} return output; } } How I render it (in ClientEventHandler.class): @SubscribeEvent public void onRenderGui(RenderGameOverlayEvent.Post event) { if (event.getType() == ElementType.EXPERIENCE && Reference.isInfoOverlayEnabled()) new InfoOverlay(); }
  18. I have made a custom keybinding which works fine but whenever I launch the game, go to options and click controls, the game crashes for some reason. Here's how I registered the keybinding: KeyBinding keyBind = new KeyBinding("Toggle overlay", Keyboard.KEY_C, "MoreCommands") ClientRegistry.registerKeyBinding(keyBind); Crash report: java.lang.NullPointerException: Rendering screen at net.minecraft.client.gui.GuiListExtended.updateItemPos(GuiListExtended.java:41) at net.minecraft.client.gui.GuiSlot.drawSelectionBox(GuiSlot.java:446) at net.minecraft.client.gui.GuiSlot.drawScreen(GuiSlot.java:236) at net.minecraft.client.gui.GuiControls.drawScreen(GuiControls.java:163) at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:349) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1168) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1192) at net.minecraft.client.Minecraft.run(Minecraft.java:436) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26)
  19. I've justed tested it and it indeed removes the silk touch part, right-clicking a grass block now gives me dirt and right-clicking leaves doesn't give me the leaves at all. And I want it to always silk touch blocks when you right click the block while holding the pickaxe.
  20. How does one get an IBlockState and TileEntity? Edit: also, wouldn't that take out the silk touch part? Right now when you right click a grass block you get a grass block this also means that you can break unbreakable things, but that's exactly what I wanted.
  21. I made a pickaxe that on right click destroys a block and drops it, but when you right click red wool with it you get white wool, when you right click grass you get shrub, when you right click diorite you get stone, etc. How would I make the pickaxe drop the right block with the right data value?
×
×
  • Create New...

Important Information

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