Jump to content

DarkAssassin

Members
  • Posts

    25
  • Joined

  • Last visited

DarkAssassin's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. it is now public
  2. it should be called by minecrafts iTickableEntity if somebody has time, please look at this code. Im new to this and want to learn whats wrong https://github.com/DarkAssassin11/SpawnTweaks
  3. i have now done this TileEntityType<?> type = TileEntityType.Builder.create(MobSpawnerTileEntity::new, BlockList.spawner).build(null); type.setRegistryName("minecraft:mob_spawner"); event.getRegistry().register(type); TEList.mob_spawner = type; and in the tile entity class done this TileEntityType.MOB_SPAWNER ==> TEList.mob_spawner and now the game neither crashes nor spews out error messages and now the entity is registered, but the tile entity doesn´t work as excpected. instead of behaving like the vanilla spawner (i used the vanilla code for spawners and added public void tick(BlockState state, World worldIn, BlockPos pos, Random random) { if (!worldIn.isRemote) { if (worldIn.isBlockPowered(pos)) { AbstractSpawner.isActivated = true; } else { AbstractSpawner.isActivated =false; } } }) but it behaves lika a normal block even when i comment the changes out. also no errors are shown
  4. i still have troubles creating a functional tile entity the Error log i´m getting is this: A TileEntity type me.spawntweak.lists.MobSpawnerTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author java.lang.RuntimeException: class me.spawntweak.lists.MobSpawnerTileEntity is missing a mapping [02:29:55] [Server thread/ERROR] [minecraft/Chunk]: A TileEntity type fabian.spawntweak.lists.MobSpawnerTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author java.lang.RuntimeException: class me.spawntweak.lists.MobSpawnerTileEntity is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.tileentity.TileEntity.write(TileEntity.java:66) ~[?:?] {re:classloading} at me.spawntweak.lists.MobSpawnerTileEntity.write(MobSpawnerTileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.world.chunk.Chunk.func_223134_j(Chunk.java:444) ~[?:?] {re:classloading} at net.minecraft.world.chunk.storage.ChunkSerializer.write(ChunkSerializer.java:303) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.func_219229_a(ChunkManager.java:677) ~[?:?] {re:classloading} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_241] {} at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) [?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) [?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) [?:1.8.0_241] {} at net.minecraft.world.server.ChunkManager.save(ChunkManager.java:336) [?:?] {re:classloading} at net.minecraft.world.server.ServerChunkProvider.save(ServerChunkProvider.java:309) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.save(ServerWorld.java:770) [?:?] {re:classloading} at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:528) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:571) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:235) [?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:685) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241] {} main: @Mod("spawntweak") public class SpawnTweak{ public static SpawnTweak instance; public static final String modid = "spawntweak"; private static final Logger logger = LogManager.getLogger(modid); public SpawnTweak() { instance=this; FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { logger.info("setup registered"); } private void clientRegistries(final FMLClientSetupEvent event) { logger.info("client registered"); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents{ @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( ItemList.spawner= new BlockItem(BlockList.spawner, new Item.Properties().group(ItemGroup.TRANSPORTATION)).setRegistryName(BlockList.spawner.getRegistryName()));} @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll( BlockList.spawner = new MobSpawner(MobSpawner.Properties.create(Material.IRON).hardnessAndResistance(3.0f, 3.0f).sound(SoundType.METAL)).setRegistryName("minecraft:spawner")); logger.info("Blocks registered"); } @SubscribeEvent public static void registerTileEntety(RegistryEvent.Register<TileEntityType<?>> event) { TileEntityType<?> type = TileEntityType.Builder.create(MobSpawnerTileEntity::new, BlockList.spawner).build(null); type.setRegistryName("minecraft:mob_spawner"); event.getRegistry().register(type); } } } Block public class MobSpawner extends Block{ public MobSpawner(Properties properties) { super(Properties.create(Material.IRON).hardnessAndResistance(3.0f, 3.0f).sound(SoundType.METAL)); } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new MobSpawnerTileEntity(); } public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override public boolean hasTileEntity(BlockState state) { return true; } } Tile Entity public class MobSpawnerTileEntity extends TileEntity implements ITickableTileEntity { private final AbstractSpawner spawnerLogic = new AbstractSpawner() { public void broadcastEvent(int id) { MobSpawnerTileEntity.this.world.addBlockEvent(MobSpawnerTileEntity.this.pos, Blocks.SPAWNER, id, 0); } public World getWorld() { return MobSpawnerTileEntity.this.world; } public BlockPos getSpawnerPosition() { return MobSpawnerTileEntity.this.pos; } public void setNextSpawnData(WeightedSpawnerEntity nextSpawnData) { super.setNextSpawnData(nextSpawnData); if (this.getWorld() != null) { BlockState blockstate = this.getWorld().getBlockState(this.getSpawnerPosition()); this.getWorld().notifyBlockUpdate(MobSpawnerTileEntity.this.pos, blockstate, blockstate, 4); } } }; public void tick(BlockState state, World worldIn, BlockPos pos, Random random) { if (!worldIn.isRemote) { if (worldIn.isBlockPowered(pos)) { AbstractSpawner.isActivated = true; } else { AbstractSpawner.isActivated =false; } } } public MobSpawnerTileEntity() { super(TileEntityType.MOB_SPAWNER); } public void read(CompoundNBT compound) { super.read(compound); this.spawnerLogic.read(compound); } public CompoundNBT write(CompoundNBT compound) { super.write(compound); this.spawnerLogic.write(compound); return compound; } public void tick() { this.spawnerLogic.tick(); } @Nullable public SUpdateTileEntityPacket getUpdatePacket() { return new SUpdateTileEntityPacket(this.pos, 1, this.getUpdateTag()); } public CompoundNBT getUpdateTag() { CompoundNBT compoundnbt = this.write(new CompoundNBT()); compoundnbt.remove("SpawnPotentials"); return compoundnbt; } public boolean receiveClientEvent(int id, int type) { return this.spawnerLogic.setDelayToMin(id) ? true : super.receiveClientEvent(id, type); } public boolean onlyOpsCanSetNbt() { return true; } public AbstractSpawner getSpawnerBaseLogic() { return this.spawnerLogic; } } Abstract Spawner public abstract class AbstractSpawner { private static final Logger LOGGER = LogManager.getLogger(); public static boolean isActivated; private int spawnDelay = 20; private final List<WeightedSpawnerEntity> potentialSpawns = Lists.newArrayList(); private WeightedSpawnerEntity spawnData = new WeightedSpawnerEntity(); private double mobRotation; private double prevMobRotation; private int minSpawnDelay = 200; private int maxSpawnDelay = 800; private int spawnCount = 4; private Entity cachedEntity; private int maxNearbyEntities = 6; private int activatingRangeFromPlayer = 16; private int spawnRange = 4; @SuppressWarnings("resource") @Nullable private ResourceLocation getEntityId() { String s = this.spawnData.getNbt().getString("id"); try { return StringUtils.isNullOrEmpty(s) ? null : new ResourceLocation(s); } catch (ResourceLocationException var4) { BlockPos blockpos = this.getSpawnerPosition(); LOGGER.warn("Invalid entity id '{}' at spawner {}:[{},{},{}]", s, this.getWorld().dimension.getType(), blockpos.getX(), blockpos.getY(), blockpos.getZ()); return null; } } @SuppressWarnings("deprecation") public void setEntityType(EntityType<?> type) { this.spawnData.getNbt().putString("id", Registry.ENTITY_TYPE.getKey(type).toString()); } /** * Returns true if there's a player close enough to this mob spawner to activate it. */ public boolean isActivated() { BlockPos blockpos = this.getSpawnerPosition(); return this.getWorld().isPlayerWithin((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D, (double)this.activatingRangeFromPlayer); } public void tick() { if (!this.isActivated()||!isActivated) { this.prevMobRotation = this.mobRotation; } else { World world = this.getWorld(); BlockPos blockpos = this.getSpawnerPosition(); if (world.isRemote) { double d3 = (double)((float)blockpos.getX() + world.rand.nextFloat()); double d4 = (double)((float)blockpos.getY() + world.rand.nextFloat()); double d5 = (double)((float)blockpos.getZ() + world.rand.nextFloat()); world.addParticle(ParticleTypes.SMOKE, d3, d4, d5, 0.0D, 0.0D, 0.0D); world.addParticle(ParticleTypes.FLAME, d3, d4, d5, 0.0D, 0.0D, 0.0D); if (this.spawnDelay > 0) { --this.spawnDelay; } this.prevMobRotation = this.mobRotation; this.mobRotation = (this.mobRotation + (double)(1000.0F / ((float)this.spawnDelay + 200.0F))) % 360.0D; } else { if (this.spawnDelay == -1) { this.resetTimer(); } if (this.spawnDelay > 0) { --this.spawnDelay; return; } boolean flag = false; for(int i = 0; i < this.spawnCount; ++i) { CompoundNBT compoundnbt = this.spawnData.getNbt(); Optional<EntityType<?>> optional = EntityType.readEntityType(compoundnbt); if (!optional.isPresent()) { this.resetTimer(); return; } ListNBT listnbt = compoundnbt.getList("Pos", 6); int j = listnbt.size(); double d0 = j >= 1 ? listnbt.getDouble(0) : (double)blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double)this.spawnRange + 0.5D; double d1 = j >= 2 ? listnbt.getDouble(1) : (double)(blockpos.getY() + world.rand.nextInt(3) - 1); double d2 = j >= 3 ? listnbt.getDouble(2) : (double)blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double)this.spawnRange + 0.5D; if (world.areCollisionShapesEmpty(optional.get().func_220328_a(d0, d1, d2)) && EntitySpawnPlacementRegistry.func_223515_a(optional.get(), world.getWorld(), SpawnReason.SPAWNER, new BlockPos(d0, d1, d2), world.getRandom())) { Entity entity = EntityType.func_220335_a(compoundnbt, world, (p_221408_6_) -> { p_221408_6_.setLocationAndAngles(d0, d1, d2, p_221408_6_.rotationYaw, p_221408_6_.rotationPitch); return p_221408_6_; }); if (entity == null) { this.resetTimer(); return; } int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), (double)(blockpos.getX() + 1), (double)(blockpos.getY() + 1), (double)(blockpos.getZ() + 1))).grow((double)this.spawnRange)).size(); if (k >= this.maxNearbyEntities) { this.resetTimer(); return; } entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, world.rand.nextFloat() * 360.0F, 0.0F); if (entity instanceof MobEntity) { MobEntity mobentity = (MobEntity)entity; if (!EventFactory.canEntitySpawnSpawner(mobentity, world, (float)entity.posX, (float)entity.posY, (float)entity.posZ, this)) { continue; } if (this.spawnData.getNbt().size() == 1 && this.spawnData.getNbt().contains("id", 8)) { ((MobEntity)entity).onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.SPAWNER, (ILivingEntityData)null, (CompoundNBT)null); } } this.func_221409_a(entity); world.playEvent(2004, blockpos, 0); if (entity instanceof MobEntity) { ((MobEntity)entity).spawnExplosionParticle(); } flag = true; } } if (flag) { this.resetTimer(); } } } } private void func_221409_a(Entity p_221409_1_) { if (this.getWorld().addEntity(p_221409_1_)) { for(Entity entity : p_221409_1_.getPassengers()) { this.func_221409_a(entity); } } } @SuppressWarnings("resource") private void resetTimer() { if (this.maxSpawnDelay <= this.minSpawnDelay) { this.spawnDelay = this.minSpawnDelay; } else { int i = this.maxSpawnDelay - this.minSpawnDelay; this.spawnDelay = this.minSpawnDelay + this.getWorld().rand.nextInt(i); } if (!this.potentialSpawns.isEmpty()) { this.setNextSpawnData(WeightedRandom.getRandomItem(this.getWorld().rand, this.potentialSpawns)); } this.broadcastEvent(1); } @SuppressWarnings("resource") public void read(CompoundNBT nbt) { this.spawnDelay = nbt.getShort("Delay"); this.potentialSpawns.clear(); if (nbt.contains("SpawnPotentials", 9)) { ListNBT listnbt = nbt.getList("SpawnPotentials", 10); for(int i = 0; i < listnbt.size(); ++i) { this.potentialSpawns.add(new WeightedSpawnerEntity(listnbt.getCompound(i))); } } if (nbt.contains("SpawnData", 10)) { this.setNextSpawnData(new WeightedSpawnerEntity(1, nbt.getCompound("SpawnData"))); } else if (!this.potentialSpawns.isEmpty()) { this.setNextSpawnData(WeightedRandom.getRandomItem(this.getWorld().rand, this.potentialSpawns)); } if (nbt.contains("MinSpawnDelay", 99)) { this.minSpawnDelay = nbt.getShort("MinSpawnDelay"); this.maxSpawnDelay = nbt.getShort("MaxSpawnDelay"); this.spawnCount = nbt.getShort("SpawnCount"); } if (nbt.contains("MaxNearbyEntities", 99)) { this.maxNearbyEntities = nbt.getShort("MaxNearbyEntities"); this.activatingRangeFromPlayer = nbt.getShort("RequiredPlayerRange"); } if (nbt.contains("SpawnRange", 99)) { this.spawnRange = nbt.getShort("SpawnRange"); } if (this.getWorld() != null) { this.cachedEntity = null; } } public CompoundNBT write(CompoundNBT compound) { ResourceLocation resourcelocation = this.getEntityId(); if (resourcelocation == null) { return compound; } else { compound.putShort("Delay", (short)this.spawnDelay); compound.putShort("MinSpawnDelay", (short)this.minSpawnDelay); compound.putShort("MaxSpawnDelay", (short)this.maxSpawnDelay); compound.putShort("SpawnCount", (short)this.spawnCount); compound.putShort("MaxNearbyEntities", (short)this.maxNearbyEntities); compound.putShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer); compound.putShort("SpawnRange", (short)this.spawnRange); compound.put("SpawnData", this.spawnData.getNbt().copy()); ListNBT listnbt = new ListNBT(); if (this.potentialSpawns.isEmpty()) { listnbt.add(this.spawnData.toCompoundTag()); } else { for(WeightedSpawnerEntity weightedspawnerentity : this.potentialSpawns) { listnbt.add(weightedspawnerentity.toCompoundTag()); } } compound.put("SpawnPotentials", listnbt); return compound; } } @OnlyIn(Dist.CLIENT) public Entity getCachedEntity() { if (this.cachedEntity == null) { this.cachedEntity = EntityType.func_220335_a(this.spawnData.getNbt(), this.getWorld(), Function.identity()); if (this.spawnData.getNbt().size() == 1 && this.spawnData.getNbt().contains("id", 8) && this.cachedEntity instanceof MobEntity) { ((MobEntity)this.cachedEntity).onInitialSpawn(this.getWorld(), this.getWorld().getDifficultyForLocation(new BlockPos(this.cachedEntity)), SpawnReason.SPAWNER, (ILivingEntityData)null, (CompoundNBT)null); } } return this.cachedEntity; } /** * Sets the delay to minDelay if parameter given is 1, else return false. */ public boolean setDelayToMin(int delay) { if (delay == 1 && this.getWorld().isRemote) { this.spawnDelay = this.minSpawnDelay; return true; } else { return false; } } public void setNextSpawnData(WeightedSpawnerEntity nextSpawnData) { this.spawnData = nextSpawnData; } public abstract void broadcastEvent(int id); public abstract World getWorld(); public abstract BlockPos getSpawnerPosition(); @OnlyIn(Dist.CLIENT) public double getMobRotation() { return this.mobRotation; } @OnlyIn(Dist.CLIENT) public double getPrevMobRotation() { return this.prevMobRotation; } @Nullable public Entity getSpawnerEntity() { return null; } }
  5. my bad. the code is older and my setup function now looks like this private void setup(final FMLCommonSetupEvent event) { logger.info("setup registered"); } private void clientRegistries(final FMLClientSetupEvent event) { logger.info("client registered"); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents{ @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( ItemList.spawner= new BlockItem(BlockList.spawner, new Item.Properties().group(ItemGroup.TRANSPORTATION)).setRegistryName(BlockList.spawner.getRegistryName()));} @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll( BlockList.spawner = new MobSpawner(MobSpawner.Properties.create(Material.IRON).hardnessAndResistance(3.0f, 3.0f).sound(SoundType.METAL)).setRegistryName("minecraft:spawner")); logger.info("Blocks registered"); } @SubscribeEvent public static void registerTileEntety(RegistryEvent.Register<TileEntityType<?>> event) { TileEntityType<?> type = TileEntityType.Builder.create(MobSpawnerTileEntity::new, BlockList.spawner).build(null); type.setRegistryName("minecraft:mob_spawner"); event.getRegistry().register(type); }
  6. i´ve detailed it in another post but Tile Entity import java.util.Random; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.play.server.SUpdateTileEntityPacket; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.WeightedSpawnerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class MobSpawnerTileEntity extends TileEntity implements ITickableTileEntity { private final AbstractSpawner spawnerLogic = new AbstractSpawner() { public void broadcastEvent(int id) { MobSpawnerTileEntity.this.world.addBlockEvent(MobSpawnerTileEntity.this.pos, Blocks.SPAWNER, id, 0); } public World getWorld() { return MobSpawnerTileEntity.this.world; } public BlockPos getSpawnerPosition() { return MobSpawnerTileEntity.this.pos; } public void setNextSpawnData(WeightedSpawnerEntity nextSpawnData) { super.setNextSpawnData(nextSpawnData); if (this.getWorld() != null) { BlockState blockstate = this.getWorld().getBlockState(this.getSpawnerPosition()); this.getWorld().notifyBlockUpdate(MobSpawnerTileEntity.this.pos, blockstate, blockstate, 4); } } }; public void tick(BlockState state, World worldIn, BlockPos pos, Random random) { if (!worldIn.isRemote) { if (worldIn.isBlockPowered(pos)) { AbstractSpawner.isActivated = true; } else { AbstractSpawner.isActivated =false; } } } public MobSpawnerTileEntity() { super(TileEntityType.MOB_SPAWNER); } public void read(CompoundNBT compound) { super.read(compound); this.spawnerLogic.read(compound); } public CompoundNBT write(CompoundNBT compound) { super.write(compound); this.spawnerLogic.write(compound); return compound; } public void tick() { this.spawnerLogic.tick(); } @Nullable public SUpdateTileEntityPacket getUpdatePacket() { return new SUpdateTileEntityPacket(this.pos, 1, this.getUpdateTag()); } public CompoundNBT getUpdateTag() { CompoundNBT compoundnbt = this.write(new CompoundNBT()); compoundnbt.remove("SpawnPotentials"); return compoundnbt; } public boolean receiveClientEvent(int id, int type) { return this.spawnerLogic.setDelayToMin(id) ? true : super.receiveClientEvent(id, type); } public boolean onlyOpsCanSetNbt() { return true; } public AbstractSpawner getSpawnerBaseLogic() { return this.spawnerLogic; } } Block import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.world.IBlockReader; public class MobSpawner extends Block{ public MobSpawner(Properties properties) { super(Properties.create(Material.IRON).hardnessAndResistance(3.0f, 3.0f).sound(SoundType.METAL)); } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new MobSpawnerTileEntity(); } public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override public boolean hasTileEntity(BlockState state) { return true; } } is it right that i have this in my tile entity or do i need to put the function into the block class public void tick(BlockState state, World worldIn, BlockPos pos, Random random) { if (!worldIn.isRemote) { if (worldIn.isBlockPowered(pos)) { AbstractSpawner.isActivated = true; } else { AbstractSpawner.isActivated =false; } } }
  7. i thought so but i actually just have a questionmark. do you know what type a spawner is? @SubscribeEvent public static void registerTileEntety(RegistryEvent.Register<TileEntityType<?>> event) { TileEntityType<?> type = TileEntityType.Builder.create(MobSpawnerTileEntity::new, BlockList.spawner).build(null); type.setRegistryName("minecraft:spawner"); event.getRegistry().register(type); } if type.setRegistryName("minecraft:spawner") it is just a block and if type.setRegistryName("minecraft:mob_spawner") the game crashes with this error log [02:29:55] [Server thread/ERROR] [minecraft/Chunk]: A TileEntity type fabian.spawntweak.lists.MobSpawnerTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author java.lang.RuntimeException: class fabian.spawntweak.lists.MobSpawnerTileEntity is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.tileentity.TileEntity.write(TileEntity.java:66) ~[?:?] {re:classloading} at fabian.spawntweak.lists.MobSpawnerTileEntity.write(MobSpawnerTileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.world.chunk.Chunk.func_223134_j(Chunk.java:444) ~[?:?] {re:classloading} at net.minecraft.world.chunk.storage.ChunkSerializer.write(ChunkSerializer.java:303) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.func_219229_a(ChunkManager.java:677) ~[?:?] {re:classloading} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_241] {} at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) [?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) [?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) [?:1.8.0_241] {} at net.minecraft.world.server.ChunkManager.save(ChunkManager.java:336) [?:?] {re:classloading} at net.minecraft.world.server.ServerChunkProvider.save(ServerChunkProvider.java:309) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.save(ServerWorld.java:770) [?:?] {re:classloading} at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:528) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:571) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:235) [?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:685) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241] {} +the main reson is spawntweak.lists.MobSpawnerTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author java.lang.RuntimeException: class fabian.spawntweak.lists.MobSpawnerTileEntity is missing a mapping! i
  8. the only thin changet for me is that i now have this item in a creative tab
  9. ok i will try that but what i´m wondering then is: why is the tile entity not loading and just a block when i comment out the TE out of my code when i place the vanilla item spawner
  10. I don't really need to do that in my case because I'm using the same ID as a Standart vanilla spawner (im able to place my block with the vanilla item) I'm now only having troubles getting the tile entity to work correctly. see this on my newer post.
  11. i just realised that i dont override, i just make a block with the same id but the tile entity doesn´t correctly work when using a different id either he said that i should override Blocks.SPAWNER but how can i do that? when using the id minecraft:spawner the spawner block is just a block and minecraft:mob_spawner does not exist but the log still says : [Server thread/WARN] [minecraft/TileEntity]: Block entity invalid: minecraft:mob_spawner but when using the id minecraft:mob_spawner the game instantly crashes whan confronted with that block and this error log: [02:29:55] [Server thread/ERROR] [minecraft/Chunk]: A TileEntity type fabian.spawntweak.lists.MobSpawnerTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author java.lang.RuntimeException: class fabian.spawntweak.lists.MobSpawnerTileEntity is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.tileentity.TileEntity.write(TileEntity.java:66) ~[?:?] {re:classloading} at fabian.spawntweak.lists.MobSpawnerTileEntity.write(MobSpawnerTileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.world.chunk.Chunk.func_223134_j(Chunk.java:444) ~[?:?] {re:classloading} at net.minecraft.world.chunk.storage.ChunkSerializer.write(ChunkSerializer.java:303) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.func_219229_a(ChunkManager.java:677) ~[?:?] {re:classloading} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_241] {} at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) [?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) [?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) [?:1.8.0_241] {} at net.minecraft.world.server.ChunkManager.save(ChunkManager.java:336) [?:?] {re:classloading} at net.minecraft.world.server.ServerChunkProvider.save(ServerChunkProvider.java:309) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.save(ServerWorld.java:770) [?:?] {re:classloading} at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:528) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:571) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:235) [?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:685) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241] {} ok i figured out that if the tileentityid is minecraft:mob_spawner the game crashes if the blockid is minecraft:spawner it replaces the original one if the tileentityid is minecraft:spawner it does nothing.
  12. i want to modify the vanilla spawner and in another Topic someone said that the best way to do so is to make your own spawner and override the registry entry with your own
  13. it doesn´t matter how long i look, i cannot find the error. the log says: [Server thread/WARN] [minecraft/TileEntity]: Block entity invalid: minecraft:mob_spawner but i dont find or remember writing mob_spawner i always wrote spawner. Edit: ok the official tag is minecraft:mob_spawner and not spawner, but why is it gone? Edit2: ive now changed all minecraft:spawner to minecraft:mob_spawner. now i cannot pick up the "spawners"(prev. just blocks without the tile entity) with middle click anymore and after using / setblock minecraft crashed and gave this output: [02:29:55] [Server thread/ERROR] [minecraft/Chunk]: A TileEntity type fabian.spawntweak.lists.MobSpawnerTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author java.lang.RuntimeException: class fabian.spawntweak.lists.MobSpawnerTileEntity is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.tileentity.TileEntity.write(TileEntity.java:66) ~[?:?] {re:classloading} at fabian.spawntweak.lists.MobSpawnerTileEntity.write(MobSpawnerTileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.world.chunk.Chunk.func_223134_j(Chunk.java:444) ~[?:?] {re:classloading} at net.minecraft.world.chunk.storage.ChunkSerializer.write(ChunkSerializer.java:303) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.func_219229_a(ChunkManager.java:677) ~[?:?] {re:classloading} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_241] {} at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) [?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) [?:1.8.0_241] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) [?:1.8.0_241] {} at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:1.8.0_241] {} at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) [?:1.8.0_241] {} at net.minecraft.world.server.ChunkManager.save(ChunkManager.java:336) [?:?] {re:classloading} at net.minecraft.world.server.ServerChunkProvider.save(ServerChunkProvider.java:309) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.save(ServerWorld.java:770) [?:?] {re:classloading} at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:528) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:571) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:235) [?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:685) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241] {} someone on here with the same error said that he forgot to register it but i thought i had registered it here: @SubscribeEvent public static void registerTileEntety(RegistryEvent.Register<TileEntityType<?>> event) { TileEntityType<?> type = TileEntityType.Builder.create(MobSpawnerTileEntity::new, BlockList.spawner).build(null); type.setRegistryName("minecraft:spawner"); event.getRegistry().register(type); } Edit 3 : i have now(for the vanilla textures that are for the block minecraft:spawner) changed the block in blockList back to spawner but left the id minecraft:mob_spawner. now the texture is shown again and if placed after /give(for some reason the command was now /give (id:)minecraft:spawner) the pig and fire particles appear for a brief moment and then minecraft crashes again with the same error
  14. I have a code for a tile entity(modified mob spawner code) and now i have troubles making it a real block that i can place. how do i register something like that correctly? @Mod("spawntweak") public class SpawnTweak{ public static SpawnTweak instance; public static final String modid = "spawntweak"; private static final Logger logger = LogManager.getLogger(modid); public SpawnTweak() { instance=this; FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { logger.info("setup registered"); } private void clientRegistries(final FMLClientSetupEvent event) { logger.info("client registered"); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents{ @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll( BlockList.spawner = new Block(Block.Properties.setRegistryName("minecraft:spawner"). ...) ); logger.info("Blocks registered"); } this is how i load my blocks
  15. i copied the vanilla spawner classes and added another condition for it to be active but in the copy of the code it gives an error and says : but there is nothing that should be missing the line of code is if (!net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(mobentity, world, (float)entity.posX, (float)entity.posY, (float)entity.posZ, this)) { continue; } nevermind i just need to copy and edit parts of the event factory, too.
×
×
  • Create New...

Important Information

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