Jump to content

urbanxx001

Members
  • Posts

    200
  • Joined

  • Last visited

Everything posted by urbanxx001

  1. I implemented it that way by referring to another mod that did it like that.
  2. If mouse event is removed, the FOV change does work in-game, if I set the scaling value scroll to a static value like 4. Was just trying to extend this behavior.
  3. If we take a look at a class like AbstractSkeletonEntity, this snippet determines if they should burn: public void livingTick() { boolean flag = this.isInDaylight(); if (flag) { ItemStack itemstack = this.getItemStackFromSlot(EquipmentSlotType.HEAD); if (!itemstack.isEmpty()) { if (itemstack.isDamageable()) { itemstack.setDamage(itemstack.getDamage() + this.rand.nextInt(2)); if (itemstack.getDamage() >= itemstack.getMaxDamage()) { this.sendBreakAnimation(EquipmentSlotType.HEAD); this.setItemStackToSlot(EquipmentSlotType.HEAD, ItemStack.EMPTY); } } flag = false; } if (flag) { this.setFire(8); } } super.livingTick(); } However this also requires we look at isInDaylight() in MobEntity: protected boolean isInDaylight() { if (this.world.isDaytime() && !this.world.isRemote) { float f = this.getBrightness(); BlockPos blockpos = this.getRidingEntity() instanceof BoatEntity ? (new BlockPos(this.getPosX(), (double)Math.round(this.getPosY()), this.getPosZ())).up() : new BlockPos(this.getPosX(), (double)Math.round(this.getPosY()), this.getPosZ()); if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.canSeeSky(blockpos)) { return true; } } return false; } And finally, isDaytime() in World: public boolean isDaytime() { return !this.func_230315_m_().func_241514_p_() && this.skylightSubtracted < 4; } And there's the light level. So altogether you'll need to add code like these three for your entity.
  4. The intended behavior is detect if an item is equiped, and if so, then allow scrolling to change FOV. Is there a different way other than events? Alternatively there's Mouse.getWheel(), which doesn't require mouse event, but it's non-static. Also, this is unrelated, but is there a reason we're asking people to update Forge when they ask questions regarding older versions, rather than redirecting them somewhere that will accept those questions?
  5. For the deferred registry method, you can do: public static final DeferredRegister<Potion> POTIONS = DeferredRegister.create(ForgeRegistries.POTION_TYPES, Main.MOD_ID); public static final RegistryObject<Potion> EFFECT_NAME = POTIONS.register("effect_name", () -> new Potion(new EffectInstance[] {new EffectInstance(Effects.RESISTANCE, 9600), new EffectInstance(Effects.REGENERATION, 9600), new EffectInstance(Effects.FIRE_RESISTANCE, 9600)})); Where 9600 is the duration, and can be different values for each one. To create a brewing recipe for this, you have 2 options: using an access transformer, or reflection. These are required because we can't directly access the registry method Minecraft uses for brewing. Reflection is less buggy, but requires more code. To do this, copy: private static Method brewing_mixes; private static void addMix(Potion start, Item ingredient, Potion result) { if(brewing_mixes == null) { brewing_mixes = ObfuscationReflectionHelper.findMethod(PotionBrewing.class, "addMix", Potion.class, Item.class, Potion.class); brewing_mixes.setAccessible(true); } try { brewing_mixes.invoke(null, start, ingredient, result); } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } } And then your recipe: public static void addBrewingRecipes() { addMix(Potions.AWKWARD, ModItems.ITEM_NAME, EFFECT_NAME.get()); } Where the first entry is the input potion, second is the brewing item, and third is the output.
  6. Funnily enough, I also just asked a question involving a helmet lol. There I used: ItemStack helmet = yourEvent.getEntity().getItemStackFromSlot(EquipmentSlotType.HEAD); if (!helmet.isEmpty() && helmet.getItem() == ModItems.ITEM_NAME) { }
  7. Do you have any mods installed?
  8. The following requires 2 events, changing FOV and the mouse wheel. @SubscribeEvent public void onFOVChange(FOVUpdateEvent fovUpdateEvent, MouseWheelEvent mouseWheelEvent) { if (fovUpdateEvent.getEntity() != null) { ItemStack helmet = fovUpdateEvent.getEntity().getItemStackFromSlot(EquipmentSlotType.HEAD); if (!helmet.isEmpty() && helmet.getItem() == ModItems.LENSES) { int scroll = Integer.signum(mouseWheelEvent.getScrollAmount()); if (scroll < 0) { scroll = -1 / scroll; } fovUpdateEvent.setNewfov((float) (fovUpdateEvent.getFov() / scroll)); } } } However event handlers only manage 1 event. Is there a workaround? I considered using 2 separate handlers, but that would still require both to work together somehow.
  9. Ah it's the scope.I made those changes and it resolved the max age, but there's still a null error with the age property, saying it's invalid: public final VoxelShape[] SHAPE; public final Item SEEDS; public final int MAX_AGE; public final IntegerProperty AGE_PROPERTY; public ModCropsBlock(VoxelShape[] shape, Item seeds, Properties builder) { super(builder); this.SHAPE = shape; this.SEEDS = seeds; this.MAX_AGE = SHAPE.length - 1; this.AGE_PROPERTY = IntegerProperty.create("age", 0, MAX_AGE); }
  10. True creating a new property each time might be affecting it. The reason I think it's an issue with getting the shape is that getMaxAge returns an error separately, which is only dependent on that. I'm actually just overriding the current methods that are in place so that both properties generate automatically based on the shape array. In CropsBlock, these fields are defined outside the methods, but when I try to do it that way with something like Max_Age = Shapes.length - 1 then it says that Shapes isn't initialized.
  11. So I realized that VoxelShape can be passed into the registry like this: public static final VoxelShape[] CROP_SHAPE = new VoxelShape[] { Block.makeCuboidShape(0.0D,0.0D,0.0D,16.0D,2.0D,16.0D), Block.makeCuboidShape(0.0D,0.0D,0.0D,16.0D,4.0D,16.0D), Block.makeCuboidShape(0.0D,0.0D,0.0D,16.0D,6.0D,16.0D), Block.makeCuboidShape(0.0D,0.0D,0.0D,16.0D,8.0D,16.0D) }; public static final Block PEANUTS = register(Reference.MOD_ID + ":peanut", new ModCropsBlock(CROP_SHAPE, ModItems.PEANUT_ITEM, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().tickRandomly().zeroHardnessAndResistance().sound(SoundType.CROP))); With the class:
  12. Ah ok I'll tinker with an anyonymous class. Thanks!
  13. Right now I have block classes that are all identical except for their voxel shape, defined inside each class. I'd like to somehow pass this in during registry so that I can boil it down to one reusable class. Is this possible? I know it can't be passed into the super since the parent class "Block" doesn't work that way; I could extend AbstractBlock instead and add code for that, but that seems like more work.
  14. Luckily there's a vanilla block that has this functionality already: the daylight detector. The blockstate for that looks like: { "variants": { "inverted=false": { "model": "minecraft:block/daylight_detector" }, "inverted=true": { "model": "minecraft:block/daylight_detector_inverted" } } } So you can adapt your blockstate to use true/false flags like that. Now we need to look at the class file for the daylight detector to see how the tags are implemented. I've added the relevant parts here. public static final BooleanProperty INVERTED = BlockStateProperties.INVERTED; public DaylightDetectorBlock(AbstractBlock.Properties properties) { super(properties); this.setDefaultState(this.stateContainer.getBaseState().with(INVERTED, Boolean.FALSE)); } public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { if (player.isAllowEdit()) { if (worldIn.isRemote) { return ActionResultType.SUCCESS; } else { BlockState blockstate = state.func_235896_a_(INVERTED); worldIn.setBlockState(pos, blockstate, 4); return ActionResultType.CONSUME; } } else { return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); } }
  15. Hmm the TeleportCommand and SpawnpointCommand classes located in net/minecraft/command/impl might be a good place to start. I'm new to modding as well though.
  16. In the future I'd suggest copying the error log into a pastebin or in spoiler tags, to keep it compact. I'd like to bet my money on Optifine, it's missing 2 classes (Launch and Loader) as well as a config file. Preview versions of Optifine are known to be buggy. Unfortunately that's the only one for 1.15.2. Try loading it without that and report if it works?
  17. Ah didn't know only certain AT's were viable. Yeah I tried to make the protected field Block_Stripping_Map, public. I assumed it was possible, as I'm just copying over some code from a mod developed by someone else, and they somehow got it to work. Will work out an alternative though. Thanks!
  18. I'm running a few commands in Intellij in order to update the AT config file into the project (This is suggested by YouTube modding tutorials, but lmk if there's a better method). This consists of: 1. gradlew --refresh-dependencies 2. gradlew clean 3. gradlew genIntellijRuns 4. Opening Intellij and waiting for dependencies to install/indices refresh Now randomly, after running the first three and opening Intellij, step 4 never occurs and the net.minecraftforge:forge library remains missing. Is this a bug, and is there a way to force it to install when this happens?
  19. I know enough about Java to code the method above, which would work if it was in the source code. Not knowing one thing (or a few things counting other posts) doesn't invalidate my understanding of everything else about Java.
  20. It's an insult when you're able to explain what the issue is but instead say to look elsewhere for help. This says you don't want to take the time to explain it when it could just take a few sentences to do so. Please don't further this, I don't want it to derail into something bad.
  21. You could have described why it didn't work instead of an insult. I'll look into LivingEntityUseItemEvent though, thanks. I appreciate the help that regular users like you and Draco give in the forum, your names appear a lot when researching old posts.
  22. Yes, it's supposed to check for that...
  23. ? It applies the drinking animation to soup items (those items that have a container with a bowl), since in the base game consuming soup uses the eating animation for whatever reason. So the code is just overriding getUseAction which is built-in the source code.
  24. Yea it should apply to all food items, including vanilla, since the class extends to the Item class. Is the problem that I need to pass something into ItemStack in the ModItems class, or does it already know what to pass based on the Item class?
×
×
  • Create New...

Important Information

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