Skip to content

Commit

Permalink
Merge branch 'wolfe's-version' into wolfe-version
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfebersahd authored Dec 17, 2024
2 parents ed545b8 + 08e3163 commit ecdf04d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.countercraft.movecraft.CruiseDirection;
import net.countercraft.movecraft.Movecraft;
import net.countercraft.movecraft.MovecraftLocation;
import net.countercraft.movecraft.util.hitboxes.SolidHitBox;
import net.countercraft.movecraft.async.rotation.RotationTask;
import net.countercraft.movecraft.async.translation.TranslationTask;
import net.countercraft.movecraft.craft.Craft;
Expand All @@ -32,13 +33,16 @@
import net.countercraft.movecraft.events.CraftReleaseEvent;
import net.countercraft.movecraft.mapUpdater.MapUpdateManager;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -287,16 +291,33 @@ else if (dive) {

//Controls sinking crafts
private void processSinking() {
//copy the crafts before iteration to prevent concurrent modifications
// Copy the crafts before iteration to prevent concurrent modifications
List<Craft> crafts = Lists.newArrayList(CraftManager.getInstance());
for (Craft craft : crafts) {
if (!(craft instanceof SinkingCraft))
continue;

if (craft.getHitBox().isEmpty() || craft.getHitBox().getMinY() < (craft.getWorld().getMinHeight() +5 )) {

CraftManager.getInstance().release(craft, CraftReleaseEvent.Reason.SUNK, false);
continue;
}
if (craft.getHitBox().getMinY() == craft.getWorld().getMinHeight()) {
removeBottomLayer(craft);
MovecraftLocation start = new MovecraftLocation(
craft.getHitBox().getMinX(),
craft.getHitBox().getMinY() + 1,
craft.getHitBox().getMinZ()
);
MovecraftLocation end = new MovecraftLocation(
craft.getHitBox().getMaxX(),
craft.getHitBox().getMaxY(),
craft.getHitBox().getMaxZ()
);
SolidHitBox newHitBox = new SolidHitBox(start, end);
craft.setHitBox(newHitBox);
continue;
}

long ticksElapsed = (System.currentTimeMillis() - craft.getLastCruiseUpdate()) / 50;
if (Math.abs(ticksElapsed) < craft.getType().getIntProperty(CraftType.SINK_RATE_TICKS))
continue;
Expand All @@ -312,6 +333,29 @@ private void processSinking() {
}
}


private void removeBottomLayer(Craft craft) {
if (craft.getHitBox().isEmpty()) {
return;
}

int bottomY = craft.getHitBox().getMinY();
int width = craft.getHitBox().getXLength();
int length = craft.getHitBox().getZLength();
int startX = craft.getHitBox().getMinX();
int startZ = craft.getHitBox().getMinZ();
World world = craft.getWorld();

for (int x = startX; x < startX + width; x++) {
for (int z = startZ; z < startZ + length; z++) {
Block block = world.getBlockAt(x, bottomY, z);
if (block.getType() != Material.AIR) {
block.setType(Material.AIR);
}
}
}
}

public void run() {
clearAll();

Expand Down
23 changes: 12 additions & 11 deletions api/src/main/java/net/countercraft/movecraft/util/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,22 @@ public class Tags {

FALL_THROUGH_BLOCKS.add(m);
}
//commented out blocks that would be griefable on my personal server
FALL_THROUGH_BLOCKS.add(Material.DEAD_BUSH);
FALL_THROUGH_BLOCKS.addAll(Tag.CORAL_PLANTS.getValues());
FALL_THROUGH_BLOCKS.add(Material.BROWN_MUSHROOM);
FALL_THROUGH_BLOCKS.add(Material.RED_MUSHROOM);
FALL_THROUGH_BLOCKS.add(Material.TORCH);
//FALL_THROUGH_BLOCKS.add(Material.BROWN_MUSHROOM);
//FALL_THROUGH_BLOCKS.add(Material.RED_MUSHROOM);
//FALL_THROUGH_BLOCKS.add(Material.TORCH);
FALL_THROUGH_BLOCKS.add(Material.FIRE);
FALL_THROUGH_BLOCKS.add(Material.REDSTONE_WIRE);
FALL_THROUGH_BLOCKS.add(Material.LADDER);
FALL_THROUGH_BLOCKS.addAll(Tag.SIGNS.getValues());
FALL_THROUGH_BLOCKS.add(Material.LEVER);
FALL_THROUGH_BLOCKS.add(Material.STONE_BUTTON);
//FALL_THROUGH_BLOCKS.add(Material.REDSTONE_WIRE);
//FALL_THROUGH_BLOCKS.add(Material.LADDER);
//FALL_THROUGH_BLOCKS.addAll(Tag.SIGNS.getValues());
//FALL_THROUGH_BLOCKS.add(Material.LEVER);
//FALL_THROUGH_BLOCKS.add(Material.STONE_BUTTON);
FALL_THROUGH_BLOCKS.add(Material.SNOW);
FALL_THROUGH_BLOCKS.add(Material.CARROT);
FALL_THROUGH_BLOCKS.add(Material.POTATO);
FALL_THROUGH_BLOCKS.addAll(Tag.FENCES.getValues());
//FALL_THROUGH_BLOCKS.add(Material.CARROT);
//FALL_THROUGH_BLOCKS.add(Material.POTATO);
//FALL_THROUGH_BLOCKS.addAll(Tag.FENCES.getValues());
FALL_THROUGH_BLOCKS.addAll(FLUID);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ public interface HitBox extends Iterable<MovecraftLocation>{
default int getXLength() {
if (isEmpty())
return 0;

return Math.abs(getMaxX() - getMinX() +1 );
}

default int getYLength() {
if (isEmpty())
return 0;

return Math.abs(getMaxY() - getMinY() +1 );
}

default int getZLength() {
if (isEmpty())
return 0;

return Math.abs(getMaxZ() -getMinZ() +1 );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,4 @@ public BlockPos getTickPosition() {
return tickPosition;
}
}
}
}

0 comments on commit ecdf04d

Please sign in to comment.