Jump to content

Distinct Soul

Members
  • Posts

    58
  • Joined

  • Last visited

Everything posted by Distinct Soul

  1. Could I possibly get examples to help me understand better? I'm much better at understanding things through being shown rather than being told.
  2. So I looked at your conventions; but I still don't understand what I'm supposed to do for registering models and not using an object base class. Like where do I put this registry event and what exactly do I put for it? Also, what do you mean by 'extract it to a helper method'?
  3. So as kinda given by the title, I'm trying to create a custom machine. To be more specific, a machine like a furnace but instead of cooking items, it combines 2 items into one - includes 2 of the same item (actually would like this to be more prioritised over 2 different items). It will also has 1 fuel slot where redstone dust/blocks are used to power it. I have looked up tutorials on custom machines; but they all pretty much involve smelting like a furnace, which I'm not trying to do. I feel like before I finish, I must mention that this is a custom block model machine and not one like a furnace where it just has different textures on the sides. I would also ideally like the fire cooking animation to be different. I believe I have most of the code done for the block itself; but I really need help on the actual functionality of this block. Detailed instructions on what each method would be highly appreciated, as I don't want just code that I don't understand and have no idea how to customise to make different machines. Here's my code: (Block Machine class) package com.distinctsoul.soulforgery.blocks.machines; import java.util.Random; import com.distinctsoul.soulforgery.Main; import com.distinctsoul.soulforgery.blocks.BlockBase; import com.distinctsoul.soulforgery.init.ModBlocks; import com.distinctsoul.soulforgery.util.Reference; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; public class BlockShardFuser extends BlockBase implements ITileEntityProvider { public static final PropertyDirection FACING = BlockHorizontal.FACING; public BlockShardFuser(String name, Material material) { super(name, material); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); setSoundType(SoundType.STONE); setHardness(3.0F); setResistance(20.0F); setHarvestLevel("pickaxe", 2); // setLightLevel(0.1F); // setLightOpacity(1); // setBlockUnbreakable(); } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(ModBlocks.SHARD_FUSER); } @Override public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { return new ItemStack(ModBlocks.SHARD_FUSER); } public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing()), 2); } public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } public static final AxisAlignedBB SHARD_FUSER_AABB = new AxisAlignedBB(0, 0, 0, 1, 1, 1); @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return true; } @Override public EnumBlockRenderType getRenderType(IBlockState iBlockState) { return EnumBlockRenderType.MODEL; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return SHARD_FUSER_AABB; } public IBlockState getStateFromMeta(int meta) { EnumFacing facing = EnumFacing.getHorizontal(meta); return this.getDefaultState().withProperty(FACING, facing); } public int getMetaFromState(IBlockState state) { EnumFacing facing = (EnumFacing)state.getValue(FACING); int facingbits = facing.getHorizontalIndex(); return facingbits; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { FACING }); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return null; } } (BlockState json) { "variants": { "facing=north": { "model": "soulforgery:shard_fuser" }, "facing=south": { "model": "soulforgery:shard_fuser", "y": 180 }, "facing=east": { "model": "soulforgery:shard_fuser", "y": 90 }, "facing=west": { "model": "soulforgery:shard_fuser", "y": 270 } } } Any help would be very appreciated.
  4. Now thinking about it, I'm not really sure. I guess I've just spent so much time invested in doing it this way, I don't want it to be that I've been doing it the wrong way this entire time. Sorry for wasting your time. Now I'm using the right event. Omg, I've actually found the solution. It wasn't because I was using LivingDeathEvent. It was because I didn't have it registered in my Preinit. I thought the @EventBusSubscriber already did that; but I must've been mistaken. Thanks for helping anyways.
  5. So you're saying there's no way to do it through the LivingDeathEvent?
  6. I don't have any code with LivingDropsEvent. The only code I have is from that example.
  7. I'm well aware of that; but I'm also using getSource in this part of my code to get the killer and the code says there's nothing wrong with that: Also, I still don't understand what I'm doing wrong that prevents the item from being dropped by the mob. Like, what code would I need to have in my LivingDeathEvent for the item to actually drop from the Zombie?
  8. So I've spent hours on looking for a way to get certain vanilla mobs to drop custom items and I want to use the LivingDeathEvent to achieve this. I've been looking at countless different forums and pages; however, most of them rely on using the LivingDropsEvent and the ones that don't, end up not working for me. I want the item to only drop only when the certain mobs are killed by a player who is holding a specific weapon. No errors show up from what I know and I'm able to load into the game fine. I also believe I have the if statements right; but I'm honestly not sure because regardless of whether I have them or not, the item doesn't drop from the mobs. I went with this event because I thought I could have more control over it; although, I have little knowledge on what you can do with LootPools other than if the player killed the mob and what mob should drop this loot. If it helps, the Forge version I'm using is: 14.23.3.2655 Here is my current code: @EventBusSubscriber public class SFEventHandler { @SubscribeEvent public void onEvent(LivingDeathEvent event) { if (event.getEntity() instanceof EntityZombie) { if (event.getSource().getTrueSource() instanceof EntityPlayer) { event.getEntity().dropItem(ModItems.TAINTED_SOUL, 1); } } } } Any help is very appreciated.
×
×
  • Create New...

Important Information

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