Everything posted by kyazuki
-
(Solved)[1.15.2]player.onDeath method causes crash
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); } } }
-
(Solved)[1.15.2]player.onDeath method causes crash
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.
-
[1.15.2]How do I make player fat?
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.
-
(Solved)[1.15.2]Why do I get 2 different values from player.distanceWalkedModified?
It worked! Thanks!!
-
(Solved)[1.15.2]How do max health set?
I didn't know removeModifier method... It works! Thanks!!
-
(Solved)[1.15.2]How do max health set?
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?
-
(Solved)[1.15.2]How do max health set?
Yes, I call this function on those events. But those events happens not only once, health keeps increase.
-
(Solved)[1.15.2]Why do I get 2 different values from player.distanceWalkedModified?
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"); }
-
[1.15.2]How do I make player fat?
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.
-
(Solved)[1.15.2]How do max health set?
I want to call this function when player logins first or every time player dies.
-
(Solved)[1.15.2]How do max health set?
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); }
-
(Solved)[1.15.2]Why cannot my cord detect events?
It worked!! Thanks!!
-
(Solved)[1.15.2]Why cannot my cord detect events?
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)); } }
IPS spam blocked by CleanTalk.