Jump to content

kyazuki

Members
  • Posts

    113
  • Joined

  • Last visited

Everything posted by kyazuki

  1. Can I check Client or Server Thread by isRemote()? @SubscribeEvent public static void killPlayer(TickEvent.PlayerTickEvent event) { if (event.player.world.isRemote()) { if (/* check player */) { event.player.onDeath(DamageSource.OUT_OF_WORLD); } } }
  2. I call onDeath method, and the game is crashed. The game is crashed in LivingEntity.dropLoot method. protected void dropLoot(DamageSource damageSourceIn, boolean p_213354_2_) { ResourceLocation resourcelocation = this.getLootTableResourceLocation(); LootTable loottable = this.world.getServer().getLootTableManager().getLootTableFromLocation(resourcelocation); LootContext.Builder lootcontext$builder = this.getLootContextBuilder(p_213354_2_, damageSourceIn); loottable.generate(lootcontext$builder.build(LootParameterSets.ENTITY), this::entityDropItem); } getServer method always returns null. @Nullable public MinecraftServer getServer() { return null; } This causes NullPointerException.
  3. I tried using scale method of MatrixStack. @SubscribeEvent public static void onRenderPlayerPre(RenderPlayerEvent.Pre event) { event.getMatrixStack().push(); event.getMatrixStack().scale(2.0f, 1.0f, 2.0f); //GlStateManager.pushMatrix(); //GlStateManager.scalef(2.0f, 1.0f, 1.0f); } @SubscribeEvent public static void onRenderPlayerPost(RenderPlayerEvent.Post event) { event.getMatrixStack().pop(); //GlStateManager.popMatrix(); } I want to make player fat from any direction. But I look normal when seen from above.
  4. I didn't know removeModifier method... It works! Thanks!!
  5. I gradually decrease max health on PlayerTickEvent. If a player dies, reset his max health to 20 hearts. But this cord increases max health every time he dies. How do I reset his max health?
  6. Yes, I call this function on those events. But those events happens not only once, health keeps increase.
  7. This cord gets 2 different values of player.distanceWalkedModified from Render Thread and Server Thread. How do I get only one of these? @SubscribeEvent public static void getDistanceWalked(TickEvent.PlayerTickEvent event) { float walkDistance = (float)(event.player.distanceWalkedModified / 0.6); LOGGER.debug("now: " + event.player.distanceWalkedModified / 0.6 + "blocks"); }
  8. I wrote this cord, but it is worked only when player hold items. Moreover blocks render on player. @SubscribeEvent public static void onRenderPlayerPre(RenderPlayerEvent.Pre event) { GlStateManager.pushMatrix(); GlStateManager.scalef(2.0f, 1.0f, 1.0f); } @SubscribeEvent public static void onRenderPlayerPost(RenderPlayerEvent.Post event) { GlStateManager.popMatrix(); } Then, how does GlStateManager.scalef work? I want to change Player's scaleX(depth) to 1.2X and scaleZ(width) to 2.0Z. GlStateManager.scalef(2.0f, 1.0f, 1.0f) makes a player fat, but depth doesn't change. GlStateManager.scalef(1.0f, 1.0f, 2.0f) shrinks a player's height.
  9. I want to call this function when player logins first or every time player dies.
  10. I want to set player's max health to 20.0. I have managed to increase health by 10.0. But every time this function is called, the player's health keeps increase. How do max health set? public static void setPlayerHealth(PlayerEntity player) { player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("MaxHealth", 10.0f, AttributeModifier.Operation.ADDITION)); player.setHealth(20.0f); }
  11. It worked!! Thanks!!
  12. I'm a new to modding minecraft. I tried to set the max health when a player login, but nothing happened. Not only that, testFunc didn't run. Please help... package com.github.kyazuki.testmod; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.PlayerEntity; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod(TestMod.MODID) @Mod.EventBusSubscriber public class TestMod { public static final String MODID = "testmod"; public static final Logger LOGGER = LogManager.getLogger(MODID); public TestMod() { LOGGER.debug("Mod Loaded."); } @SubscribeEvent public void testFunc(TickEvent.PlayerTickEvent event) { LOGGER.debug("tick!"); } @SubscribeEvent public void setPlayerHealth(PlayerEvent.PlayerLoggedInEvent event) { PlayerEntity player = (PlayerEntity) event.getEntity(); player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("MaxHealth", 10.0f, AttributeModifier.Operation.ADDITION)); } }
×
×
  • Create New...

Important Information

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