Jump to content

ArcaneDiver

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by ArcaneDiver

  1. Ok, resolved by ignoring END Phase. Thank you so much
  2. Hi, i'm trying to implement a cooldown for an ability, and i found that every second a tick event is called 20 times. Here is my actual code: Decreasing the cooldown @SubscribeEvent public static void onSonarCooldown(TickEvent.PlayerTickEvent event) { PlayerEntity player = event.player; ISonarData data = player.getCapability(EntitySonarDataHandler.CAPABILITY_SONAR_DATA).orElse(null); if(data != null) { if(data.getCooldown() > 0) { data.setCooldown(data.getCooldown() - 1); } } } Setting the cooldown data.setCooldown(10 * 20); But the cooldown isn't 10sec but less. How can i implement it better?
  3. They have to be applied on the server. Use !world.isRemote to check it. Also check documentation about sides https://mcforge.readthedocs.io/en/latest/concepts/sides/
  4. But what about IInventory#openInventory? Just ignore
  5. Yes because i have to pass an IInventory to Slot. I obviously could be wrong because i'm quite new with GUI.
  6. I resolved by use a KeyBindingEvent and sending a packet to the server which calls NetworkHooks.openGui
  7. Hi, i have attached a IItemHandler capability to my entity but i have to pass an IInventory to my Container and i don't kwon how convert it in order to be able to pass to the Container constructor. Here is the code: Entity: @CapabilityInject(IItemHandler.class) private static Capability<IItemHandler> ITEM_HANDLER_CAPABILITY = null; protected IItemHandler inventory = new ItemStackHandler(); Container: public class RidableDolphinContainer extends Container { private PlayerInventory playerInventory; private IInventory inventory; public RidableDolphinContainer(int windowID, PlayerInventory playerInventory) { this(windowID, playerInventory, new Inventory(1)); } public RidableDolphinContainer(int windowID, PlayerInventory playerInventory, IInventory inventory) { super(ModContainers.RIDABLE_DOLPHIN.get(), windowID); assertInventorySize(inventory, 1); this.playerInventory = playerInventory; this.inventory = inventory; inventory.openInventory(playerInventory.player); this.addSlot(new SlotSonarRidableDolphin(inventory, 0, 80, 20));
  8. I tried to implement this by modifing the container on GuiOpenEvent and PlayerContainerEvent.Open but i sadly discovered that PlayerContainerEvent.Open doesn't fire for the Container of the player then how can i say "when i press E open my container"? Here is the code of events: @SubscribeEvent public static void onDolphinContainerOpen(PlayerContainerEvent.Open event) { // Never fires :C ServerPlayerEntity playerEntity = (ServerPlayerEntity) event.getPlayer(); if(playerEntity.getRidingEntity() instanceof RidableDolphinEnitity) { RidableDolphinEnitity dolphin = (RidableDolphinEnitity) playerEntity.getRidingEntity(); playerEntity.openContainer = new RidableDolphinContainer(playerEntity.currentWindowId, playerEntity.inventory, dolphin.getInventory()); } } @SubscribeEvent public static void onDolphinGuiOpen(GuiOpenEvent event) { if(event.getGui() instanceof ContainerScreen) { ClientPlayerEntity player = Minecraft.getInstance().player; if (player != null && player.getRidingEntity() instanceof RidableDolphinEnitity) { RidableDolphinEnitity dolphin = (RidableDolphinEnitity) player.getRidingEntity(); if(!(event.getGui() instanceof RidableDolphinScreen)) { ContainerScreen<?> oldScreen = (ContainerScreen) event.getGui(); Container oldContainer = oldScreen.getContainer(); RidableDolphinContainer container = new RidableDolphinContainer(oldContainer.windowId, player.inventory, dolphin.getInventory()); RidableDolphinScreen screen = new RidableDolphinScreen(container, player.inventory, dolphin.getDisplayName()); player.openContainer = container; event.setGui(screen); } } } }
  9. Hey, how can i associate my custom ContainerScreen to my own entity? Like horse inventory. In order to when i click E to open inventory my custom container should display. But that doesn't append. I have already register the screen in the ScreenManager. Here is my custom entity: public class RidableDolphinEnitity extends DolphinEntity implements INamedContainerProvider { protected Inventory inventory = new Inventory(2); public RidableDolphinEnitity(EntityType<RidableDolphinEnitity> type, World worldIn) { super(type, worldIn); } public Inventory getInventory() { return inventory; } @Nullable @Override public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) { return new RidableDolphinContainer(id, inventory, getInventory()); } @Override public ITextComponent getDisplayName() { return TextComponentUtils.toTextComponent(() -> "Dolphin Inventory"); } }
  10. You should create an issue in the repo of the mod. https://github.com/BluSunrize/ImmersiveEngineering/issues There the creator of the mod could gives you the correct support.
  11. The main problem of the potion effect is that the effect can be seen by everyone instead a sonar like effect should be seen only by the player that has activate the effect.
  12. I have created the packet but the effect still doesn't applies, but i got an idea what if i use setGlowing(true) then i start a thread that sleep for 10 sec then it calls setGlowing(false). Is it a good way?
  13. Ok, but i need a potion like effect because i need that after a while it disappear. I think that the problem is that i haven't the server's world...
  14. Hi, i would like to implement something like a sonar, in order to implement that i get the entities around the player and i apply to them the glowing effect, but i'm facing some problems. Glowing effect does not applies I cant figure out how let just 1 player see the glowing effect because is the server that has to apply the potion effects Here is the code: @SubscribeEvent public static void onSonarActivation(InputEvent.KeyInputEvent event) { if(event.getAction() == GLFW.GLFW_PRESS && event.getKey() == KEY_SONAR.getKey().getKeyCode()) { World world = Minecraft.getInstance().world; ClientPlayerEntity player = Minecraft.getInstance().player; if( world != null && !world.isRemote && player != null && player.getRidingEntity() != null && player.getRidingEntity() instanceof RidableDolphinEnitity ) { AxisAlignedBB box = new AxisAlignedBB( player.getPosX() - 30, player.getPosY() - 30, player.getPosZ() - 30, player.getPosX() + 30, player.getPosX() + 30, player.getPosX() + 30 ); List<LivingEntity> entities = new ArrayList<>(); world.getEntitiesWithinAABBExcludingEntity(player, box).forEach(e -> { if(e instanceof LivingEntity && !(e instanceof RidableDolphinEnitity)) entities.add((LivingEntity) e); }); entities.forEach(e -> e.addPotionEffect(new EffectInstance(Effects.GLOWING, 100))); } } }
  15. I`m using IntelliJ then i added the args to Program aurguments. And it worked thanks a lot
  16. i downloaded the MDK from https://files.minecraftforge.net/, and when i run "runclient", it start a minecraft with Dev username. I should change it.
  17. Hi, i need to change the name of the client of the developement kit. How can i do that?
  18. Here is how i resolved: matrix.push(); matrix.rotate(Vector3f.XN.rotationDegrees(-90)); matrix.rotate(Vector3f.ZN.rotationDegrees(-playerEntity.rotationYaw)); matrix.rotate(Vector3f.YN.rotationDegrees(-playerEntity.rotationYaw));
  19. Ok then i'll try to rotate the player following the dolphin. And then i'll make my rotation.
  20. Oh thanks probably i read some too old post?, i implemented that with the MatrixStack object but when this weir effect in third person, and the player position changes by rotating the visual. Here is the code: MatrixStack matrix = e.getMatrixStack(); matrix.push(); matrix.rotate(Vector3f.XN.rotationDegrees(90));
  21. Now, how i can rotate the entire player model? Like 90deg. I tried this, but i dont see any changes @SubscribeEvent public static void onPlayerRideRender(RenderPlayerEvent.Pre e) { if(e.getPlayer().getRidingEntity() != null && e.getPlayer().getRidingEntity() instanceof RidableDolphinEnitity) { GL11.glPushMatrix(); GL11.glRotated(Math.PI/4, 0, 0 , 0); } }
  22. Ohh, that's why at times it worked, i`m a fool. Thank you very much for helping.
  23. I have already registered the class in the bus: MinecraftForge.EVENT_BUS.register(EventHandler.class);
×
×
  • Create New...

Important Information

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