Files
gradle
src
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle
Code
13 272
src/main/java/com/firemagic/firemagicmod/FireMagicMod.java
package com.firemagic.firemagicmod;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.projectile.SmallFireballEntity;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;
@Mod(FireMagicMod.MOD_ID)
public class FireMagicMod {
public static final String MOD_ID = "firemagicmod";
private static final String PROTOCOL_VERSION = "1";
public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel(
new net.minecraft.util.ResourceLocation(MOD_ID, "main"),
() -> PROTOCOL_VERSION,
PROTOCOL_VERSION::equals,
PROTOCOL_VERSION::equals
);
public FireMagicMod() {
CHANNEL.registerMessage(0, FireMessage.class, FireMessage::encode, FireMessage::decode, FireMessage::handle);
}
static void shootFireball(ServerPlayerEntity player) {
ServerWorld world = player.getServerWorld();
Vector3d look = player.getLookVec();
SmallFireballEntity fireball = new SmallFireballEntity(world, player, look.x, look.y, look.z);
fireball.setPosition(player.getPosX(), player.getPosYEye() - 0.1D, player.getPosZ());
fireball.shoot(look.x, look.y, look.z, 1.5F, 0.0F);
world.addEntity(fireball);
double x = player.getPosX();
double y = player.getPosYEye();
double z = player.getPosZ();
world.playSound(null, x, y, z, SoundEvents.ENTITY_BLAZE_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F);
world.spawnParticle(ParticleTypes.FLAME, x, y, z, 8, 0.12D, 0.12D, 0.12D, 0.02D);
}
}