Skip to content

Commit

Permalink
Remove all OptionsList references
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jul 12, 2023
1 parent ba41375 commit e528a36
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player
final Vec3 destPos = Vec3.atCenterOf(hit.getBlockPos())
.add(Vec3.atLowerCornerOf(hit.getDirection().getNormal()).scale(-0.5));
final CompoundTag catapultNbt = new CompoundTag();
catapultNbt.putString("OptionsListData", String.format(
"{destX:%1$f,destY:%2$f,destZ:%3$f,angle:45}", // It's Gson lenient, so we don't need quotes
destPos.x, destPos.y, destPos.z
));
catapultNbt.putDouble("DestX", destPos.x);
catapultNbt.putDouble("DestY", destPos.y);
catapultNbt.putDouble("DestZ", destPos.z);
BlockItem.setBlockEntityData(result, PortalCubedBlocks.CATAPULT_BLOCK_ENTITY, catapultNbt);

final CompoundTag display = new CompoundTag();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// TODO: Reimplement GUI without optionslist
package com.fusionflux.portalcubed.blocks.blockentities;

import com.fusionflux.portalcubed.blocks.PortalCubedBlocks;
import eu.midnightdust.lib.config.MidnightConfig;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -24,16 +22,9 @@
import org.jetbrains.annotations.Nullable;

