9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-06 15:52:03 +00:00

Fix Indentation

This commit is contained in:
iqtester
2025-06-24 11:39:39 -04:00
parent 63efa3fd5e
commit 273bd5d292
10 changed files with 910 additions and 907 deletions

View File

@@ -5,35 +5,35 @@ import org.joml.Vector3f;
import java.util.Objects;
public abstract class AbstractSeat implements Seat {
protected final Vector3f offset;
protected final float yaw;
protected final Vector3f offset;
protected final float yaw;
public AbstractSeat(Vector3f offset, float yaw) {
this.offset = offset;
this.yaw = yaw;
}
public AbstractSeat(Vector3f offset, float yaw) {
this.offset = offset;
this.yaw = yaw;
}
@Override
public Vector3f offset() {
return offset;
}
@Override
public Vector3f offset() {
return offset;
}
@Override
public float yaw() {
return yaw;
}
@Override
public float yaw() {
return yaw;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AbstractSeat seat)) return false;
return Float.compare(yaw, seat.yaw()) == 0 && offset.equals(seat.offset());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AbstractSeat seat)) return false;
return Float.compare(yaw, seat.yaw()) == 0 && offset.equals(seat.offset());
}
@Override
public int hashCode() {
int result = Objects.hash(offset);
result = 31 * result + Float.hashCode(yaw);
return result;
}
@Override
public int hashCode() {
int result = Objects.hash(offset);
result = 31 * result + Float.hashCode(yaw);
return result;
}
}

View File

@@ -4,5 +4,5 @@ import java.util.List;
public interface SeatFactory {
Seat create(List<String> args);
Seat create(List<String> args);
}

View File

@@ -12,49 +12,49 @@ import java.util.ArrayList;
import java.util.List;
public class SeatType {
public static final Key SIT = Key.of("craftengine:sit");
public static final Key LAY = Key.of("craftengine:lay");
public static final Key CRAWL = Key.of("craftengine:crawl");
public static final Key SIT = Key.of("craftengine:sit");
public static final Key LAY = Key.of("craftengine:lay");
public static final Key CRAWL = Key.of("craftengine:crawl");
public static void register(Key key, SeatFactory factory) {
Holder.Reference<SeatFactory> holder =((WritableRegistry<SeatFactory>) BuiltInRegistries.SEAT_FACTORY)
.registerForHolder(new ResourceKey<>(Registries.SEAT_FACTORY.location(), key));
holder.bindValue(factory);
}
public static void register(Key key, SeatFactory factory) {
Holder.Reference<SeatFactory> holder = ((WritableRegistry<SeatFactory>) BuiltInRegistries.SEAT_FACTORY)
.registerForHolder(new ResourceKey<>(Registries.SEAT_FACTORY.location(), key));
holder.bindValue(factory);
}
public static Seat fromString(String s) {
int lastSpaceIndex = s.lastIndexOf(' ');
public static Seat fromString(String s) {
int lastSpaceIndex = s.lastIndexOf(' ');
Key type = SIT;
SeatFactory factory;
String numericPart;
Key type = SIT;
SeatFactory factory;
String numericPart;
if (lastSpaceIndex != -1) {
numericPart = s.substring(lastSpaceIndex + 1);
try {
Float.parseFloat(numericPart);
} catch (NumberFormatException e) {
type = Key.withDefaultNamespace(numericPart, "craftengine");
s = s.substring(0, lastSpaceIndex);
lastSpaceIndex = s.lastIndexOf(' ');
}
}
if (lastSpaceIndex != -1) {
numericPart = s.substring(lastSpaceIndex + 1);
try {
Float.parseFloat(numericPart);
} catch (NumberFormatException e) {
type = Key.withDefaultNamespace(numericPart, "craftengine");
s = s.substring(0, lastSpaceIndex);
lastSpaceIndex = s.lastIndexOf(' ');
}
}
List<String> split = new ArrayList<>();
int start = 0;
while (lastSpaceIndex != -1) {
split.add(s.substring(start, lastSpaceIndex));
start = lastSpaceIndex + 1;
lastSpaceIndex = s.indexOf(' ', start);
}
if (start < s.length()) {
split.add(s.substring(start));
}
List<String> split = new ArrayList<>();
int start = 0;
while (lastSpaceIndex != -1) {
split.add(s.substring(start, lastSpaceIndex));
start = lastSpaceIndex + 1;
lastSpaceIndex = s.indexOf(' ', start);
}
if (start < s.length()) {
split.add(s.substring(start));
}
factory = BuiltInRegistries.SEAT_FACTORY.getValue(type);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.furniture.seat.invalid_type", type.toString());
}
return factory.create(split);
}
factory = BuiltInRegistries.SEAT_FACTORY.getValue(type);
if (factory == null) {
throw new LocalizedResourceConfigException("warning.config.furniture.seat.invalid_type", type.toString());
}
return factory.create(split);
}
}

View File

@@ -8,21 +8,21 @@ import org.joml.Vector3f;
public interface SeatEntity extends EntityPacketHandler {
void add(NetWorkUser from, NetWorkUser to);
void add(NetWorkUser from, NetWorkUser to);
void dismount(Player player);
void dismount(Player player);
void onDismount(Player player);
void onDismount(Player player);
void event(Player player, Object event);
void event(Player player, Object event);
void destroy();
void destroy();
boolean destroyed();
boolean destroyed();
Furniture furniture();
Furniture furniture();
Vector3f vector3f();
Vector3f vector3f();
int playerID();
int playerID();
}