forked from c0508383/Backhand
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Caedis <[email protected]>
- Loading branch information
Showing
68 changed files
with
1,370 additions
and
3,995 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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,51 @@ | ||
package xonin.backhand; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.entity.player.EntityPlayerMP; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.common.util.FakePlayer; | ||
|
||
import com.gtnewhorizon.gtnhlib.eventbus.EventBusSubscriber; | ||
|
||
import cpw.mods.fml.common.event.FMLServerStoppingEvent; | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
import cpw.mods.fml.common.gameevent.PlayerEvent; | ||
import xonin.backhand.api.core.BackhandUtils; | ||
import xonin.backhand.utils.EnumAnimations; | ||
import xonin.backhand.packet.OffhandConfigSyncPacket; | ||
import xonin.backhand.packet.OffhandSyncItemPacket; | ||
|
||
@EventBusSubscriber | ||
public class CommonProxy { | ||
|
||
public static ItemStack offhandItemUsed; | ||
|
||
public void load() { | ||
|
||
} | ||
public void load() {} | ||
|
||
public void onServerStopping(FMLServerStoppingEvent event) { | ||
for (EntityPlayer player : Backhand.getServer() | ||
.getConfigurationManager().playerEntityList) { | ||
if (BackhandUtils.getOffhandItem(player) != null) { | ||
BackhandUtils.resetAndDelayHotswap(player, 0); | ||
@SubscribeEvent | ||
public static void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) { | ||
if (!(event.player instanceof EntityPlayerMP playerMP)) { | ||
return; | ||
} | ||
Backhand.packetHandler.sendPacketToPlayer(new OffhandConfigSyncPacket().generatePacket(), playerMP); | ||
ItemStack offhandItem = BackhandUtils.getOffhandItem(playerMP); | ||
if (Backhand.isOffhandBlacklisted(offhandItem)) { | ||
BackhandUtils.setPlayerOffhandItem(playerMP, null); | ||
if (!playerMP.inventory.addItemStackToInventory(offhandItem)) { | ||
event.player.entityDropItem(offhandItem, 0); | ||
} | ||
} | ||
} | ||
|
||
public EntityPlayer getClientPlayer() { | ||
return null; | ||
} | ||
|
||
public void sendAnimationPacket(EnumAnimations animation, EntityPlayer entityPlayer) {} | ||
|
||
// Should not be called on the server anyway | ||
public boolean isRightClickHeld() { | ||
return false; | ||
} | ||
|
||
public int getRightClickCounter() { | ||
return 0; | ||
} | ||
|
||
public void setRightClickCounter(int i) {} | ||
|
||
public int getRightClickDelay() { | ||
return 0; | ||
} | ||
|
||
// Should not be called on the server anyway | ||
public boolean isLeftClickHeld() { | ||
return false; | ||
@SubscribeEvent | ||
public static void addTracking(net.minecraftforge.event.entity.player.PlayerEvent.StartTracking event) { | ||
if (event.entityPlayer instanceof EntityPlayerMP playerMP && isValidPlayer(event.target)) { | ||
Backhand.packetHandler | ||
.sendPacketToPlayer(new OffhandSyncItemPacket((EntityPlayer) event.target).generatePacket(), playerMP); | ||
} | ||
} | ||
|
||
// Should not be called on the server anyway | ||
public int getLeftClickCounter() { | ||
return 0; | ||
private static boolean isValidPlayer(@Nullable Entity entity) { | ||
return entity instanceof EntityPlayerMP playerMP | ||
&& !(entity instanceof FakePlayer || playerMP.playerNetServerHandler == null); | ||
} | ||
|
||
// Should not be called on the server anyway | ||
public void setLeftClickCounter(int i) {} | ||
} |
Oops, something went wrong.