Compare commits
No commits in common. "5af73939085725cb52bd04d37f08f7bc7f5f3229" and "bdec1683c23f0eeed1fc13f844d1de304a8355fa" have entirely different histories.
5af7393908
...
bdec1683c2
13 changed files with 31 additions and 88 deletions
|
@ -11,6 +11,7 @@ import ru.octol1ttle.knockdowns.client.communication.KnockedNotificationManager;
|
|||
import ru.octol1ttle.knockdowns.client.event.KnockdownsKeyListener;
|
||||
import ru.octol1ttle.knockdowns.client.util.DirectionalCallSound;
|
||||
import ru.octol1ttle.knockdowns.common.IClientProxy;
|
||||
import ru.octol1ttle.knockdowns.common.KnockdownsMod;
|
||||
import ru.octol1ttle.knockdowns.common.data.IKnockdownsPlayerData;
|
||||
import ru.octol1ttle.knockdowns.common.network.packets.s2c.PlayerCalloutS2CPacket;
|
||||
import ru.octol1ttle.knockdowns.common.network.packets.s2c.PlayerKnockedDownS2CPacket;
|
||||
|
@ -26,6 +27,7 @@ public class ClientProxy implements IClientProxy {
|
|||
|
||||
@Override
|
||||
public void onFMLInit(FMLInitializationEvent event) {
|
||||
KnockdownsMod.LOGGER.info("Registering key bindings");
|
||||
KnockdownsKeyListener.registerKeyBindings();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ public class KnockdownsClientEventListener {
|
|||
KnockedNotificationManager.clearDatas();
|
||||
return;
|
||||
}
|
||||
CalloutManager.getCallouts().removeIf(callout -> client.world.getTotalWorldTime() - callout.getValue().getReceiveTime() > 100);
|
||||
KnockedNotificationManager.getKnockedPlayerDatas().removeIf(notification -> client.world.getTotalWorldTime() - notification.getReceiveTime() > 140);
|
||||
CalloutManager.getCallouts().removeIf(callout -> client.world.getTotalWorldTime() - callout.getValue().getReceiveTime() > 60);
|
||||
KnockedNotificationManager.getKnockedPlayerDatas().removeIf(notification -> client.world.getTotalWorldTime() - notification.getReceiveTime() > 100);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -34,16 +34,10 @@ public class CommunicationGui extends KnockdownsBaseGui {
|
|||
|
||||
@Override
|
||||
public void render(float partialTicks, ScaledResolution resolution) {
|
||||
GlStateManager.pushMatrix();
|
||||
float scale = 1.0f;
|
||||
if (resolution.getScaleFactor() > 3) {
|
||||
scale = (float) 3 / resolution.getScaleFactor();
|
||||
GlStateManager.scale(scale, scale, 1.0f);
|
||||
}
|
||||
FontRenderer font = client.fontRenderer;
|
||||
|
||||
int x = SCREEN_EDGE_MARGIN;
|
||||
int y = (int) (resolution.getScaledHeight() / scale - SCREEN_EDGE_MARGIN - font.FONT_HEIGHT);
|
||||
int y = resolution.getScaledHeight() - SCREEN_EDGE_MARGIN - font.FONT_HEIGHT;
|
||||
|
||||
KeyBinding[] sortedBindings = new KeyBinding[4];
|
||||
for (KeyBinding binding : KnockdownsKeyListener.calloutBindings.keySet())
|
||||
|
@ -141,8 +135,6 @@ public class CommunicationGui extends KnockdownsBaseGui {
|
|||
KEY_SIZE
|
||||
);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public void renderCallouts(float partialTicks) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ReviveGui extends KnockdownsBaseGui {
|
|||
String timerText = String.format("%.1f", data.getReviveTimeLeft() / 20.0f);
|
||||
float timerX = (resolution.getScaledWidth() - font.getStringWidth(timerText)) * 0.5f;
|
||||
|
||||
data.getRevivers().removeIf(reviver -> !reviver.isEntityAlive() || IKnockdownsPlayerData.get(reviver).isKnockedDown());
|
||||
data.getRevivers().removeIf(reviver -> reviver.isDead || !reviver.isEntityAlive() || IKnockdownsPlayerData.get(reviver).isKnockedDown());
|
||||
int reviverCount = data.getRevivers().size();
|
||||
TextFormatting color;
|
||||
if (reviverCount == 0) {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package ru.octol1ttle.knockdowns.client.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import ru.octol1ttle.knockdowns.common.data.IKnockdownsPlayerData;
|
||||
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
public abstract class PlayerControllerMPMixin {
|
||||
@ModifyExpressionValue(method = "processRightClickBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemBlock;canPlaceBlockOnSide(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumFacing;Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/item/ItemStack;)Z"))
|
||||
private boolean cancelPlaceIfKnockedDown(boolean original) {
|
||||
return original && !IKnockdownsPlayerData.get(Minecraft.getMinecraft().player).isKnockedDown();
|
||||
}
|
||||
}
|
|
@ -45,14 +45,15 @@ import static ru.octol1ttle.knockdowns.common.KnockdownsUtils.resetKnockedState;
|
|||
@Mod.EventBusSubscriber(modid = Tags.MOD_ID)
|
||||
public class KnockdownsCommonEventListener {
|
||||
public static void onFMLInit(FMLInitializationEvent event) {
|
||||
KnockdownsMod.LOGGER.info("Registering network packets");
|
||||
KnockdownsNetwork.registerPackets();
|
||||
KnockdownsMod.LOGGER.info("Registering capability");
|
||||
KnockdownsCapability.register();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onSoundsRegister(RegistryEvent.Register<SoundEvent> event) {
|
||||
event.getRegistry().register(KnockdownsSoundEvents.CALLOUT);
|
||||
event.getRegistry().register(KnockdownsSoundEvents.KNOCKED_DOWN);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -62,15 +63,6 @@ public class KnockdownsCommonEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerJoin(PlayerLoggedInEvent event) {
|
||||
IKnockdownsPlayerData data = IKnockdownsPlayerData.get(event.player);
|
||||
KnockdownsNetwork.sendToPlayer(
|
||||
new SynchronizePlayerDataS2CPacket.Full(event.player.getEntityId(), data.isKnockedDown(), data.getReviveTimeLeft()),
|
||||
(EntityPlayerMP) event.player
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
MinecraftServer server = event.player.getServer();
|
||||
|
@ -83,15 +75,13 @@ public class KnockdownsCommonEventListener {
|
|||
return;
|
||||
}
|
||||
|
||||
knocked.clearElytraFlying();
|
||||
|
||||
if (allPlayersKnocked(server, knocked)) {
|
||||
knocked.attackEntityFrom(DamageSource.GENERIC, knocked.getMaxHealth());
|
||||
return;
|
||||
}
|
||||
|
||||
List<EntityPlayer> revivers = data.getRevivers();
|
||||
revivers.removeIf(reviver -> !reviver.isEntityAlive() || IKnockdownsPlayerData.get(reviver).isKnockedDown());
|
||||
revivers.removeIf(reviver -> reviver.isDead || !reviver.isEntityAlive() || IKnockdownsPlayerData.get(reviver).isKnockedDown());
|
||||
if (!revivers.isEmpty()) {
|
||||
data.setReviveTimeLeft(data.getReviveTimeLeft() - revivers.size());
|
||||
KnockdownsNetwork.sendToMultiple(
|
||||
|
@ -122,13 +112,7 @@ public class KnockdownsCommonEventListener {
|
|||
data.setTicksKnocked(data.getTicksKnocked() + 1);
|
||||
|
||||
int period = MathHelper.floor(KNOCKED_HURT_PERIOD * 20);
|
||||
if (data.getTicksKnocked() <= KNOCKED_INVULNERABILITY_TICKS) {
|
||||
knocked.setEntityInvulnerable(true);
|
||||
knocked.extinguish();
|
||||
knocked.setAir(300);
|
||||
KnockdownsUtils.clearBadPotionEffects(knocked);
|
||||
knocked.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Integer.MAX_VALUE, 3));
|
||||
} else if (data.getTicksKnocked() % period == 0) {
|
||||
if (data.getTicksKnocked() >= KNOCKED_INVULNERABILITY_TICKS && data.getTicksKnocked() % period == 0) {
|
||||
knocked.setEntityInvulnerable(false);
|
||||
knocked.attackEntityFrom(DamageSource.GENERIC, knocked.getMaxHealth() / (KNOCKED_TENACITY / KNOCKED_HURT_PERIOD));
|
||||
}
|
||||
|
@ -147,17 +131,19 @@ public class KnockdownsCommonEventListener {
|
|||
}
|
||||
|
||||
if (data.isKnockedDown() || allPlayersKnocked(player.getServer(), player)) {
|
||||
data.getRevivers().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
player.clearActivePotions();
|
||||
player.setEntityInvulnerable(true);
|
||||
player.setHealth(1.0f);
|
||||
player.setAbsorptionAmount(player.getMaxHealth() - 1.0f);
|
||||
player.extinguish();
|
||||
player.setAir(300);
|
||||
player.clearElytraFlying();
|
||||
KnockdownsUtils.clearBadPotionEffects(player);
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Integer.MAX_VALUE, 3));
|
||||
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 6000, 3));
|
||||
|
||||
Entity trueSource = event.getSource().getTrueSource();
|
||||
if (trueSource instanceof EntityLiving) {
|
||||
|
@ -246,6 +232,15 @@ public class KnockdownsCommonEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerJoin(PlayerLoggedInEvent event) {
|
||||
IKnockdownsPlayerData data = IKnockdownsPlayerData.get(event.player);
|
||||
KnockdownsNetwork.sendToPlayer(
|
||||
new SynchronizePlayerDataS2CPacket.Full(event.player.getEntityId(), data.isKnockedDown(), data.getReviveTimeLeft()),
|
||||
(EntityPlayerMP) event.player
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerLeave(PlayerLoggedOutEvent event) {
|
||||
for (EntityPlayer knocked : event.player.world.playerEntities) {
|
||||
|
|
|
@ -38,7 +38,6 @@ public class KnockdownsFMLLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixi
|
|||
public List<String> getMixinConfigs() {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("mixins.knockdowns.json");
|
||||
list.add("mixins.knockdowns.client.json");
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public class KnockdownsMod {
|
|||
|
||||
@Mod.EventHandler
|
||||
public void onFMLInit(FMLInitializationEvent event) {
|
||||
LOGGER.info("Initializing");
|
||||
clientProxy.onFMLInit(event);
|
||||
KnockdownsCommonEventListener.onFMLInit(event);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package ru.octol1ttle.knockdowns.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import ru.octol1ttle.knockdowns.common.data.IKnockdownsPlayerData;
|
||||
import ru.octol1ttle.knockdowns.common.network.KnockdownsNetwork;
|
||||
|
@ -18,20 +14,6 @@ public class KnockdownsUtils {
|
|||
public static final float KNOCKED_HURT_PERIOD = 1.2f;
|
||||
public static final float KNOCKED_TENACITY = 60.0f;
|
||||
|
||||
public static void clearBadPotionEffects(EntityPlayerMP player) {
|
||||
List<Potion> removeList = new ArrayList<>();
|
||||
|
||||
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||
if (effect.getPotion().isBadEffect()) {
|
||||
removeList.add(effect.getPotion());
|
||||
}
|
||||
}
|
||||
|
||||
for (Potion potion : removeList) {
|
||||
player.removePotionEffect(potion);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean allPlayersKnocked(MinecraftServer server, EntityPlayer except) {
|
||||
for (EntityPlayer player : server.getPlayerList().getPlayers()) {
|
||||
if (player.equals(except)) {
|
||||
|
@ -50,11 +32,12 @@ public class KnockdownsUtils {
|
|||
data.setKnockedDown(false);
|
||||
data.setReviveTimeLeft(INITIAL_REVIVE_TIME_LEFT);
|
||||
data.setTicksKnocked(0);
|
||||
data.getRevivers().clear();
|
||||
|
||||
KnockdownsNetwork.sendToTrackingAndSelf(
|
||||
new SynchronizePlayerDataS2CPacket.KnockedDown(player.getEntityId(), data.isKnockedDown()),
|
||||
player
|
||||
);
|
||||
|
||||
data.getRevivers().clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package ru.octol1ttle.knockdowns.common.mixin;
|
||||
package ru.octol1ttle.knockdowns.common.mixins;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -19,7 +19,7 @@ public abstract class EntityLivingBaseMixin extends Entity {
|
|||
}
|
||||
|
||||
@Inject(method = "checkTotemDeathProtection", at = @At("RETURN"))
|
||||
private void onTotemActivation(CallbackInfoReturnable<Boolean> cir) {
|
||||
public void onTotemActivation(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (cir.getReturnValue() && ((Object) this) instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) (Object) this;
|
||||
IKnockdownsPlayerData data = IKnockdownsPlayerData.get(player);
|
|
@ -1,4 +1,4 @@
|
|||
package ru.octol1ttle.knockdowns.common.mixin;
|
||||
package ru.octol1ttle.knockdowns.common.mixins;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -8,7 +8,7 @@ import ru.octol1ttle.knockdowns.common.data.IKnockdownsPlayerData;
|
|||
|
||||
@SuppressWarnings("ConstantValue")
|
||||
@Mixin(EntityPlayer.class)
|
||||
public abstract class EntityPlayerMixin {
|
||||
public class EntityPlayerMixin {
|
||||
@ModifyReturnValue(method = "shouldHeal", at = @At("RETURN"))
|
||||
private boolean dontHealIfKnockedDown(boolean original) {
|
||||
if (((Object) this) instanceof EntityPlayer) {
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"package": "ru.octol1ttle.knockdowns.client.mixin",
|
||||
"required": true,
|
||||
"refmap": "${mixin_refmap}",
|
||||
"target": "@env(DEFAULT)",
|
||||
"minVersion": "0.8.5",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [],
|
||||
"server": [],
|
||||
"client": [
|
||||
"PlayerControllerMPMixin"
|
||||
]
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"package": "ru.octol1ttle.knockdowns.common.mixin",
|
||||
"package": "ru.octol1ttle.knockdowns.common.mixins",
|
||||
"required": true,
|
||||
"refmap": "${mixin_refmap}",
|
||||
"target": "@env(DEFAULT)",
|
||||
|
|
Loading…
Add table
Reference in a new issue