generated from LabyMod/addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added /auswurf and fixed some bugs including a bug caused by LabyMod …
…itself which caused wrong key press detection. As LabyMod won't fix this we had to solve the problem with a workaround.
- Loading branch information
Showing
33 changed files
with
513 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
core/src/main/java/tmb/randy/tmbgriefergames/core/commands/EjectCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package tmb.randy.tmbgriefergames.core.commands; | ||
|
||
import net.labymod.api.client.chat.command.Command; | ||
import tmb.randy.tmbgriefergames.core.Addon; | ||
|
||
public class EjectCommand extends Command { | ||
|
||
public EjectCommand() { | ||
super("auswurf"); | ||
} | ||
|
||
@Override | ||
public boolean execute(String prefix, String[] arguments) { | ||
if(!Addon.isGG()) | ||
return false; | ||
|
||
Addon.getSharedInstance().getBridge().startAuswurf(); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/Auswurf.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package tmb.randy.tmbgriefergames.v1_12_2.util; | ||
|
||
import net.labymod.api.client.gui.screen.key.Key; | ||
import net.labymod.api.event.client.input.KeyEvent; | ||
import net.labymod.api.event.client.input.KeyEvent.State; | ||
import net.labymod.api.event.client.lifecycle.GameTickEvent; | ||
import net.labymod.api.util.I18n; | ||
import net.minecraft.block.BlockChest; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.inventory.ContainerChest; | ||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.inventory.Slot; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.RayTraceResult; | ||
import net.minecraft.util.math.RayTraceResult.Type; | ||
import tmb.randy.tmbgriefergames.core.Addon; | ||
import tmb.randy.tmbgriefergames.core.enums.QueueType; | ||
import tmb.randy.tmbgriefergames.v1_12_2.util.click.ClickManager; | ||
|
||
public class Auswurf { | ||
private boolean active; | ||
private BlockPos chestPos; | ||
|
||
public void onTickEvent(GameTickEvent event) { | ||
if(active && Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().world != null) { | ||
if(Minecraft.getMinecraft().player.openContainer instanceof ContainerChest chest) { | ||
IInventory inv = chest.getLowerChestInventory(); | ||
if(inv.getName().startsWith("§0Lager: ")) { | ||
if(chestPos == null) { | ||
chestPos = getChestPos(); | ||
} else { | ||
if(ClickManager.getSharedInstance().isClickQueueEmpty(QueueType.MEDIUM)) { | ||
for (int i = 0; i < 25; i++) { | ||
Slot slot = chest.getSlot(i); | ||
if(slot.getHasStack()) { | ||
ClickManager.getSharedInstance().dropClick(i); | ||
} | ||
} | ||
|
||
if(ClickManager.getSharedInstance().isClickQueueEmpty(QueueType.MEDIUM)) { | ||
Minecraft.getMinecraft().displayGuiScreen(null); | ||
Minecraft.getMinecraft().player.closeScreen(); | ||
RayTraceResult rayTraceResult = Minecraft.getMinecraft().objectMouseOver; | ||
if(rayTraceResult.typeOfHit == Type.BLOCK && rayTraceResult.getBlockPos().equals(chestPos)) { | ||
Minecraft.getMinecraft().playerController.processRightClickBlock(Minecraft.getMinecraft().player, Minecraft.getMinecraft().world, chestPos, rayTraceResult.sideHit, rayTraceResult.hitVec, EnumHand.MAIN_HAND); | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void onKeyEvent(KeyEvent event) { | ||
if(event.state() == State.PRESS) { | ||
if (active && event.key() == Key.ESCAPE) { | ||
ClickManager.getSharedInstance().clearAllQueues(); | ||
Addon.getSharedInstance().displayNotification(I18n.getTranslation("tmbgriefergames.eject.disabled")); | ||
chestPos = null; | ||
active = false; | ||
} | ||
} | ||
} | ||
|
||
public void startAuswurf() { | ||
Addon.getSharedInstance().displayNotification(I18n.getTranslation("tmbgriefergames.eject.enabled")); | ||
active = true; | ||
} | ||
|
||
private static BlockPos getChestPos() { | ||
Minecraft mc = Minecraft.getMinecraft(); | ||
RayTraceResult rayTraceResult = mc.objectMouseOver; | ||
|
||
if (rayTraceResult != null && rayTraceResult.typeOfHit == RayTraceResult.Type.BLOCK) { | ||
BlockPos blockPosition = rayTraceResult.getBlockPos(); | ||
IBlockState blockState = mc.world.getBlockState(blockPosition); | ||
|
||
if (blockState.getBlock() instanceof BlockChest) { | ||
return blockPosition; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private static Entity getEntityInBlockPos(BlockPos pos) { | ||
Minecraft mc = Minecraft.getMinecraft(); | ||
for (Entity entity : mc.world.loadedEntityList) { | ||
if (entity instanceof EntityLivingBase && entity.getDistanceSq(pos) < 2) { | ||
return entity; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.