Skip to content

Commit

Permalink
guten tschüss
Browse files Browse the repository at this point in the history
  • Loading branch information
not-coded committed Dec 27, 2023
1 parent 501c535 commit 053524d
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, bo
.then(Commands.literal("bedwars").executes(ProtectionMapCommand::bedwars))
.then(Commands.literal("ffa")
.then(Commands.literal("uhc").executes(ProtectionMapCommand::ffa_uhc))
.then(Commands.literal("sky").executes(ProtectionMapCommand::ffa_sky))
)
);
}
Expand All @@ -35,4 +36,9 @@ public static int ffa_uhc(CommandContext<CommandSourceStack> context) throws Com
return 1;
}

public static int ffa_sky(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
com.nexia.ffa.sky.utilities.FfaAreas.createProtectionMap(player);
return 1;
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/nexia/core/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ public static class Enhancements {

@Comment("Remove Projectiles going through players [EXPERIMENTAL]")
public boolean projectilePatch = false;

@Comment("Fix Tridents doing 8 damage when thrown, instead of 6")
public boolean tridentDamagePatch = false;
}
}
8 changes: 8 additions & 0 deletions src/main/java/com/nexia/core/mixin/entity/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.nexia.core.mixin.entity;

import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.sky.utilities.FfaAreas;
import net.minecraft.commands.CommandSource;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Nameable;
Expand Down Expand Up @@ -31,6 +32,13 @@ private void hurt(DamageSource damageSource, CallbackInfoReturnable<Boolean> cir
private double modifyVoidY(Entity instance) {
double voidY = -32;

if (instance.level instanceof ServerLevel serverLevel) {

if (FfaAreas.isFfaWorld(serverLevel)) {
voidY = FfaAreas.getVoidY();
}
}

return instance.getY() + 64 - voidY;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.nexia.core.mixin.entity;

import com.nexia.core.Main;
import com.nexia.ffa.sky.utilities.FfaAreas;
import com.nexia.minigames.games.bedwars.custom.BwTrident;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
Expand Down Expand Up @@ -34,9 +37,13 @@ public void tickDespawn(){
private float getDamageBonus(ItemStack itemStack, LivingEntity livingEntity) {
float bonus = EnchantmentHelper.getDamageBonus(itemStack, livingEntity);

/*
if ((Object)this instanceof BwTrident) {
bonus -= 1;
}
*/

if(Main.config.enhancements.tridentDamagePatch) bonus -= 2;

return bonus;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public EnderPearlItemMixin(Item.Properties properties) {
super(properties);
}

@Inject(method = "use", at = @At(value = "HEAD"))
@Inject(method = "use", at = @At(value = "HEAD"), cancellable = true)
private void setPlayer(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir) {
if (player instanceof ServerPlayer serverPlayer) {
thrower = serverPlayer;
Expand All @@ -46,7 +46,6 @@ private void setPlayer(Level level, Player player, InteractionHand interactionHa

}


}

@ModifyArg(method = "use", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemCooldowns;addCooldown(Lnet/minecraft/world/item/Item;I)V"))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nexia/core/mixin/player/PlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void drop1(boolean dropAll, CallbackInfoReturnable<Boolean> cir) {

ItemStack dropped = inventory.getItem(inventory.selected);

if (FfaUtil.isFfaPlayer(player) && !FfaUhcUtil.isFfaPlayer(player)) {
if (FfaUtil.isFfaPlayer(player)) {
cir.setReturnValue(false);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/nexia/core/utilities/misc/EventUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class EventUtil {

public static boolean dropItem(Player player, ItemStack itemStack) {
return !(player.getTags().contains("ffa") || player.getTags().contains("ffa_classic") || player.getTags().contains("ffa_kits") || player.getTags().contains("ffa_sky")) || !LobbyUtil.isLobbyWorld(player.level) || !OitcGame.isOITCPlayer(player);
return !FfaUtil.isFfaPlayer(player) || !LobbyUtil.isLobbyWorld(player.level) || !OitcGame.isOITCPlayer(player);
}

public static void onSignClick(CallbackInfoReturnable<InteractionResult> ci, BlockPos signPos, Level level, ServerPlayer p) {
Expand All @@ -38,6 +38,7 @@ public static void onSignClick(CallbackInfoReturnable<InteractionResult> ci, Blo
if(bp.contains(signPos)) {
SpawnGUI.openSpawnGUI(p);
}

ci.setReturnValue(InteractionResult.PASS);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static void setDeathMessage(@NotNull ServerPlayer minecraftPlayer, @Nulla
}

for (Player player : ServerTime.factoryServer.getPlayers()) {
if (player.hasTag("ffa_kits")) player.sendMessage(msg);
if (player.hasTag("ffa_classic")) player.sendMessage(msg);
}
}

Expand Down Expand Up @@ -313,15 +313,17 @@ public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSour

static {
invItems = new HashMap<>();
ItemStack sword = new ItemStack(Items.NETHERITE_SWORD);
ItemStack sword = new ItemStack(Items.DIAMOND_SWORD);
sword.enchant(Enchantments.SHARPNESS, 1);
sword.getOrCreateTag().putBoolean("Unbreakable", true);
invItems.put(0, sword);

ItemStack trident = new ItemStack(Items.TRIDENT);
trident.getOrCreateTag().putBoolean("Unbreakable", true);
invItems.put(1, trident);

ItemStack axe = new ItemStack(Items.NETHERITE_AXE);
ItemStack axe = new ItemStack(Items.DIAMOND_AXE);
axe.enchant(Enchantments.CLEAVING, 1);
axe.getOrCreateTag().putBoolean("Unbreakable", true);
invItems.put(2, axe);

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/nexia/ffa/sky/utilities/FfaAreas.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
public class FfaAreas {
public static ServerLevel ffaWorld = null;
public static EntityPos spawn = new EntityPos(Main.sky.spawnCoordinates[0], Main.sky.spawnCoordinates[1], Main.sky.spawnCoordinates[2], 0, 0);
public static BlockPos spawnCorner1 = spawn.toBlockPos().offset(-12, -12, -12);
public static BlockPos spawnCorner2 = spawn.toBlockPos().offset(12, 12, 12);
public static BlockPos spawnCorner1 = spawn.toBlockPos().offset(-6, -5, -6);
public static BlockPos spawnCorner2 = spawn.toBlockPos().offset(6, 5, 6);

public static BlockPos ffaCorner1 = spawn.toBlockPos().offset(99, -spawn.y, 132);
public static BlockPos ffaCorner2 = spawn.toBlockPos().offset(-100, spawn.y + 255, -98);
public static BlockPos ffaCorner1 = spawn.toBlockPos().offset(25, -spawn.y, 25);
public static BlockPos ffaCorner2 = spawn.toBlockPos().offset(-25, spawn.y + 255, -25);

public FfaAreas() {
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nexia/ffa/sky/utilities/FfaSkyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ private static ItemStack gApplePotion() {
potion.getOrCreateTag().putInt("CustomPotionColor", 16771584);

ArrayList<MobEffectInstance> effects = new ArrayList<>();
effects.add(new MobEffectInstance(MobEffects.REGENERATION, 80, 2));
effects.add(new MobEffectInstance(MobEffects.REGENERATION, 100, 1));
effects.add(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0));
PotionUtils.setCustomEffects(potion, effects);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nexia/ffa/uhc/utilities/FfaUhcUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static void leaveOrDie(@NotNull ServerPlayer player, @Nullable DamageSour
}

public static boolean canGoToSpawn(ServerPlayer player) {
if(!FfaUhcUtil.isFfaPlayer(player) || FfaUhcUtil.wasInSpawn.contains(player.getUUID())) return true;
if(FfaUhcUtil.isFfaPlayer(player) || FfaUhcUtil.wasInSpawn.contains(player.getUUID())) return true;
return !(player.getHealth() < 20);
}

Expand Down

0 comments on commit 053524d

Please sign in to comment.