Jump to content

Alekseyev

Members
  • Posts

    46
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Alekseyev's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Bumping in hope of someone having an idea
  2. You create a new Capability every time you call getCapability. Return your already existing instance instead. You're trying to cast the LazyOptional of the capability to the capability itself. Instead you should retrieve it by using one the methods that exist for that purpose. I was linked this article some time ago by helpful persons, and it helped me greatly in understanding LazyOptionals (which function mostly the same as regular Optionals) https://www.baeldung.com/java-optional
  3. Hi, I ran into a problem: The night vision's effect of brightening up the surroundings is handled in LightTexture#updateLightmap(float partialTicks) and checks for the potion effect, after which a value (usually 1, if the effect is about to expire 0.7 + a sinus curve) is retrieved. How would I implement my own night vision effect, say, at lower intensity? I don't think it's possible to change that vanilla method to account for another check.
  4. Oh wow, I am dumb. No idea how I missed that file on Github. I always forget about how you don't have to import things from the same package...
  5. @Choonster in your TestMod3 you use a "RecipeUtil.ShapedPrimer", but you don't seem to import it anywhere, nor can I find such a file in the minecraft/forge sources.
  6. Which would be +20 ticks per second if your game runs at full speed, and less if the processor can't keep up with all the things it has to compute.
  7. Could be fixed for the most part by setting the getRenderLayer to CUTOUT or CUTOUT_MIPPED.
  8. You could also have the inventoryTick function check the modulo of ticksExisted of the entity so that the rest of the code only fires every x ticks.
  9. Are you sure that your texture has transparent areas? Could be missing an alpha channel in the PNG.
  10. Hi, I designed a custom block model and got it to load in the world. However, I am facing two issues: 1: The floor below the block is not rendered. 2: The lighting on the model itself is broken on some faces (notably the upper and lower parts of those at an angle. (The textures and z-fighting will be fixed later, but that's not so important right now.)
  11. Would it also be an option to replace the Item Set with one of your own choice via reflection?
  12. I thought about the following: Instead of checking the charge value and being updated on it, the client just has a boolean for "1000 or higher". The server then only sends an update packet whenever the charge value crosses this treshold. However, there is a problem: I also want the charge to be displayed on the HUD later (in the form of a bar of varying size), and to calculate that size, you'd need the value again...
  13. Hi, I can successfully use LivingHurtEvent or LivingDamageEvent to set damage caused by a certain source to zero or cancel the event right away. However, other effects associated with damage still play, notably the hurt sound and the screenshake. How would I go about removing these depending on the damage source, say, for example, drowning or being on fire?
  14. HarvestCheck is fired between the destruction of a block and the (optional) creation of drops. I am not 100% sure whether it only fires for blocks with a harvest level of 1 or higher, but I remember something like this. It definitely also includes ordinary blocks like stone or snow, that require a tool to be collected. Haven't used the other event myself yet and no documemtation at hand.
  15. Hey there, I have a capability with a boolean (active status) and an integer value (a charge value). I want to check this data for many effects and events. Here are my current cases: BreakSpeed and Jump Height (but planning to add more later on, such as attack damage or mob behaviour) I want to make it so that when the boolean is active, the player's block breaking speed is doubled or jump height increased. This works fine. However, I also want to reduce the charge value while doing this. When simply using the code further down, a desync in the values known by the client and by the server starts to manifest after prolonged usage, from both the block breaking and jump height. The debug chat line also appears twice per side for some reason, with the second time showing the already incremented charge value. This makes me wonder: What is the best way to handle capability data like this? Since some data is handled by the server and other data by the client (such as movement), the data would have to be present on both, but considering that the charge is modified so highly frequently, sending a packet every frame surely can't be the right way to handle it? @SubscribeEvent public void breakingSpeed(net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed event) { if (getBioData(player).getMaskActive()) { Item mask = player.inventory.armorItemInSlot(3).getItem(); if (mask == ItemInit.KANOHI_PAKARI) { event.setNewSpeed(event.getNewSpeed() * 2); getBioData(player).modifyMaskCharge(-5); if (player.ticksExisted % 20 == 0) { player.sendStatusMessage(new TextComponentString(TextFormatting.DARK_GRAY + "Speeds: New: " + event.getNewSpeed() + " Old: " + event.getOriginalSpeed()), false); } } } } @SubscribeEvent public void jumpEffect(LivingEvent.LivingJumpEvent event) { if (event.getEntity() instanceof EntityPlayer) { EntityPlayer evPlayer = (EntityPlayer)event.getEntity(); if (getBioData(evPlayer).getMaskActive() && evPlayer.inventory.armorItemInSlot(3).getItem() == ItemInit.KANOHI_MIRU && getBioData(evPlayer).getMaskCharge() >= 1000) { evPlayer.motionY += 0.7D; evPlayer.motionX *= 4.0D; evPlayer.motionZ *= 4.0D; getBioData(evPlayer).modifyMaskCharge(-1000); } } } @SubscribeEvent public void playerTick(TickEvent.PlayerTickEvent event) { if (!(player.inventory.armorItemInSlot(3).getItem() instanceof Kanohi) && getBioData(player).getMaskActive() == true) { getBioData(player).setMaskActive(false); player.sendStatusMessage(new TextComponentString(TextFormatting.RED + event.side.name() + " Mask unequipped, setting to: " + (getBioData(player).getMaskActive() ? "On" : "Off")), false); } if (getBioData(player).getMaskActive()) { Item mask = player.inventory.armorItemInSlot(3).getItem(); if (mask == ItemInit.KANOHI_MIRU) { player.fallDistance = 0; } } else { getBioData(player).modifyMaskCharge(+10); //Increasing charge with mask deactivated } if (player.ticksExisted % 100 == 0) { player.sendStatusMessage(new TextComponentString(TextFormatting.DARK_RED + event.side.name() + " Mask: " + (getBioData(player).getMaskActive() ? "On" : "Off") + " Charge: " + getBioData(player).getMaskCharge()), false); } } public class DefaultBioPlayerDataHandler implements IBioPlayerDataHandler { private BioElements element; private Boolean maskActive = false; private int maskCharge = 10000; private final int maxCharge = 10000; @Override public BioElements getElement() { return element; } @Override public void setElement(BioElements element) { this.element = element; } @Override public void removeElement() { this.element = BioElements.NONE; } @Override public Boolean getMaskActive() { return maskActive; } @Override public void setMaskActive(Boolean status) { this.maskActive = status; } @Override public int getMaskCharge() { return this.maskCharge; } @Override public void setMaskCharge(int charge) { this.maskCharge = charge; } @Override public void modifyMaskCharge(int modifier) { if (maskCharge + modifier >= 0) { if (maskCharge + modifier <= maxCharge) { maskCharge = maskCharge + modifier; } else { maskCharge = maxCharge; } } else { maskCharge = 0; maskActive = false; } } }
×
×
  • Create New...

Important Information

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