Jump to content

Oscarita25

Members
  • Posts

    143
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Oscarita25

  1. Okay.. before reading this i want you to know that i: - have not coded this Level System - have really almost 0 .. ideas how to use a Subscribe event.. (i should look this up.. in a second) - that i am a bit confused with the code myself.. >:I -- what is no good thing (got this from a friend i want to continue it but i have to understand it first) so here the classes i am using: Quirk class .. here is basicly the Level system public abstract class Quirk { protected String name; protected static int cooldown = 0; protected static int maxCooldown = 0; protected static int act = 0; protected static int maxAct = 0; protected static boolean activated = false; protected static boolean aviable = true; protected static double xp = 0; protected static double nextXp = 0; protected static double xpPerTick = 0; protected static int level = 0; protected static double levelFactor = 0; protected static double levelMinimum = 0; protected static LevelUp levelUp = null; public Quirk(String name) { this.name = name; ModQuirks.QUIRKS.add(this); } @SubscribeEvent public abstract void onPlayerUse(EntityPlayer player); public String getName() { return name; } public static int xpToLevel(double xp) { double i = levelMinimum; int lvl = 1; if(xp < i) return 1; while(i <= xp) { lvl++; i *= levelFactor; } if(xp < i) { if(lvl - 1 == 0) { return 1; } return lvl - 1; } return lvl; } public void setXp(double xp) { this.xp = xp; this.level = xpToLevel(xp); System.out.println("LEVEL: " + level); init(); if(xp == 0) { nextXp = levelMinimum; } else { nextXp = xp * levelFactor; } } protected static void init() { if(levelUp == null || level == 0) return; maxCooldown = (int) (maxCooldown * Math.pow(levelUp.getCooldownMultiplier(), level)); maxAct = (int) (maxAct * Math.pow(levelUp.getActivatedMultiplier(), level)); } public void setMaxCooldown(int _maxCooldown) { this.maxCooldown = _maxCooldown; } public void setMaxActivatedTime(int _maxAct) { this.maxAct = _maxAct; } public void setLevelUp(LevelUp _levelUp) { this.levelUp = _levelUp; } public void setLevelFactor(double _levelFactor) { this.levelFactor = _levelFactor; } public void setLevelMinimum(double _levelMinimum) { this.levelMinimum = _levelMinimum; } public void setXpPerTick(double _xpPerTick) { this.xpPerTick = _xpPerTick; } public static double getXp() { return xp; } public static void addXp(double add) { xp += add; } } and i am using the Level system like this: public class QuirkExplosive extends Quirk { private static EntityPlayer p; public QuirkExplosive() { super("explosive"); setMaxCooldown(100); setLevelMinimum(100); setLevelFactor(5); setMaxActivatedTime(1); setLevelUp(new LevelUp(0, 0.99)); setXpPerTick(1/20); } @Override public void onPlayerUse(EntityPlayer player) { p = player; if(aviable) { //this is my instance of the simpleNetworkWrapper.. BnHA.simpleNetworkWrapper.sendToServer(new MessageExplosion(level * 0.5F)); aviable = false; xp += level * 2.75; } } @SubscribeEvent public static void tick(ServerTickEvent event) { if(!aviable) { cooldown++; if(cooldown >= maxCooldown) { aviable = true; cooldown = 0; } } if(xp >= nextXp) { level++; nextXp = xp * levelFactor; if(p != null) { p.sendMessage(new TextComponentString(TextFormatting.AQUA + "Level Up")); p.sendMessage(new TextComponentString(TextFormatting.AQUA + "Your now level " + level)); } maxCooldown *= levelUp.getCooldownMultiplier(); } } } what this should do: - pressing [Key] calls onPlayerUse in the QuirkExplosive class (works) - will cast a explosion (works) - aviable is set to false (works) - and adds xp to the player (works) - the tick event is getting called because aviable is false and the cooldown is running trough (works) - the player should level up when the xp reaches nextXp (Xp req for nextLvl) .... (doesn't work) .. thats what at least think it does and i bet .. really that its just because i am using the Subscribe event wrong ... °—°...
  2. i am pretty interested in this .. and i wouldn't mind helping out :I i am not that advanced in modding but i can do stuff .. like textures (i am very good at textures) my discord is Oscar#0853
  3. seems like it was for both...
  4. i thought that was for smoke ?
  5. yup .. that was it .. now just out of curiousity ... is there a way to turn off explosion damage and just do damage to entities?
  6. @V0idWa1k3r ... well i have overtaken the mod i am working on but i knew such thing as a "common" proxy should not exist aka. that what i were doing is wrong.. but just ignored that because it worked fine for now (right now i just want something running good XD) i will fix that in a second .. i wasn't sure about that .. but this actually could it be XD.. i will now debug my code and write another reply .. if changing the power worked
  7. oh that was just me trying .. i should change that.. i think i am doing that ... and i don't run a git on it right now :I .. but i can give you some more code Here some more code: Message Handler: public class MyMessageHandler implements IMessageHandler<MessageExplosion, IMessage> { @Override public IMessage onMessage(MessageExplosion message, MessageContext ctx) { EntityPlayerMP serverPlayer = ctx.getServerHandler().player; float amount = message.power; serverPlayer.getServerWorld().addScheduledTask(() -> { serverPlayer.getServerWorld().createExplosion(serverPlayer, serverPlayer.lastTickPosX + serverPlayer.getLookVec().x , serverPlayer.lastTickPosY + 1, serverPlayer.lastTickPosZ + serverPlayer.getLookVec().z , (float) (amount), true); }); return null; } } Message: public class MessageExplosion implements IMessage { public MessageExplosion() {} public MessageExplosion(float power) { this.power = power; } float power; EntityPlayer player; @Override public void toBytes(ByteBuf buf) { buf.writeFloat(power); } @Override public void fromBytes(ByteBuf buf) { power = buf.readFloat(); } public float getamount() { return power; } } Here is what class i am using to spawn the explosion public class QuirkExplosive extends Quirk { private static EntityPlayer p; public QuirkExplosive() { super("explosive"); setMaxCooldown(2000); setLevelMinimum(100); setLevelFactor(5); setMaxActivatedTime(1); setLevelUp(new LevelUp(0, 0.99)); setXpPerTick(1/20); } @Override public void onPlayerUse(EntityPlayer player) { p = player; if(aviable) { BnHA.proxy.simpleNetworkWrapper.sendToServer(new MessageExplosion(level * 0.1F)); aviable = false; xp += level * 2.75; } } @SubscribeEvent public static void tick(ServerTickEvent event) { if(!aviable) { cooldown++; if(cooldown >= maxCooldown) { aviable = true; cooldown = 0; } } if(xp >= nextXp) { level++; nextXp = xp * levelFactor; if(p != null) { p.sendMessage(new TextComponentString(TextFormatting.AQUA + "Level Up")); p.sendMessage(new TextComponentString(TextFormatting.AQUA + "Your now level " + level)); } maxCooldown *= levelUp.getCooldownMultiplier(); } } } @V0idWa1k3r if the superclass is relevant i can send it too
  8. still not sure about that .. also my explosion still does no damage .... (it should do damage to the entities not the player)
  9. never worked with custom item models but i found this in the Item class.. : @SideOnly(Side.CLIENT) public void setTileEntityItemStackRenderer(@Nullable net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer teisr) { this.teisr = teisr; } its client sided .. named renderer.. maybe you can change the model in there with a simple switch checking for the NBT? but i am not sure tho..
  10. no problem you just have to check that the player is loaded somehow
  11. ? sorry cant help you :I but i would suggest to send a message for debugging in the console to see if the event is fired before the player loaded
  12. no, just wondering.. because thats a version i never modded on :I so i may will post you a bit innacurrate code
  13. also on what version are you modding that you get the player with "Minecraft.getMinecraft().thePlayer"
  14. @TheDigitalDev should all people see this message in the chat or should it only be client displayed?
  15. i got the packets working.. now everything or the explosions is server sided what is great.. but the explosion does not do damage... serverPlayer.getServerWorld().createExplosion(serverPlayer, serverPlayer.lastTickPosX + serverPlayer.getLookVec().x , serverPlayer.lastTickPosY + 1, serverPlayer.lastTickPosZ + serverPlayer.getLookVec().z , (float) (amount), true); is this the right way to do it? (this is in my packet handler class... the packet will send the amount of power that is being used)
  16. i know this is a bit older now but i just wanted to say .. that i think that you can also use obj models because the ModelRender does support these .. (obj models can be less blocky aka. they can be even completly smooth spheres)
  17. okay i just used a work around that is way easier child the parts to the biped model - what would be the player and then rendering then the super method (what would be Modelbiped) and just using LArm.isHidden = true; Body.isHidden = true; RLeg.isHidden = true; LLeg.isHidden = true; RArm.isHidden = true; Head.isHidden = true; to hide the models that are getting rendered 2 times
  18. also now its rendering propertly but its not showing the animation
  19. @Alexiy yes right now its only intentended for players
  20. -just making a message so anybody may see this post and help me
  21. thanks .. funny enough i already have a packets .. but i forgot that i could use them to do that
  22. ahh nooo :I .. i think this would not be any releated to this anymore but i noticed i am spawning the explosion client side and not server side .. how would spawn it server sided?
  23. @V0idWa1k3r thanks that worked!
  24. thanks i will try that
  25. Well i try to spawn a explosion on the coardinates of the player.. that works pretty well with this: player.world.createExplosion(player, player.getPosition().getX(), player.getPosition().getY() + 1, player.getPosition().getZ(), (float) (level * 0.1), true); *i am spawning it with a keybind* but that wont change if the player rotates ... what i want it to do .. i want it to be always spawned at the right side of the player inside of his right hand ..
×
×
  • Create New...

Important Information

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