Jump to content

Sq3xd

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by Sq3xd

  1. My idea was that it will be obtainable by killing mob, and if there's a jar nearby it would be filled with that mob soul
  2. It's like a spawn egg, but you interact with special block and then it will make a copy of entity
  3. Actually no, because it's different items
  4. I created an SOUL_JAR Item that has been registered for each mob like - mod:soul_jar_minecraft_cow etc.. but it all has different registry names, i have a model file name soul_jar.json and i want to know how to bind each of those items to this class (When mod iterates through all of vanilla mobs and registering items for them). I didn't found any info about it because all of info is outdated, and forge docs is complicated asf (i wish there would be more examples) i also used AI but it showing me only outdated info, but theres some code where i registering my item and trying to bind it to model -> public static void register(IEventBus eventBus){ ITEMS.register(eventBus); Set<ResourceLocation> entityKeyList = ForgeRegistries.ENTITY_TYPES.getKeys(); for (ResourceLocation k : entityKeyList) { EntityType<?> entityType = ForgeRegistries.ENTITY_TYPES.getValue(k); if (!entityType.getCategory().equals(MobCategory.MISC)) { RegistryObject<Item> SOUL_JAR = ITEMS.register("soul_jar" + '_' + k.toString().replace(':', '_').replace('.', '_'), () -> new JarItem(new Item.Properties().rarity(Rarity.RARE).tab(ModTabs.MAGICAL_OBSESSION_JARS), entityType)); if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.CLIENT) { ItemModelShaper itemModelShaper = Minecraft.getInstance().getItemRenderer().getItemModelShaper(); itemModelShaper.register(SOUL_JAR.get().asItem(), new ModelResourceLocation("item.soul_jar", "inventory")); } } } } I also have more questions like how to iterate through all other mods mobs also, or render mob inside of a jar in inventory, but i will try to figure it out.
  5. It's probably a stupid question, but i can't find a way to get list of all entities. I want to register Item for each Mob Entity but i cant find method to get list of all entities, that's why it's a stupid question but maybe someone call tell me where's that method.
  6. Ok, thanks!
  7. I making a pipe that can change it state if other pipe is placed to it, but just setting state value doesn't work. Here's my pipe code -> public class MagicPipeBlockEntity extends BlockEntity { public MagicPipeBlockEntity(BlockPos pos, BlockState state) { super(ModBlockEntities.MAGIC_PIPE.get(), pos, state); } // Tick public static void tick(Level level, BlockPos pos, BlockState state, MagicPipeBlockEntity entity) { if (level.isClientSide){ if (level.getBlockState(pos.above()).is(ModBlocks.MAGIC_PIPE.get())){ entity.getBlockState().setValue(BlockStateProperties.UP, true); state.setValue(BlockStateProperties.UP, true); System.out.println("YES"); } } if (!level.isClientSide) { if (level.getBlockState(pos.above()).is(ModBlocks.MAGIC_PIPE.get())){ entity.getBlockState().setValue(BlockStateProperties.UP, true); } } } } Also MagicPipeBlock code -> public class MagicPipeBlock extends Block implements EntityBlock { public static final BooleanProperty UP = BlockStateProperties.UP; public static final BooleanProperty DOWN = BlockStateProperties.DOWN; public static final BooleanProperty NORTH = BlockStateProperties.NORTH; public static final BooleanProperty SOUTH = BlockStateProperties.SOUTH; public static final BooleanProperty EAST = BlockStateProperties.EAST; public static final BooleanProperty WEST = BlockStateProperties.WEST; public MagicPipeBlock(Properties properties){ super(properties); this.registerDefaultState(this.stateDefinition.any().setValue(UP, false)); this.registerDefaultState(this.stateDefinition.any().setValue(DOWN, false)); this.registerDefaultState(this.stateDefinition.any().setValue(NORTH, false)); this.registerDefaultState(this.stateDefinition.any().setValue(SOUTH, false)); this.registerDefaultState(this.stateDefinition.any().setValue(EAST, false)); this.registerDefaultState(this.stateDefinition.any().setValue(WEST, false)); } public BlockState getStateForPlacement(BlockPlaceContext p_48689_) { return this.defaultBlockState().setValue(UP, false).setValue(DOWN, false).setValue(NORTH, false).setValue(SOUTH, false).setValue(EAST, false).setValue(WEST, false); } protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_48725_) { p_48725_.add(UP, DOWN, NORTH, SOUTH, EAST, WEST); } @Override public RenderShape getRenderShape(BlockState p_60550_) { return RenderShape.MODEL; } // ENTITY @Nullable @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { return new MagicPipeBlockEntity(pos, state); } @Nullable @Override public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) { return createTickerHelper(type, ModBlockEntities.MAGIC_PIPE.get(), MagicPipeBlockEntity::tick); } @javax.annotation.Nullable protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> p_152133_, BlockEntityType<E> p_152134_, BlockEntityTicker<? super E> p_152135_) { return p_152134_ == p_152133_ ? (BlockEntityTicker<A>)p_152135_ : null; } }
  8. Is there's anyway i can sync both Server/Client side random numbers? Only way i found it's by using NBT's but i don't think it's the right way.
  9. Ok, thank you for advice, i think i figured it out!
  10. I think the reason why this names like this is not because of Intellij, it's because of decompiling Minecraft source code by Forge. Parchment will rename this variables and also some other methods. Kaupenjoe made video about this. The same can be done with the newest versions.
  11. Intellij doesn't know how to name this variables, use Parchment or just don't use it.
  12. I just wanna know how can i fix this problem, it doesn't crashes game or anything, but when i'm breaking my block it just giving warning. [Server thread/WARN] [minecraft/LevelChunk]: Block entity magical_obsession:special_cauldron @ BlockPos{x=-64, y=69, z=67} state Block{minecraft:air} invalid for ticking:
  13. FIXED
  14. The problem is, i got block with custom inventory and json recipes, it also has it's own item inside renderer. But when i'm triyng to get item in slot for Client side (For Server side it's fine) i also need to check if recipe.isPresent(). But it doesn't return anything for client side, without this method the game will crash. Here's some code for crafting -> public static void tick(Level level, BlockPos pos, BlockState state, SpecialCauldronBlockEntity entity) { if (level.isClientSide) { if (!entity.itemStackHandler.getStackInSlot(0).is(ItemStack.EMPTY.getItem())) { entity.progress++; if (entity.progress >= entity.maxProgress) { //entity.itemStackHandler.setStackInSlot(0, Items.DIAMOND.getDefaultInstance()); craftItem(entity, level); level.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.END_PORTAL_SPAWN, SoundSource.BLOCKS, 1.0f, 1.0f, true); entity.resetProgress(); } } else { entity.resetProgress(); } } if (!level.isClientSide) { if (!entity.itemStackHandler.getStackInSlot(0).is(ItemStack.EMPTY.getItem())) { entity.progress++; if (entity.progress >= entity.maxProgress) { //entity.itemStackHandler.setStackInSlot(0, Items.DIAMOND.getDefaultInstance()); craftItem(entity, level); entity.resetProgress(); } } else { entity.resetProgress(); } } } // Craft private static void craftItem(SpecialCauldronBlockEntity pEntity, Level level) { SimpleContainer inventory = new SimpleContainer(pEntity.itemStackHandler.getStackInSlot(0)); if (level.isClientSide) { Optional<SpecialCauldronRecipe> recipe = level.getRecipeManager() .getRecipeFor(SpecialCauldronRecipe.Type.INSTANCE, inventory, level); System.out.println(level.isClientSide); if (recipe.isPresent()) { pEntity.itemStackHandler.setStackInSlot(0, new ItemStack(recipe.get().getResultItem().getItem())); } } if (!level.isClientSide) { Optional<SpecialCauldronRecipe> recipe = level.getRecipeManager() .getRecipeFor(SpecialCauldronRecipe.Type.INSTANCE, inventory, level); if (recipe.isPresent()) { pEntity.itemStackHandler.setStackInSlot(0, new ItemStack(recipe.get().getResultItem().getItem())); } } }
  15. Thank you so much, it's now working!
  16. I have a block that's had an itemStackHandler, it contains 1 item that player inserts and rendering it on block. I have done saving block load nbt data. But when i exiting and loading the world it only stores item on server side but not client. So i need to get data from Server side inventory to Client side invenory, how can i do that? My save/load code -> @Override protected void saveAdditional(CompoundTag nbt) { nbt.put("inventory", itemStackHandler.serializeNBT()); super.saveAdditional(nbt); } @Override public void load(CompoundTag nbt) { // TODO FIX MODEL RENDERING FOR CLIENT SIDE super.load(nbt); itemStackHandler.deserializeNBT(nbt.getCompound("inventory")); } Render code -> @Override public void render(SpecialCauldronBlockEntity entity, float pticks, PoseStack stack, MultiBufferSource buffer, int coverlay, int plight) { final BlockRenderDispatcher block_renderer = this.context.getBlockRenderDispatcher(); // TODO make block save items and render it //ItemStack item = Minecraft.getInstance().player.getMainHandItem(); final ItemRenderer item_renderer = this.context.getItemRenderer(); // Render Item inside if (state.getValue(HorizontalDirectionalBlock.FACING).equals(Direction.EAST) || state.getValue(HorizontalDirectionalBlock.FACING).equals(Direction.WEST)){ stack.pushPose(); stack.translate(0.5d, 0.55d, 0.5d); stack.scale(0.75f, 0.75f, 0.75f); stack.mulPose(Vector3f.YN.rotationDegrees(90)); item_renderer.renderStatic(Minecraft.getInstance().player, entity.itemStackHandler.getStackInSlot(0), ItemTransforms.TransformType.FIXED, false, stack, buffer, Minecraft.getInstance().level, coverlay, plight, plight); stack.popPose(); } else { stack.pushPose(); stack.translate(0.5d, 0.55d, 0.5d); stack.scale(0.75f, 0.75f, 0.75f); item_renderer.renderStatic(Minecraft.getInstance().player, entity.itemStackHandler.getStackInSlot(0), ItemTransforms.TransformType.FIXED, false, stack, buffer, Minecraft.getInstance().level, coverlay, plight, plight); stack.popPose(); }
  17. Might be useful.
  18. Nevermind, fixed this. Updated code -> @Override public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult result) { // Explode if placed on not correct block if (!level.isClientSide){ if (level.getBlockEntity(pos) instanceof SpecialCauldronBlockEntity entity) { if (level.getBlockState(pos.below()).is(ModTags.Blocks.SPECIAL_CAULDRON_EXPLODES)) { level.explode(null, DamageSource.MAGIC, null, pos.getX(), pos.getY(), pos.getZ(), 3.5f, false, Explosion.BlockInteraction.DESTROY); } } } // Interaction - Server Side if (!level.isClientSide) { if (level.getBlockEntity(pos) instanceof SpecialCauldronBlockEntity entity) { if (entity.getItem(0).is(ItemStack.EMPTY.getItem()) && !player.getMainHandItem().is(ItemStack.EMPTY.getItem())) { ItemStack item = player.getItemInHand(hand).copy(); entity.setItem(0, item); player.getMainHandItem().shrink(1); // TODO Make normal shrink } else { if (!entity.getItem(0).is(ItemStack.EMPTY.getItem())) { player.addItem(entity.getItem(0)); entity.setItem(0, ItemStack.EMPTY); } } } } // Interaction - Client Side if (level.isClientSide) { if (level.getBlockEntity(pos) instanceof SpecialCauldronBlockEntity entity) { if (entity.getItem(0).is(ItemStack.EMPTY.getItem()) && !player.getMainHandItem().is(ItemStack.EMPTY.getItem())) { ItemStack item = player.getItemInHand(hand).copy(); level.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.END_PORTAL_FRAME_FILL, SoundSource.BLOCKS, 1.0f, 1.0f, true); entity.setItem(0, item); } else { if (!entity.getItem(0).is(ItemStack.EMPTY.getItem())) { level.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, 0.75f, 1f, true); entity.setItem(0, ItemStack.EMPTY); } } } } return InteractionResult.SUCCESS; }
  19. I got it, it happened because it was executed on wrong side, block container works fine, but how do i render items?
  20. (It started working by itself idk why). But i still interested how to do it properly. And i also got another problem, when i'm clicking my block with sword, it work's but when i'm trying to break it, it doesn't. Probably because of my block thinks that i have a sword in my hand (because you cant break block with hand) but it's not. Updated Code -> @Override public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult result) { if(!level.isClientSide){ if (level.getBlockEntity(pos) instanceof SpecialCauldronBlockEntity entity) { if (level.getBlockState(pos.below()).is(ModTags.Blocks.SPECIAL_CAULDRON_EXPLODES)) { level.explode(null, DamageSource.MAGIC, null, pos.getX(), pos.getY(), pos.getZ(), 3.5f, false, Explosion.BlockInteraction.DESTROY); } } } if (level.isClientSide) { if (level.getBlockEntity(pos) instanceof SpecialCauldronBlockEntity entity) { if (entity.getItem(0).is(ItemStack.EMPTY.getItem()) && !player.getMainHandItem().is(ItemStack.EMPTY.getItem())) { ItemStack item = player.getItemInHand(hand).copy(); level.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.END_PORTAL_FRAME_FILL, SoundSource.BLOCKS, 1.0f, 1.0f, true); entity.setItem(0, item); player.getMainHandItem().shrink(1); } else { if (!entity.getItem(0).is(ItemStack.EMPTY.getItem())) { player.addItem(entity.getItem(0)); level.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, 0.75f, 1f, true); entity.setItem(0, ItemStack.EMPTY); } } } } return InteractionResult.SUCCESS; }
  21. probably Applied Energistics causes crash, also you can use Not Enough Crashes mod, it's useful.
  22. Not enough crashes will be useful if you haven't it installed yet
  23. Try to remove Forgeendertech mod
  24. Try to remove ars noveau
×
×
  • Create New...

Important Information

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