Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Everything posted by max2461

  1. The Screen class you're using is trying to run on the server i'm guessing. Calling it from your client proxy should fix it. MyScreenObjects Class: public class MyScreenObjects{ @ObjectHolder("modid:myobjectholder") public static ContainerType<ModContainer> ModContainerScreen; } ClientProxy: (IMCOMPLETE PROXY CLASS) You can find a tutorial somewhere on how to set it up right if you don't already have one. public class ClientProxy implements ProxyInterface{ @Override public void init() { ScreenManager.registerFactory(MyScreenObjects.ModContainerScreen, MyModScreenClass::new); } } *called in your main class
  2. Hey everyone, i just wanted to update the thread in case anyone else needs more detail on how to do something similar to this. I used Animefan8888's suggestion: and found that EntityInteractSpecific worked better for me. As i have a lot of custom functions all over my mod it wouldn't do any good to post my code but here is a breakdown for some direction! @SubscribeEvent public void EntityInteract(EntityInteractSpecific event) { if(event.getTarget() instanceof [ENTITY YOU WANT]){ //Eg: CowEntity, ChickenEntity. if(event.getItemStack().getItem()==[YOUR ITEM]){ //Eg: Items.NAME_TAG if( [ON THE SERVER] ){ itemstack.interactWithEntity([PLAYER],[ENTITY],[HAND]); /* Cancel the event on the server to prevent other item interactions from passing along with your custom interaction. */ event.setCancellationResult(ActionResultType.SUCCESS); event.setCanceled(true); } if([ON THE CLIENT]){ /* You need to also cancel the event on the client to prevent things like GUI's to apear in villagers, or other process interactions */ event.setCancellationResult(ActionResultType.SUCCESS); event.setCanceled(true); } } } }
  3. So back in 1.12 the villagers had a bug where you couldn't use a nametag on them because- guess what right clicking does on a villager? BOOM. i am a loser who made the same mistake now... I have a custom item that is supposed to be used on entities, but when i look at the name-tag code, i didn't see how it was fixed, so i went to the villagers code and found this: VillagerEntity#processInteract public boolean processInteract(PlayerEntity player, Hand hand) { ItemStack itemstack = player.getHeldItem(hand); boolean flag = itemstack.getItem() == Items.NAME_TAG; if (flag) { itemstack.interactWithEntity(player, this, hand); return true; } else if (itemstack.getItem() != Items.VILLAGER_SPAWN_EGG && this.isAlive() && !this.func_213716_dX() && !this.isSleeping() && !player.isSneaking()) { if (this.isChild()) { this.shakeHead(); return super.processInteract(player, hand); } else { boolean flag1 = this.getOffers().isEmpty(); if (hand == Hand.MAIN_HAND) { if (flag1 && !this.world.isRemote) { this.shakeHead(); } player.addStat(Stats.TALKED_TO_VILLAGER); } if (flag1) { return super.processInteract(player, hand); } else { if (!this.world.isRemote && !this.offers.isEmpty()) { this.func_213740_f(player); } return true; } } } else { return super.processInteract(player, hand); } } How can i go about adding my custom item into this field? Is there a method i could use to override only this particular function? SOLUTION HERE:
  4. Thank you very much, you are correct. I needed to override IForgeBlock#hasTileEntity. You are a life saver!
  5. So i have been fighting with this for a while now and have tried fixing it in a multitude of different ways... I know its registering because under "Block Entities" i see my block. But when i place the block, nothing happens besides the normal block getting placed, and when i try to use: it comes back and says: "ShelfingTile" Class: public class ShelfingTile extends TileEntity implements ITickableTileEntity{ public ShelfingTile(){ super(SHELFING_TILE); } @Override public void tick() { MainCore.LOGGER.debug("TileEntityTick"); } } "Registry Events" Class Code Snippit: private static Item.Properties GetNewItemProperties(){ Item.Properties properties = new Item.Properties(); return properties; } private static BlockItem GetBlockItem(Block block,String reg_name){ BlockItem blockitem = new BlockItem(block,GetNewItemProperties()); blockitem.setRegistryName(reg_name); return blockitem; } @SubscribeEvent public static void RegisterBlock(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll ( CoreRegistry.SHELFING = new Shelfing(), ); } @SubscribeEvent public static void RegisterItem(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( GetBlockItem(CoreRegistry.SHELFING,Shelfing.reg_name), ); } @SubscribeEvent public static void RegisterTileEntity(final RegistryEvent.Register<TileEntityType<?>> event) { event.getRegistry().registerAll ( TileEntityType.Builder.create(ShelfingTile::new,CoreRegistry.SHELFING).build(null).setRegistryName(Shelfing.reg_name) ); } "CoreRegistry" Code Snippits: @ObjectHolder("MaxM") //ModID public class CoreRegistry{ @ObjectHolder("shelfing") //Shelfing Blocks Registry Name public static Block SHELFING; @ObjectHolder("shelfing") public static TileEntityType<ShelfingTile> SHELFING_TILE; } Enitre Block Class: public class Shelfing extends Block{ public static String reg_name = "shelfing"; public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; protected static final VoxelShape SHAPE = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); private static Block.Properties GetNewBlockProperties(){ float hardness = 1.5f; float resistance = 2.0f; Block.Properties properties = Properties.create(Material.WOOD); properties.sound(SoundType.WOOD); properties.hardnessAndResistance(hardness,resistance); return properties; } public Shelfing() { super(GetNewBlockProperties());setRegistryName(reg_name); this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH)); } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new ShelfingTile(); } public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); } public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return SHAPE; } public boolean isSolid(BlockState state) { return false; } public boolean allowsMovement(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type) { return false; } @Override public BlockState rotate(BlockState state, Rotation rot) { return state.with(FACING, rot.rotate(state.get(FACING))); } @Override public BlockState mirror(BlockState state, Mirror mirrorIn) { return state.rotate(mirrorIn.toRotation(state.get(FACING))); } protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { builder.add(FACING); } public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; } }
  6. YOU ARE A GOD. -cough- I mean, thank you very much. I admit I am a bit ignorant towards "advanced" methods. It worked great!
  7. That is a very good point, i don't know why i didn't consider that. However, how can i override an "Interface" function in a class?
  8. I tried to override things like Enchantment Table's getting power raised by Bookshelves to include one of my custom blocks, but it never took. I have tried many different kinds of overriding classes, but it never seems to work. I was wondering if there is something i am missing. THIS IS NOT EXACT CODE... REWRITTEN FROM MEMORY FOR EXAMPLE. public interface MagicEnchantmentOverride extends IForgeBlock{ @Override default float getEnchantPowerBonus(BlockState state, IWorldReader world, BlockPos pos){ if(this.getBlock() == MyBlocks.MAGICBLOCK){ return this.getBlock() == MyBlocks.MAGICBLOCK ? 1: 0; }else{ return this.getBlock() == Blocks.BOOKSHELF ? 1: 0; } }
  9. So in my code for 1.8.1, I used to be able to change Creepers AI tasks like so: @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent event) { if (event.entity instanceof EntityCreeper){ EntityCreeper entity = (EntityCreeper) event.entity; for (Object entry : entity.targetTasks.taskEntries.toArray()){ EntityAIBase ai = ((EntityAITasks.EntityAITaskEntry) entry).action; if (ai instanceof EntityAINearestAttackableTarget) entity.targetTasks.removeTask(ai); } for (Object entry : entity.tasks.taskEntries.toArray()){ EntityAIBase ai = ((EntityAITasks.EntityAITaskEntry) entry).action; if (ai instanceof EntityAIAttackOnCollide) entity.tasks.removeTask(ai); } entity.tasks.addTask(1, new EntityAITempt(entity, 1.0D, Items.gunpowder, false)); entity.tasks.addTask(2, new EntityAIPanic(entity, 1.4D)); } } But now, in 1.14.4, i cannot for the life of me figure out how to use the "goal" system in the AI. I have tried different events, new registry of the mob, overriding creeperEntites... Here is a failure chunk of code I tried to rework the 1.8 function to (knowing it would fail): (Also, if it doesn't make any sense its because it's literally me changing tiny things to see what happens after weeks of trying) @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent event) { if (event.getEntity() instanceof CreeperEntity){ CreeperEntity creeper = (CreeperEntity) event.getEntity(); for (Task task : creeper.goalSelector.getRunningGoals().filter(PrioritizedGoalPrioritizedGoal).getgoal()){ GoalSelector ai = ((GoalSelector) entry).action; if (ai instanceof EntityAINearestAttackableTarget) entity.targetTasks.removeTask(ai); } } } The Mod in its base form is just to make creepers friendly and maybe attack other things. I just can't get the Goal system right.
  10. I don't know if this will help or not, but when I had this issue on the most recent version: (after they removed setupdecompworkspace) I had to run a command: gradlew genEclipseRuns To fix my Eclipse, i had to run these commands in this order: gradlew clean gradlew genEclipseRuns gradlew eclipse it was critical to run "genEclipseRuns" before "eclipse."
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.