Skip to content

Commit

Permalink
fix: small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Restioson committed Jun 16, 2024
1 parent 8ea80d9 commit 9545945
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 29 deletions.
24 changes: 10 additions & 14 deletions src/main/java/io/github/restioson/siege/game/SiegeKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ public record SiegeKit(Text name, List<KitEquipment> equipment, List<KitResource
new KitEquipment(Items.WOODEN_AXE, EquipmentSlot.MAINHAND),
new KitEquipment(Items.WOODEN_SWORD)
),
List.of(
new KitResource(
Text.translatable("game.siege.kit.items.wood"),
Items.CHERRY_PLANKS,
Items.BIRCH_PLANKS,
SiegePersonalResource.WOOD,
EquipmentSlot.OFFHAND,
12
)
),
List.of(KitResource.PLANKS),
List.of()
);
public static final SiegeKit DEMOLITIONER = new SiegeKit(
Expand Down Expand Up @@ -298,6 +289,14 @@ public ItemStack buildItemStack(GameTeam team) {
public record KitResource(Text name, Item attackerItem, Item defenderItem, @Nullable SiegePersonalResource resource,
@Nullable EquipmentSlot equipmentSlot, int max) {
public static final KitResource STEAK = new KitResource(Items.COOKED_BEEF.getName(), Items.COOKED_BEEF, null, null, 10);
public static final KitResource PLANKS = new KitResource(
Text.translatable("game.siege.kit.items.wood"),
Items.CHERRY_PLANKS,
Items.BIRCH_PLANKS,
SiegePersonalResource.WOOD,
EquipmentSlot.OFFHAND,
12
);

public KitResource(Text name, Item item, @Nullable SiegePersonalResource resource, EquipmentSlot equipmentSlot, int max) {
this(name, item, item, resource, equipmentSlot, max);
Expand All @@ -308,10 +307,7 @@ public KitResource(Text name, Item item, @Nullable SiegePersonalResource resourc
}

public ItemStackBuilder itemStackBuilder(GameTeam team) {
return ItemStackBuilder
.of(this.itemForTeam(team))
.setUnbreakable()
.setDyeColor(team.config().dyeColor().getRgb());
return ItemStackBuilder.of(this.itemForTeam(team));
}

public Item itemForTeam(GameTeam team) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@

public enum CapturingState {
CAPTURING(Text.literal("Capturing..").formatted(Formatting.GOLD)),
RECAPTURE_DISABLED(Text.literal("Recapture is disabled for this game!").formatted(Formatting.RED)),
CONTESTED(Text.literal("Contested!").formatted(Formatting.GRAY)),
SECURING(Text.literal("Securing..").formatted(Formatting.AQUA)),
PREREQUISITE_REQUIRED(Text.literal("Cannot capture yet!").formatted(Formatting.RED));
RECAPTURE_DISABLED(Text.literal("Recapture is disabled for this game!").formatted(Formatting.RED), false),
PREREQUISITE_REQUIRED(Text.literal("Cannot capture yet!").formatted(Formatting.RED), false);

private final Text name;
private final boolean hasAlert;

CapturingState(Text name) {
this.name = name;
this.hasAlert = true;
}

CapturingState(Text name, boolean hasAlert) {
this.name = name;
this.hasAlert = hasAlert;
}


public Text getName() {
return this.name;
}

public boolean hasAlert() {
return this != PREREQUISITE_REQUIRED;
return this.hasAlert;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@
import xyz.nucleoid.plasmid.game.player.PlayerSet;
import xyz.nucleoid.plasmid.game.rule.GameRuleType;
import xyz.nucleoid.plasmid.util.PlayerRef;
import xyz.nucleoid.stimuli.event.block.BlockBreakEvent;
import xyz.nucleoid.stimuli.event.block.BlockPlaceEvent;
import xyz.nucleoid.stimuli.event.block.BlockPunchEvent;
import xyz.nucleoid.stimuli.event.block.BlockUseEvent;
import xyz.nucleoid.stimuli.event.block.*;
import xyz.nucleoid.stimuli.event.item.ItemThrowEvent;
import xyz.nucleoid.stimuli.event.item.ItemUseEvent;
import xyz.nucleoid.stimuli.event.player.PlayerAttackEntityEvent;
Expand Down Expand Up @@ -89,6 +86,11 @@ public class SiegeActive {
public static int TNT_GATE_DAMAGE = 10;
public SiegeMap map;

private final static List<Item> PLANKS = List.of(
SiegeKit.KitResource.PLANKS.attackerItem(),
SiegeKit.KitResource.PLANKS.defenderItem()
);

private SiegeActive(ServerWorld world, GameActivity activity, SiegeMap map, SiegeConfig config, GlobalWidgets widgets, Multimap<GameTeamKey, ServerPlayerEntity> players) {
this.world = world;
this.gameSpace = activity.getGameSpace();
Expand Down Expand Up @@ -128,6 +130,7 @@ public static void open(ServerWorld world, GameSpace gameSpace, SiegeMap map, Si
activity.allow(GameRuleType.FALL_DAMAGE);
activity.allow(GameRuleType.PLACE_BLOCKS);
activity.allow(GameRuleType.UNSTABLE_TNT);
activity.listen(BlockDropItemsEvent.EVENT, active::onBlockDrop);

activity.listen(GameActivityEvents.ENABLE, active::onOpen);
activity.listen(GameActivityEvents.DISABLE, active::onClose);
Expand All @@ -154,6 +157,11 @@ public static void open(ServerWorld world, GameSpace gameSpace, SiegeMap map, Si
});
}

private TypedActionResult<List<ItemStack>> onBlockDrop(Entity entity, ServerWorld world, BlockPos blockPos, BlockState blockState, List<ItemStack> itemStacks) {
itemStacks.removeIf(stack -> !PLANKS.contains(stack.getItem()));
return TypedActionResult.success(itemStacks);
}

private void onExplosion(Explosion explosion, boolean particles) {
gate:
for (SiegeGate gate : this.map.gates) {
Expand Down Expand Up @@ -421,9 +429,17 @@ private MutableText getDeathMessageAndIncStats(ServerPlayerEntity player, Damage
var world = this.world;
long time = world.getTime();

MutableText eliminationMessage = Text.literal(" was killed by ");
MutableText eliminationMessage = Text.literal(" was ");
SiegePlayer attacker = null;

if (source.isIn(DamageTypeTags.IS_EXPLOSION)) {
eliminationMessage.append("blown up");
} else {
eliminationMessage.append("killed");
}

eliminationMessage.append(" by ");

if (source.getAttacker() != null) {
eliminationMessage.append(source.getAttacker().getDisplayName());

Expand Down Expand Up @@ -569,7 +585,7 @@ private void tickWarpingPlayers() {
return true;
}

if (this.world.getTime() - warpingPlayer.startTime > 20 * 3) {
if (this.world.getTime() - warpingPlayer.startTime > 20 * 2) {
SiegeSpawn respawn = warpingPlayer.destination.getRespawnFor(warpingPlayer.destination.team);
assert respawn != null; // TODO remove restriction
Vec3d pos = SiegeSpawnLogic.choosePos(player.getRandom(), respawn.bounds(), 0.5f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ private void tickCaptureFlag(ServerWorld world, SiegeFlag flag, int interval) {
}
}

if (defendersAtFlag && flag.team != SiegeTeams.DEFENDERS) {
capturingState = CapturingState.RECAPTURE_DISABLED;
} else if (capturingState != null && !flag.isReadyForCapture()) {
capturingState = CapturingState.PREREQUISITE_REQUIRED;
if (capturingState != null) {
if (defendersAtFlag && flag.team != SiegeTeams.DEFENDERS) {
capturingState = CapturingState.RECAPTURE_DISABLED;
} else if (!flag.isReadyForCapture()) {
capturingState = CapturingState.PREREQUISITE_REQUIRED;
}
}

flag.capturingState = capturingState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public final class WarpSelectionUi extends SimpleGui {
private WarpSelectionUi(ServerPlayerEntity player, List<GuiElementInterface> selectors) {
super(ScreenHandlerType.GENERIC_9X1, player, false);
super(ScreenHandlerType.GENERIC_9X3, player, false);
this.setTitle(Text.literal("Warp to a Point"));
selectors.forEach(this::addSlot);
}
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/data/siege/games/canal_recapture.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
"translate": "game.siege.siege.desc"
},
{
"translate": "game.siege.recapture.desc"
"translate": "game.siege.recapture.desc.1"
},
{
"translate": "game.siege.recapture.desc.2"
},
{
"translate": "game.siege.recapture.desc.3"
}
],
"map": {
Expand Down
Binary file modified src/main/resources/data/siege/map_templates/canal.nbt
Binary file not shown.

0 comments on commit 9545945

Please sign in to comment.