Skip to content

Commit

Permalink
It builds!
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jun 10, 2023
1 parent 5d980aa commit e3c1f95
Show file tree
Hide file tree
Showing 90 changed files with 1,097 additions and 907 deletions.
28 changes: 12 additions & 16 deletions src/main/java/com/fusionflux/portalcubed/PortalCubed.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.fusionflux.portalcubed.client.PortalCubedClient;
import com.fusionflux.portalcubed.client.packet.PortalCubedClientPackets;
import com.fusionflux.portalcubed.commands.PortalCubedCommands;
import com.fusionflux.portalcubed.compat.create.CreateIntegration;
import com.fusionflux.portalcubed.compat.rayon.RayonIntegration;
import com.fusionflux.portalcubed.entity.CorePhysicsEntity;
import com.fusionflux.portalcubed.entity.ExperimentalPortal;
Expand All @@ -36,6 +35,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -47,8 +47,6 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
Expand All @@ -59,9 +57,8 @@
import org.quiltmc.qsl.block.content.registry.api.BlockContentRegistries;
import org.quiltmc.qsl.block.content.registry.api.FlammableBlockEntry;
import org.quiltmc.qsl.command.api.CommandRegistrationCallback;
import org.quiltmc.qsl.entity_events.api.EntityWorldChangeEvents;
import org.quiltmc.qsl.entity_events.api.ServerPlayerEntityCopyCallback;
import org.quiltmc.qsl.item.group.api.QuiltItemGroup;
import org.quiltmc.qsl.entity.event.api.EntityWorldChangeEvents;
import org.quiltmc.qsl.entity.event.api.ServerPlayerEntityCopyCallback;
import org.quiltmc.qsl.networking.api.PacketByteBufs;
import org.quiltmc.qsl.networking.api.ServerPlayConnectionEvents;
import org.quiltmc.qsl.networking.api.ServerPlayNetworking;
Expand All @@ -76,20 +73,16 @@ public class PortalCubed implements ModInitializer {

public static final Logger LOGGER = LogUtils.getLogger();

public static final CreativeModeTab TESTING_ELEMENTS_GROUP = QuiltItemGroup.createWithIcon(
id("testing_elements"),
() -> new ItemStack(PortalCubedItems.PORTAL_GUN));

public static final MenuType<FaithPlateScreenHandler> FAITH_PLATE_SCREEN_HANDLER = Registry.register(
Registry.MENU, id("faith_plate_screen"),
BuiltInRegistries.MENU, id("faith_plate_screen"),
new ExtendedScreenHandlerType<>(FaithPlateScreenHandler::new)
);
public static final MenuType<VelocityHelperScreenHandler> VELOCITY_HELPER_SCREEN_HANDLER = Registry.register(
Registry.MENU, id("velocity_helper"),
BuiltInRegistries.MENU, id("velocity_helper"),
new ExtendedScreenHandlerType<>(VelocityHelperScreenHandler::new)
);
public static final MenuType<OptionsListScreenHandler> OPTIONS_LIST_SCREEN_HANDLER = Registry.register(
Registry.MENU, id("options_list"),
BuiltInRegistries.MENU, id("options_list"),
new ExtendedScreenHandlerType<>(OptionsListScreenHandler::new)
);

Expand Down Expand Up @@ -134,7 +127,9 @@ public void onInitialize(ModContainer mod) {
}
Direction portalFacing = portal.getFacingDirection();
Direction otherDirec = Direction.fromNormal((int) portal.getOtherFacing().x(), (int) portal.getOtherFacing().y(), (int) portal.getOtherFacing().z());
Direction portalVertFacing = Direction.fromNormal(new BlockPos(portal.getAxisH().orElseThrow().x, portal.getAxisH().orElseThrow().y, portal.getAxisH().orElseThrow().z));
Direction portalVertFacing = Direction.fromNormal(BlockPos.containing(
portal.getAxisH().orElseThrow().x, portal.getAxisH().orElseThrow().y, portal.getAxisH().orElseThrow().z
));

IPQuaternion rotationW = IPQuaternion.getRotationBetween(portal.getAxisW().orElseThrow().scale(-1), portal.getOtherAxisW(), (portal.getAxisH().orElseThrow()));
IPQuaternion rotationH = IPQuaternion.getRotationBetween((portal.getAxisH().orElseThrow()), (portal.getOtherAxisH()), portal.getAxisW().orElseThrow().scale(-1));
Expand Down Expand Up @@ -297,13 +292,14 @@ public void onInitialize(ModContainer mod) {
PortalCubedSounds.registerSounds();
PortalCubedGameRules.register();
PortalCubedParticleTypes.register();
BlockContentRegistries.FLAMMABLE_BLOCK.put(PortalCubedBlocks.NEUROTOXIN_BLOCK, new FlammableBlockEntry(10000, 10000));
BlockContentRegistries.FLAMMABLE.put(PortalCubedBlocks.NEUROTOXIN_BLOCK, new FlammableBlockEntry(10000, 10000));
GravityChannel.UPDATE_GRAVITY.getVerifierRegistry().register(AdhesionGravityVerifier.FIELD_GRAVITY_SOURCE, AdhesionGravityVerifier::check);

CommandRegistrationCallback.EVENT.register(new PortalCubedCommands());

if (QuiltLoader.isModLoaded("create")) {
CreateIntegration.init();
LOGGER.warn("Create is out for this game version! Go poke the Portal Cubed developers on Discord to re-enable this integration.");
// CreateIntegration.init();
}

RayonIntegration.INSTANCE.init();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.fusionflux.portalcubed.accessor;

import com.fusionflux.portalcubed.mechanics.PortalCubedDamageSources;

public interface LevelExt {
PortalCubedDamageSources pcDamageSources();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
Expand All @@ -18,6 +17,7 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class NeurotoxinBlock extends BaseEntityBlock {
Expand All @@ -26,6 +26,7 @@ public NeurotoxinBlock(Properties settings) {
super(settings);
}

@NotNull
@Override
@SuppressWarnings("deprecation")
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
Expand All @@ -47,16 +48,17 @@ public boolean propagatesSkylightDown(BlockState state, BlockGetter world, Block
return true;
}

@NotNull
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}

@Override
@SuppressWarnings("deprecation")
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (!world.isClientSide) {
entity.hurt(DamageSource.DROWN, 1);
public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
if (!level.isClientSide) {
entity.hurt(level.damageSources().drown(), 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package com.fusionflux.portalcubed.blocks;

import com.fusionflux.portalcubed.PortalCubed;
import com.fusionflux.portalcubed.items.PortalCubedItems;
import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.level.block.SoundType;
Expand Down Expand Up @@ -52,11 +49,6 @@ public final class PortalBlocksLoader {
@ClientOnly
private static Map<String, RenderType> renderLayers;
private static final Map<String, BlockData> BLOCK_DATA = new LinkedHashMap<>();
ItemGroupEvents
private static final CreativeModeTab ITEM_GROUP = QuiltItemGroup.createWithIcon(
id("portal_blocks"),
() -> new ItemStack(PortalCubedItems.BLOCK_ITEM_ICON)
);

static {
if (MinecraftQuiltLoader.getEnvironmentType() == EnvType.CLIENT) {
Expand Down Expand Up @@ -87,8 +79,8 @@ public static void initCommon() {
BLOCK_DATA.forEach((key, value) -> {
if (value.block == null) return;
final ResourceLocation id = id(key);
Registry.register(Registry.BLOCK, id, value.block);
Registry.register(Registry.ITEM, id, new BlockItem(value.block, new Item.Properties().tab(ITEM_GROUP)));
Registry.register(BuiltInRegistries.BLOCK, id, value.block);
Registry.register(BuiltInRegistries.ITEM, id, new BlockItem(value.block, new Item.Properties()));
});
}

Expand All @@ -103,7 +95,7 @@ public static void initClient() {
}
BlockRenderLayerMap.put(
renderLayer,
Registry.BLOCK.getOptional(id)
BuiltInRegistries.BLOCK.getOptional(id)
.orElseThrow(() -> new IllegalArgumentException("Unknown block in portal_blocks.json " + id))
);
}
Expand All @@ -123,7 +115,7 @@ private static BlockData parseBlock(JsonObject json) {
}
json.remove("type");
final QuiltBlockSettings settings = json.has("inherit")
? Registry.BLOCK.getOptional(new ResourceLocation(GsonHelper.getAsString(json, "inherit")))
? BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(GsonHelper.getAsString(json, "inherit")))
.map(QuiltBlockSettings::copyOf)
.orElseThrow(() -> new IllegalArgumentException("Unknown block " + json.get("inherit")))
: QuiltBlockSettings.of(Material.STONE)
Expand All @@ -149,19 +141,19 @@ private static BlockData parseBlock(JsonObject json) {

private static SoundType parseBlockSounds(JsonElement sounds) {
if (sounds.isJsonPrimitive()) {
return Registry.BLOCK.getOptional(new ResourceLocation(GsonHelper.convertToString(sounds, "sounds")))
return BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(GsonHelper.convertToString(sounds, "sounds")))
.map(b -> b.getSoundType(b.defaultBlockState()))
.orElseThrow(() -> new IllegalArgumentException("Unknown block " + sounds));
}
final JsonObject object = GsonHelper.convertToJsonObject(sounds, "sounds");
return new SoundType(
GsonHelper.getAsFloat(object, "volume", 1f),
GsonHelper.getAsFloat(object, "pitch", 1f),
new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "break"))),
new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "step"))),
new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "place"))),
new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "hit"))),
new SoundEvent(new ResourceLocation(GsonHelper.getAsString(object, "fall")))
SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "break"))),
SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "step"))),
SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "place"))),
SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "hit"))),
SoundEvent.createVariableRangeEvent(new ResourceLocation(GsonHelper.getAsString(object, "fall")))
);
}

Expand Down
Loading

0 comments on commit e3c1f95

Please sign in to comment.