Topic category: Help with Minecraft modding (Java Edition)
So i've been working on a mod, and in that mod i wanted to have some slime variants with different coloration, however if i use the base rendering that mcreator adds it doesn't render the slimes the same way so i made the class RenderSlimeOverride as shown
import net.minecraft.util.ResourceLocation;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderSlime;
import net.minecraft.entity.monster.EntitySlime;
public class RenderSlimeOverride extends RenderSlime
{
String texture;
public RenderSlimeOverride(RenderManager p_i47193_1_, String file)
{
texture = file;
super(p_i47193_1_);
}
@Override
protected ResourceLocation getEntityTexture(EntitySlime entity)
{
return new ResourceLocation(texture);
}
}
so that i can give the file i want to draw the slime textures from and render a regular slime like that, and as far as i know nothing seems wrong with that, then i tried to implement it to one of my slime variants using
import mod.mcreator.RenderSlimeOverride;
and it didn't work, i tried moving the mod around in the file system and modifying the import accordingly to be mod.RenderSlimeOverride; or just RenderSlimeOverride; and i keep getting error messages like these
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_dungeonSlimeFire.java:25: error: '.' expected
import RenderSlimeOverride;
^
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_dungeonSlimeFire.java:25: error: ';' expected
import RenderSlimeOverride;
^
C:\Pylo\MCreator179\forge\build\sources\main\java\mod\mcreator\mcreator_dungeonSlimeFire.java:27: error: class, interface, or enum expected
import java.util.Random;
^
My fire slime class is as follows, it's sloppy right now since it's still in progress, but this is what i have, this is currently with an iteration where RenderSlimeOverride is directly in the Source folder.
package mod.mcreator;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;import net.minecraft.world.World;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.EnumHand;
import net.minecraft.util.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.SoundEvents;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;
import net.minecraft.client.Minecraft;
import RenderSlimeOverride;import java.util.Random;
@SuppressWarnings("unchecked")
public class mcreator_dungeonSlimeFire {public int mobid = 1;
public static Object instance;public void load(FMLInitializationEvent event) {
}public void serverLoad(FMLServerStartingEvent event) {
}@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderSlimeOverride customRender = new RenderSlimeOverride(Minecraft.getMinecraft().getRenderManager(), "fireslime.png") {protected ResourceLocation getEntityTexture(Entity par1Entity) {
return new ResourceLocation("fireslime.png");
}
};
RenderingRegistry.registerEntityRenderingHandler(mcreator_dungeonSlimeFire.EntitydungeonSlimeFire.class,customRender);
}public int addFuel(ItemStack i) {
return 0;
}public void generateSurface(World w, Random r, int i, int j) {
}public void generateNether(World w, Random r, int i, int j) {
}public void preInit(FMLPreInitializationEvent event) {
EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:dungeonslimefire"),
mcreator_dungeonSlimeFire.EntitydungeonSlimeFire.class, "dungeonslimefire", mobid, instance, 64, 1, true, (153 << 16) + (255 << 8)
+ 153, (255 << 16) + (0 << 8) + 0);
}public static class EntitydungeonSlimeFire extends EntitySlime {
private boolean hasSplit;
World world = null;public EntitydungeonSlimeFire(World w) {
super(w);
world = w;
hasSplit = false;
experienceValue = 5;
this.isImmuneToFire = false;
setNoAI(!true);
}public EntitydungeonSlimeFire(World w, boolean split) {
super(w);
world = w;
hasSplit = split;
experienceValue = 5;
this.isImmuneToFire = false;
setNoAI(!true);
}/*
* @Override protected Item getDropItem() { return new
* ItemStack(mcreator_lootBagFireGeneric.block).getItem(); }
*/
@Override
protected net.minecraft.util.SoundEvent getAmbientSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(""));
}@Override
protected net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.slime.hurt"));
}@Override
protected net.minecraft.util.SoundEvent getDeathSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation("entity.slime.death"));
}@Override
public void onStruckByLightning(EntityLightningBolt entityLightningBolt) {
super.onStruckByLightning(entityLightningBolt);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
Entity entity = this;
}@Override
public void fall(float l, float d) {
super.fall(l, d);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
Entity entity = this;
}/**
* Called when the entity is attacked.
*/
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
if (source.isFireDamage())
amount /= 2;
boolean retval = super.attackEntityFrom(source, amount);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
Entity entity = this;
return retval;
}@Override
public void onDeath(DamageSource source) {
super.onDeath(source);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
Entity entity = this;
}protected EntitydungeonSlimeFire createInstance() {
return new EntitydungeonSlimeFire(this.world, true);
}@Override
public void setDead() {
int i = super.getSlimeSize();
if (!this.hasSplit) {
EntityItem entityToSpawn = new EntityItem(world, this.posX, this.posY, this.posZ, new ItemStack(this.getDropItem(), (int) (1)));
entityToSpawn.setPickupDelay(10);
world.spawnEntity(entityToSpawn);
}
EntityItem itemToSpawn = new EntityItem(world, this.posX, this.posY, this.posZ, new ItemStack(mcreator_fireGlob.block, (int) (1)));
itemToSpawn.setPickupDelay(10);
world.spawnEntity(itemToSpawn);
if (!this.world.isRemote && i > 1 && super.getHealth() <= 0.0F) {
int j = 2 + super.rand.nextInt(3);
for (int k = 0; k < j; ++k) {
float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
EntitydungeonSlimeFire entityslime = this.createInstance();
if (this.hasCustomName()) {
entityslime.setCustomNameTag(this.getCustomNameTag());
}
if (this.isNoDespawnRequired()) {
entityslime.enablePersistence();
}
entityslime.setSlimeSize(i / 2, true);
entityslime.setLocationAndAngles(this.posX + (double) f, this.posY + 0.5D, this.posZ + (double) f1,
this.rand.nextFloat() * 360.0F, 0.0F);
this.world.spawnEntity(entityslime);
}
}
super.setSlimeSize(1, false);
super.setDead();
}@Override
public boolean processInteract(EntityPlayer entity, EnumHand hand) {
boolean retval = super.processInteract(entity, hand);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
ItemStack itemstack = entity.getHeldItem(hand);
return retval;
}@Override
public void onKillEntity(EntityLivingBase entity) {
super.onKillEntity(entity);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
}protected void dealDamage(EntityLivingBase entityIn) {
int i = this.getSlimeSize();
if (this.canEntityBeSeen(entityIn) /*
* &&
* this.getDistanceSq(entityIn)
* < 0.6D * (double)i * 0.6D *
* (double)i
*/
&& entityIn.attackEntityFrom(DamageSource.causeMobDamage(this).setFireDamage(), (float) this.getAttackStrength() * 2 + 1)
&& entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 1 + (float) this.getAttackStrength() / 4)) {
this.playSound(SoundEvents.ENTITY_SLIME_ATTACK, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
this.applyEnchantments(this, entityIn);
}
}@Override
public void onEntityUpdate() {
super.onEntityUpdate();
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
Entity entity = this;
}@Override
public void onCollideWithPlayer(EntityPlayer entity) {
super.onCollideWithPlayer(entity);
int i = (int) this.posX;
int j = (int) this.posY;
int k = (int) this.posZ;
}@Override
protected float getSoundVolume() {
return 1.0F;
}
}
}
Never mind, i figured it out.