public class CatapultBlockEntity extends BlockEntity implements ExtendedScreenHandlerFactory {
@MidnightConfig.Entry(min = -30_000_000, max = 30_000_000)
private double destX;

@MidnightConfig.Entry(min = -2032, max = 4064)
private double destY;

@MidnightConfig.Entry(min = -30_000_000, max = 30_000_000)
private double destZ;

@MidnightConfig.Entry(min = 0, max = 90)
private double angle = 45;

public CatapultBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
Expand All @@ -49,12 +40,18 @@ public CatapultBlockEntity(BlockPos pos, BlockState state) {

@Override
public void load(CompoundTag nbt) {
// OptionsListData.read(nbt, this);
destX = nbt.getDouble("DestX");
destY = nbt.getDouble("DestY");
destZ = nbt.getDouble("DestZ");
angle = nbt.contains("Angle") ? nbt.getDouble("Angle") : 45;
}

@Override
protected void saveAdditional(CompoundTag nbt) {
// OptionsListData.write(nbt, this);
nbt.putDouble("DestX", destX);
nbt.putDouble("DestY", destY);
nbt.putDouble("DestZ", destZ);
nbt.putDouble("Angle", angle);
}

@NotNull
Expand All @@ -78,8 +75,7 @@ public Component getDisplayName() {
@Nullable
@Override
public AbstractContainerMenu createMenu(int i, Inventory playerInventory, Player playerEntity) {
return null;
// return new OptionsListScreenHandler(i, worldPosition);
return null; // TODO: Implement GUI
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public void onInitializeClient(ModContainer mod) {

MenuScreens.register(PortalCubed.FAITH_PLATE_SCREEN_HANDLER, FaithPlateScreen::new);
MenuScreens.register(PortalCubed.VELOCITY_HELPER_SCREEN_HANDLER, VelocityHelperScreen::new);
// MenuScreens.register(PortalCubed.OPTIONS_LIST_SCREEN_HANDLER, OptionsListScreen::new);

registerEntityRenderers();
registerColorProviders();
Expand Down Expand Up @@ -425,32 +424,6 @@ Items.LIGHT, new ResourceLocation("level")
BufferUploader.drawWithShader(bufferBuilder.end());
});

// TODO: Note for gaming don't use camera setup for portal rendering
// RecoilEvents.CAMERA_SETUP.register((camera, cameraEntity, perspective, tickDelta, ctrl) -> {
// final Vec3 entityPos = cameraEntity.getPosition(tickDelta);
// final Vec3 startPos = entityPos.add(ctrl.getPos().subtract(entityPos).normalize().scale(0.1));
// final Vec3 endPos = ctrl.getPos();
// final var transformed = PortalDirectionUtils.simpleTransformPassingVector(
// cameraEntity, startPos, endPos, p -> p.getNormal().y < 0
// );
// if (transformed != null) {
// cameraTransformedThroughPortal = transformed.second();
// ctrl.setPos(transformed.first());
// final Quaternionf cameraRot = camera.rotation().mul(
// cameraTransformedThroughPortal.getTransformQuat().toQuaternionf()
// );
// camera.getLookVector().set(0.0F, 0.0F, 1.0F).rotate(cameraRot);
// camera.getUpVector().set(0.0F, 1.0F, 0.0F).rotate(cameraRot);
// camera.getLeftVector().set(1.0F, 0.0F, 0.0F).rotate(cameraRot);
// if (camera.isDetached()) {
// ((CameraExt)camera).backCameraUp(transformed.first());
// ctrl.setPos(camera.getPosition());
// }
// } else {
// cameraTransformedThroughPortal = null;
// }
// });

//noinspection UnstableApiUsage
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(e -> e.addAfter(
i -> i.getItem() instanceof RecordItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class PortalCubedServerPackets {
public static final ResourceLocation GRAB_KEY_PRESSED = id("grab_key_pressed");
public static final ResourceLocation REMOVE_PORTALS = id("remove_portals");
public static final ResourceLocation VELOCITY_HELPER_CONFIGURE = id("velocity_helper_configure");
public static final ResourceLocation OPTIONS_LIST_CONFIGURE = id("options_list_configure");
public static final ResourceLocation PLAY_BOUNCE_SOUND = id("play_bounce_sound");
public static final ResourceLocation CROWBAR_ATTACK = id("crowbar_attack");
public static final ResourceLocation LEFT_CLICK = id("left_click");
Expand Down Expand Up @@ -143,23 +142,10 @@ public static void onVelocityHelperConfigure(MinecraftServer server, ServerPlaye
));
}

public static void onOptionsListConfigure(MinecraftServer server, ServerPlayer player, @SuppressWarnings("unused") ServerGamePacketListenerImpl handler, @SuppressWarnings("unused") FriendlyByteBuf buf, @SuppressWarnings("unused") PacketSender sender) {
// final BlockPos origin = buf.readBlockPos();
// final String json = buf.readUtf();
// server.execute(() -> {
// if (!(player.level().getBlockEntity(origin) instanceof OptionsListBlockEntity optionsListBlockEntity) || !player.isCreative()) {
// return;
// }
// OptionsListData.read(json, optionsListBlockEntity);
// optionsListBlockEntity.updateListeners();
// });
}

public static void registerPackets() {
ServerPlayNetworking.registerGlobalReceiver(GRAB_KEY_PRESSED, PortalCubedServerPackets::onGrabKeyPressed);
ServerPlayNetworking.registerGlobalReceiver(REMOVE_PORTALS, PortalCubedServerPackets::onRemovePortalKeyPressed);
ServerPlayNetworking.registerGlobalReceiver(VELOCITY_HELPER_CONFIGURE, PortalCubedServerPackets::onVelocityHelperConfigure);
ServerPlayNetworking.registerGlobalReceiver(OPTIONS_LIST_CONFIGURE, PortalCubedServerPackets::onOptionsListConfigure);
ServerPlayNetworking.registerGlobalReceiver(
PLAY_BOUNCE_SOUND, (server, player, handler, buf, responseSender) -> PortalCubed.playBounceSound(player)
);
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/assets/portalcubed/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@
"portalcubed.ponder.auto_portal.text_5": "This portal is green because the Auto Portal is still set to secondary.",
"portalcubed.ponder.auto_portal.text_6": "Sneak right-click with a hammer to reset the portal\u0027s base color.",

"optionslist.portalcubed.catapult.destX": "Destination X",
"optionslist.portalcubed.catapult.destY": "Destination Y",
"optionslist.portalcubed.catapult.destZ": "Destination Z",
"optionslist.portalcubed.catapult.angle": "Launch Angle"
"portalcubed.catapult.destX": "Destination X",
"portalcubed.catapult.destY": "Destination Y",
"portalcubed.catapult.destZ": "Destination Z",
"portalcubed.catapult.angle": "Launch Angle"
}

0 comments on commit e528a36

Please sign in to comment.