Skip to content

Commit

Permalink
It compiles!
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jun 29, 2023
1 parent a1a617d commit f4479c3
Show file tree
Hide file tree
Showing 64 changed files with 484 additions and 1,115 deletions.
25 changes: 12 additions & 13 deletions src/main/java/com/fusionflux/portalcubed/PortalCubed.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.fusionflux.portalcubed.gui.FaithPlateScreenHandler;
import com.fusionflux.portalcubed.gui.VelocityHelperScreenHandler;
import com.fusionflux.portalcubed.items.PortalCubedItems;
import com.fusionflux.portalcubed.optionslist.OptionsListScreenHandler;
import com.fusionflux.portalcubed.packet.PortalCubedServerPackets;
import com.fusionflux.portalcubed.particle.PortalCubedParticleTypes;
import com.fusionflux.portalcubed.sound.PortalCubedSounds;
Expand Down Expand Up @@ -84,10 +83,10 @@ BuiltInRegistries.MENU, id("faith_plate_screen"),
BuiltInRegistries.MENU, id("velocity_helper"),
new ExtendedScreenHandlerType<>(VelocityHelperScreenHandler::new)
);
public static final MenuType<OptionsListScreenHandler> OPTIONS_LIST_SCREEN_HANDLER = Registry.register(
BuiltInRegistries.MENU, id("options_list"),
new ExtendedScreenHandlerType<>(OptionsListScreenHandler::new)
);
// public static final MenuType<OptionsListScreenHandler> OPTIONS_LIST_SCREEN_HANDLER = Registry.register(
// BuiltInRegistries.MENU, id("options_list"),
// new ExtendedScreenHandlerType<>(OptionsListScreenHandler::new)
// );

public static final double MAX_SPEED = 2225 / 64.0 / 20.0, MAX_SPEED_SQR = MAX_SPEED * MAX_SPEED;

