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

ArcaneDiver

Members
  • Posts

    36
  • Joined

  • Last visited

Recent Profile Visitors

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

ArcaneDiver's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  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...
×
×
  • Create New...

Important Information

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