Jump to content

samjviana

Members
  • Posts

    82
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by samjviana

  1. I've an Custom Ore that i want to add to World Gen to the whole Overworld, in previous versions of Minecraft I was able to use ForgeRegistries.BIOMES but that field doesn't exist on ForgeRegistries anymore I've done an googling but sadly i couldn't find an solution for this.
  2. Just tried that, and it worked. Thank you!!
  3. I've made an Custom Slime Entity that his color works like Sheep's color. So i have one white slime template and for each slime created i "randomize" it's color. The problem is that when the slime dies, it's childs spawn with the template color and not with the "parent" color. I've already googled around and searched betwen the classes but ended up with nothing, so how can i pass the color to the new little slimes when a big one dies? the Entity code: package net.ddns.samjviana.morethings.entity; import java.util.Arrays; import java.util.Map; import java.util.Random; import java.util.stream.Collectors; import com.google.common.collect.Maps; import net.minecraft.entity.EntitySize; import net.minecraft.entity.EntityType; import net.minecraft.entity.ILivingEntityData; import net.minecraft.entity.Pose; import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.attributes.AttributeModifierMap; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.item.DyeColor; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.util.DamageSource; import net.minecraft.util.math.MathHelper; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.IWorld; import net.minecraft.world.World; public class ColoredSlimeEntity extends SlimeEntity { private static final DataParameter<Byte> DYE_COLOR = EntityDataManager.createKey(SlimeEntity.class, DataSerializers.BYTE); private static final Map<DyeColor, float[]> DYE_TO_RGB = Maps.newEnumMap(Arrays.stream(DyeColor.values()).collect(Collectors.toMap( (DyeColor dyeColor) -> { return dyeColor; }, ColoredSlimeEntity::createSlimeColor))); public ColoredSlimeEntity(final EntityType<? extends ColoredSlimeEntity> entityType, final World world) { super(entityType, world); } @Override protected void setSlimeSize(int size, boolean resetHealth) { super.setSlimeSize(size, resetHealth); } @Override protected boolean spawnCustomParticles() { int i = this.getSlimeSize(); for(int j = 0; j < i * 8; ++j) { float f = this.rand.nextFloat() * ((float)Math.PI * 2F); float f1 = this.rand.nextFloat() * 0.5F + 0.5F; float f2 = MathHelper.sin(f) * (float)i * 0.5F * f1; float f3 = MathHelper.cos(f) * (float)i * 0.5F * f1; this.world.addParticle(this.getSquishParticle(), this.getPosX() + (double)f2, this.getPosY(), this.getPosZ() + (double)f3, 0.0D, 0.0D, 0.0D); } return super.spawnCustomParticles(); } @Override public void onDeath(DamageSource cause) { // TODO Auto-generated method stub super.onDeath(cause); } public static float[] getDyeRgb(DyeColor dyeColor) { return DYE_TO_RGB.get(dyeColor); } private static float[] createSlimeColor(DyeColor dyeColorIn) { if (dyeColorIn == DyeColor.WHITE) { return new float[]{0.9019608F, 0.9019608F, 0.9019608F}; } else { float[] afloat = dyeColorIn.getColorComponentValues(); return new float[]{afloat[0] * 0.75F, afloat[1] * 0.75F, afloat[2] * 0.75F}; } } public static AttributeModifierMap getAttributes() { AttributeModifierMap.MutableAttribute attributes = SlimeEntity.func_233666_p_(); attributes.func_233814_a_(Attributes.field_233823_f_); return attributes.func_233813_a_(); } @Override public ILivingEntityData onInitialSpawn(IWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, ILivingEntityData spawnDataIn, CompoundNBT dataTag) { this.setSlimeColor(getRandomSlimeColor(worldIn.getRandom())); return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); } public void setSlimeColor(DyeColor color) { byte b0 = this.dataManager.get(DYE_COLOR); this.dataManager.set(DYE_COLOR, (byte)(b0 & 240 | color.getId() & 15)); } public static DyeColor getRandomSlimeColor(Random random) { int i = random.nextInt(15); return DyeColor.byId(i); } @Override protected void registerData() { super.registerData(); this.dataManager.register(DYE_COLOR, (byte)0); } public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); compound.putByte("Color", (byte)this.getSlimeColor().getId()); } public DyeColor getSlimeColor() { return DyeColor.byId(this.dataManager.get(DYE_COLOR) & 15); } @Override public EntitySize getSize(Pose poseIn) { return super.getSize(poseIn); } @Override public int getSlimeSize() { return super.getSlimeSize(); } }
  4. Looking at EntitySheep code helped a lot, thanks.
  5. Actually your answer in the topic 1.16.1 Custom Entity attributes helped me a lot understanding how to work with AttributeModifierMap, and i managed to finish the entity, thank you. Now i'm trying to change the color of the slime. instead of having a bunch of entities i want an "template" that randomize in many colors (just like it happens with leaves), so i'll have slimes of many colors, i know it's not an original idea but it's just for practice. Should i open another topic about this? Sorry by the english by the way XD.
  6. I'm new at this minecraft mod thing, and i was trying to make custom entities. I got to make an pig and a zombie, but failed on making a slime. I'm using the "GlobalEntityTypeAttributes#put" to define the Attributes of the entity, along with SlimeEntity#func_233666_p_ and SlimeEntity#func_233639_cI_ to get AttributeModifierMap. But when i use the SlimeEntity#func_233666_p_ i get: java.lang.IllegalArgumentException: Can't find attribute minecraft:generic.follow_range at net.minecraft.entity.ai.attributes.AttributeModifierMap.func_233810_d_(AttributeModifierMap.java:21) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.ai.attributes.AttributeModifierMap.func_233804_a_(AttributeModifierMap.java:28) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.ai.attributes.AttributeModifierManager.func_233795_c_(AttributeModifierManager.java:67) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.LivingEntity.func_233637_b_(LivingEntity.java:1848) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.pathfinding.PathNavigator.<init>(PathNavigator.java:47) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.pathfinding.GroundPathNavigator.<init>(GroundPathNavigator.java:16) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.MobEntity.createNavigator(MobEntity.java:135) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.MobEntity.<init>(MobEntity.java:114) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.monster.SlimeEntity.<init>(SlimeEntity.java:54) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.ddns.samjviana.morethings.entity.BlueSlimeEntity.<init>(BlueSlimeEntity.java:9) ~[main/:?] at net.minecraft.entity.EntityType.create(EntityType.java:442) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.EntityType.lambda$loadEntityUnchecked$1(EntityType.java:453) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at java.util.Optional.map(Optional.java:215) ~[?:1.8.0_221] at net.minecraft.entity.EntityType.loadEntityUnchecked(EntityType.java:452) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.EntityType.loadEntity(EntityType.java:510) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.EntityType.func_220335_a(EntityType.java:492) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.command.impl.SummonCommand.summonEntity(SummonCommand.java:49) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.command.impl.SummonCommand.lambda$register$1(SummonCommand.java:33) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:262) ~[brigadier-1.0.17.jar:?] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:176) ~[brigadier-1.0.17.jar:?] at net.minecraft.command.Commands.handleCommand(Commands.java:218) ~[?:?] at net.minecraft.network.play.ServerPlayNetHandler.handleSlashCommand(ServerPlayNetHandler.java:1085) ~[?:?] at net.minecraft.network.play.ServerPlayNetHandler.processChatMessage(ServerPlayNetHandler.java:1065) ~[?:?] at net.minecraft.network.play.client.CChatMessagePacket.processPacket(CChatMessagePacket.java:40) ~[?:?] at net.minecraft.network.play.client.CChatMessagePacket.processPacket(CChatMessagePacket.java:8) ~[?:?] at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[?:?] at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[?:?] at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[?:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:763) ~[?:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:157) ~[?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[?:?] at net.minecraft.server.MinecraftServer.driveOneInternal(MinecraftServer.java:746) ~[?:?] at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:740) ~[?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:122) ~[?:?] at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:726) ~[?:?] at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:669) ~[?:?] at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:231) ~[?:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221] And with SlimeEntity#func_233639_cI_ i get: net.minecraft.crash.ReportedException: Loading entity NBT at net.minecraft.entity.Entity.read(Entity.java:1660) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.EntityType.lambda$loadEntityUnchecked$2(EntityType.java:455) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.util.Util.acceptOrElse(Util.java:319) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.EntityType.loadEntityUnchecked(EntityType.java:452) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.EntityType.loadEntity(EntityType.java:510) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.EntityType.func_220335_a(EntityType.java:492) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.command.impl.SummonCommand.summonEntity(SummonCommand.java:49) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.command.impl.SummonCommand.lambda$register$1(SummonCommand.java:33) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:262) ~[brigadier-1.0.17.jar:?] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:176) ~[brigadier-1.0.17.jar:?] at net.minecraft.command.Commands.handleCommand(Commands.java:218) ~[?:?] at net.minecraft.network.play.ServerPlayNetHandler.handleSlashCommand(ServerPlayNetHandler.java:1085) ~[?:?] at net.minecraft.network.play.ServerPlayNetHandler.processChatMessage(ServerPlayNetHandler.java:1065) ~[?:?] at net.minecraft.network.play.client.CChatMessagePacket.processPacket(CChatMessagePacket.java:40) ~[?:?] at net.minecraft.network.play.client.CChatMessagePacket.processPacket(CChatMessagePacket.java:8) ~[?:?] at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[?:?] at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[?:?] at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[?:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:763) ~[?:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:157) ~[?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[?:?] at net.minecraft.server.MinecraftServer.driveOneInternal(MinecraftServer.java:746) ~[?:?] at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:740) ~[?:?] at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) ~[?:?] at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:725) ~[?:?] at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:669) ~[?:?] at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:231) ~[?:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221] Caused by: java.lang.NullPointerException at net.minecraft.entity.monster.SlimeEntity.setSlimeSize(SlimeEntity.java:80) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.monster.SlimeEntity.readAdditional(SlimeEntity.java:110) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] at net.minecraft.entity.Entity.read(Entity.java:1645) ~[forge-1.16.1-32.0.24_mapped_snapshot_20200514-1.16-recomp.jar:?] ... 28 more
×
×
  • Create New...

Important Information

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