Expand All @@ -112,7 +111,7 @@ public void onInitialize(ModContainer mod) {
}
server.execute(() -> {
boolean rubberband = false;
if (!(player.level.getEntity(targetEntityId) instanceof Portal portal)) {
if (!(player.level().getEntity(targetEntityId) instanceof Portal portal)) {
LOGGER.warn("{} tried to teleport through nonexistent portal", player);
handler.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
CalledValues.setIsTeleporting(player, false);
Expand Down Expand Up @@ -176,7 +175,7 @@ public void onInitialize(ModContainer mod) {
double y = buf.readDouble();
double z = buf.readDouble();
server.execute(() -> {
final BlockEntity entity = player.level.getBlockEntity(target);
final BlockEntity entity = player.level().getBlockEntity(target);
if (entity instanceof FaithPlateBlockEntity faithPlateBlockEntity) {
faithPlateBlockEntity.setVelX(x);
faithPlateBlockEntity.setVelY(y);
Expand Down Expand Up @@ -211,7 +210,7 @@ public void onInitialize(ModContainer mod) {
float rotYaw = buf.readFloat();
UUID cubeuuid = buf.readUUID();
server.execute(() -> {
if (!(player.getLevel().getEntity(cubeuuid) instanceof CorePhysicsEntity cube)) {
if (!(player.serverLevel().getEntity(cubeuuid) instanceof CorePhysicsEntity cube)) {
LOGGER.warn("{} tried to drop nonexistent physics object", player);
return;
}
Expand All @@ -233,13 +232,13 @@ public void onInitialize(ModContainer mod) {
});

ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
if (!handler.player.level.getGameRules().getBoolean(PortalCubedGameRules.ALLOW_CROUCH_FLY_GLITCH)) {
if (!handler.player.level().getGameRules().getBoolean(PortalCubedGameRules.ALLOW_CROUCH_FLY_GLITCH)) {
// Default is true on the client, so we don't need to send in that case
final FriendlyByteBuf buf = PacketByteBufs.create();
buf.writeBoolean(false);
handler.send(ServerPlayNetworking.createS2CPacket(PortalCubedClientPackets.ENABLE_CFG, buf));
}
if (handler.player.level.getGameRules().getBoolean(PortalCubedGameRules.USE_PORTAL_HUD)) {
if (handler.player.level().getGameRules().getBoolean(PortalCubedGameRules.USE_PORTAL_HUD)) {
// Same as above, but false
final FriendlyByteBuf buf = PacketByteBufs.create();
buf.writeBoolean(true);
Expand Down Expand Up @@ -288,7 +287,7 @@ public void onInitialize(ModContainer mod) {

public static void syncFog(ServerPlayer player) {
final FriendlyByteBuf buf = PacketByteBufs.create();
FogSettings.encodeOptional(FogPersistentState.getOrCreate((ServerLevel)player.level).getSettings(), buf);
FogSettings.encodeOptional(FogPersistentState.getOrCreate(player.serverLevel()).getSettings(), buf);
ServerPlayNetworking.send(player, PortalCubedClientPackets.SET_CUSTOM_FOG, buf);
}

Expand All @@ -302,11 +301,11 @@ public static void syncFog(ServerLevel world) {
}

public static void playBounceSound(Entity entity) {
entity.level.playSound(
entity.level().playSound(
null,
entity.position().x(), entity.position().y(), entity.position().z(),
PortalCubedSounds.GEL_BOUNCE_EVENT, SoundSource.BLOCKS,
1f, 0.95f + entity.level.random.nextFloat() * 0.1f
1f, 0.95f + entity.level().random.nextFloat() * 0.1f
);
}

Expand Down
20 changes: 11 additions & 9 deletions src/main/java/com/fusionflux/portalcubed/PortalTabsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.TagParser;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.flag.FeatureFlagSet;
Expand All @@ -30,8 +31,6 @@
import java.util.function.Predicate;
import java.util.function.Supplier;

import static com.fusionflux.portalcubed.PortalCubed.id;

public class PortalTabsLoader {
private static final Map<String, Function<JsonObject, Predicate<CreativeModeTab.ItemDisplayParameters>>> CONDITION_TYPES = Map.of(
"and", o -> GsonHelper.getAsJsonArray(o, "conditions")
Expand Down Expand Up @@ -61,19 +60,22 @@ public class PortalTabsLoader {
);

public static void load(ModContainer mod) {
final JsonObject jsonObject;
final JsonArray jsonArray;
try (Reader reader = Files.newBufferedReader(mod.getPath("portal_tabs.json"))) {
jsonObject = GsonHelper.parse(reader);
jsonArray = GsonHelper.parseArray(reader);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
load(jsonObject);
load(jsonArray);
}

private static void load(JsonObject jsonObject) {
for (final var entry : jsonObject.entrySet()) {
final CreativeModeTab.Builder builder = FabricItemGroup.builder(id(entry.getKey()));
final JsonObject entryData = GsonHelper.convertToJsonObject(entry.getValue(), "tab");
private static void load(JsonArray jsonArray) {
for (final var entry : jsonArray) {
final CreativeModeTab.Builder builder = FabricItemGroup.builder();
final JsonObject entryData = GsonHelper.convertToJsonObject(entry, "tab");
if (entryData.has("title")) {
builder.title(Component.Serializer.fromJson(entryData.get("title")));
}
if (entryData.has("icon")) {
builder.icon(parseItemStack(entryData.get("icon"), "icon"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void entityInside(BlockState state, Level world, BlockPos pos, Entity ent

private void addCollisionEffects(Level world, Entity entity, BlockPos pos, BlockState state) {
FriendlyByteBuf info = AdhesionGravityVerifier.packInfo(pos);
if ((entity.isOnGround() && entity.horizontalCollision) || (!entity.isOnGround() && entity.horizontalCollision) || (!entity.isOnGround() && !entity.horizontalCollision)) {
if ((entity.onGround() && entity.horizontalCollision) || (!entity.onGround() && entity.horizontalCollision) || (!entity.onGround() && !entity.horizontalCollision)) {
if (((EntityExt) entity).getGelTimer() == 0) {
Direction current = GravityChangerAPI.getGravityDirection(entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.*;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -277,13 +276,6 @@ public static int getColor(Level world, BlockPos pos) {
);
}

@NotNull
@Override
@SuppressWarnings("deprecation")
public PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.DESTROY;
}

@NotNull
@Override
@SuppressWarnings("deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public boolean propagatesSkylightDown(BlockState state, BlockGetter world, Block

public static boolean collides(Entity entity, BlockPos pos, BlockState state) {
return Shapes.joinIsNotEmpty(
state.getShape(entity.level, pos, CollisionContext.of(entity)).move(pos.getX(), pos.getY(), pos.getZ()),
state.getShape(entity.level(), pos, CollisionContext.of(entity)).move(pos.getX(), pos.getY(), pos.getZ()),
Shapes.create(entity.getBoundingBox()),
BooleanOp.AND
);
Expand Down
76 changes: 76 additions & 0 deletions src/main/java/com/fusionflux/portalcubed/blocks/MapColorNames.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.fusionflux.portalcubed.blocks;

import com.google.common.collect.ImmutableMap;
import net.minecraft.world.level.material.MapColor;

import java.util.Map;

public class MapColorNames {
public static final Map<String, MapColor> COLORS = ImmutableMap.<String, MapColor>builder()
.put("none", MapColor.NONE)
.put("grass", MapColor.GRASS)
.put("sand", MapColor.SAND)
.put("wool", MapColor.WOOL)
.put("fire", MapColor.FIRE)
.put("ice", MapColor.ICE)
.put("metal", MapColor.METAL)
.put("plant", MapColor.PLANT)
.put("snow", MapColor.SNOW)
.put("clay", MapColor.CLAY)
.put("dirt", MapColor.DIRT)
.put("stone", MapColor.STONE)
.put("water", MapColor.WATER)
.put("wood", MapColor.WOOD)
.put("quartz", MapColor.QUARTZ)
.put("color_orange", MapColor.COLOR_ORANGE)
.put("color_magenta", MapColor.COLOR_MAGENTA)
.put("color_light_blue", MapColor.COLOR_LIGHT_BLUE)
.put("color_yellow", MapColor.COLOR_YELLOW)
.put("color_light_green", MapColor.COLOR_LIGHT_GREEN)
.put("color_pink", MapColor.COLOR_PINK)
.put("color_gray", MapColor.COLOR_GRAY)
.put("color_light_gray", MapColor.COLOR_LIGHT_GRAY)
.put("color_cyan", MapColor.COLOR_CYAN)
.put("color_purple", MapColor.COLOR_PURPLE)
.put("color_blue", MapColor.COLOR_BLUE)
.put("color_brown", MapColor.COLOR_BROWN)
.put("color_green", MapColor.COLOR_GREEN)
.put("color_red", MapColor.COLOR_RED)
.put("color_black", MapColor.COLOR_BLACK)
.put("gold", MapColor.GOLD)
.put("diamond", MapColor.DIAMOND)
.put("lapis", MapColor.LAPIS)
.put("emerald", MapColor.EMERALD)
.put("podzol", MapColor.PODZOL)
.put("nether", MapColor.NETHER)
.put("terracotta_white", MapColor.TERRACOTTA_WHITE)
.put("terracotta_orange", MapColor.TERRACOTTA_ORANGE)
.put("terracotta_magenta", MapColor.TERRACOTTA_MAGENTA)
.put("terracotta_light_blue", MapColor.TERRACOTTA_LIGHT_BLUE)
.put("terracotta_yellow", MapColor.TERRACOTTA_YELLOW)
.put("terracotta_light_green", MapColor.TERRACOTTA_LIGHT_GREEN)
.put("terracotta_pink", MapColor.TERRACOTTA_PINK)
.put("terracotta_gray", MapColor.TERRACOTTA_GRAY)
.put("terracotta_light_gray", MapColor.TERRACOTTA_LIGHT_GRAY)
.put("terracotta_cyan", MapColor.TERRACOTTA_CYAN)
.put("terracotta_purple", MapColor.TERRACOTTA_PURPLE)
.put("terracotta_blue", MapColor.TERRACOTTA_BLUE)
.put("terracotta_brown", MapColor.TERRACOTTA_BROWN)
.put("terracotta_green", MapColor.TERRACOTTA_GREEN)
.put("terracotta_red", MapColor.TERRACOTTA_RED)
.put("terracotta_black", MapColor.TERRACOTTA_BLACK)
.put("crimson_nylium", MapColor.CRIMSON_NYLIUM)
.put("crimson_stem", MapColor.CRIMSON_STEM)
.put("crimson_hyphae", MapColor.CRIMSON_HYPHAE)
.put("warped_nylium", MapColor.WARPED_NYLIUM)
.put("warped_stem", MapColor.WARPED_STEM)
.put("warped_hyphae", MapColor.WARPED_HYPHAE)
.put("warped_wart_block", MapColor.WARPED_WART_BLOCK)
.put("deepslate", MapColor.DEEPSLATE)
.put("raw_iron", MapColor.RAW_IRON)
.put("glow_lichen", MapColor.GLOW_LICHEN)
.build();

private MapColorNames() {
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.Material;
import org.jetbrains.annotations.Nullable;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.loader.api.minecraft.ClientOnly;
Expand Down Expand Up @@ -122,7 +121,7 @@ private static BlockData parseBlock(JsonObject json) {
? BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(GsonHelper.getAsString(json, "inherit")))
.map(QuiltBlockSettings::copyOf)
.orElseThrow(() -> new IllegalArgumentException("Unknown block " + json.get("inherit")))
: QuiltBlockSettings.of(Material.STONE)
: PortalCubedBlocks.settings()
.strength(3.5f, 3.5f)
.requiresTool();
json.remove("inherit");
Expand All @@ -137,7 +136,7 @@ private static BlockData parseBlock(JsonObject json) {
case "slipperiness" -> settings.friction(GsonHelper.convertToFloat(value, "slipperiness"));
case "sounds" -> settings.sound(parseBlockSounds(value));
case "map_color" -> settings.mapColor(
Optional.ofNullable(MaterialColorNames.COLORS.get(GsonHelper.convertToString(value, "map_color")))
Optional.ofNullable(MapColorNames.COLORS.get(GsonHelper.convertToString(value, "map_color")))
.orElseThrow(() -> new IllegalArgumentException("Unknown map_color " + value))
);
case "render_layer" -> renderLayer = GsonHelper.convertToString(value, "render_layer");
Expand Down
Loading

0 comments on commit f4479c3

Please sign in to comment.