Started by
Freddy101
on
Topic category: Help with Minecraft modding (Java Edition)
hi whenever i use this code it tells me to fix my imports but they are fine from what I can tell
the code in question
package net.mcreator.cbsrpg.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
public class AnimatedBeamEntity extends Entity {
private PlayerEntity player;
public AnimatedBeamEntity(World world) {
super(world);
}
// Getter and setter methods for player entity
public void setPlayer(PlayerEntity player) {
this.player = player;
}
// Override onUpdate method
@Override
public void onUpdate() {
super.onUpdate(); // Call superclass onUpdate method
if (player != null) {
// Calculate deltas and set rotation
double deltaX = player.getPosX() - this.getPosX();
double deltaY = player.getPosY() - this.getPosY();
double deltaZ = player.getPosZ() - this.getPosZ();
float yaw = (float) Math.atan2(deltaZ, deltaX) * (180F / (float) Math.PI) - 90.0F;
float pitch = (float) (-Math.atan2(deltaY, Math.sqrt(deltaX * deltaX + deltaZ * deltaZ)) * (180F / Math.PI));
this.rotationYaw = yaw;
this.rotationPitch = pitch;
this.setRotation(yaw, pitch);
}
}
}
> Task :compileJava
C:\Users\fredn\OneDrive\Desktop\noww V2\src\main\java\net\mcreator\cbsrpg\LaserLooking.java:23: error: class AnimatedBeamEntity is public, should be declared in a file named AnimatedBeamEntity.java public class AnimatedBeamEntity extends Entity {
^
C:\Users\fredn\OneDrive\Desktop\noww V2\src\main\java\net\mcreator\cbsrpg\LaserLooking.java:19: error: package net.minecraft.entity does not exist import net.minecraft.entity.Entity;
^
C:\Users\fredn\OneDrive\Desktop\noww V2\src\main\java\net\mcreator\cbsrpg\LaserLooking.java:20: error: package net.minecraft.entity.player does not exist import net.minecraft.entity.player.PlayerEntity;
^
C:\Users\fredn\OneDrive\Desktop\noww V2\src\main\java\net\mcreator\cbsrpg\LaserLooking.java:21: error: cannot find symbol import net.minecraft.world.World;
^
the error log^
i have cleared my cache already
still need help :(
This seems like code using old 1.16 MCP mappings, it will not work in new versions anyway.
Here's a tip when it comes to imports in MCreator's code editor: if your code uses valid classes that exist, pressing control + w automatically generates the imports.
In some cases it may import the wrong classes when multiple classes have the same name, but you can just replace those if it does.