Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to LiteLoadLib #212

Open
wants to merge 2 commits into
base: main-1.19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ buildscript {
maven { url = 'https://maven.parchmentmc.org' }
maven { url = 'https://cursemaven.com' }
mavenCentral()
mavenLocal()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
Expand Down Expand Up @@ -169,6 +170,8 @@ dependencies {
// runtimeOnly fg.deobf("com.teamcofh:thermal_foundation:1.16.5-1.4.3.10")
// runtimeOnly fg.deobf("com.teamcofh:thermal_expansion:1.16.5-1.4.2.4")

runtimeOnly fg.deobf("dev.murad.liteloadlib:liteloadlib:mc${mc_version}-v${lll_version}")
compileOnly fg.deobf("dev.murad.liteloadlib:liteloadlib:mc${mc_version}-v${lll_version}")
// spark
runtimeOnly fg.deobf("curse.maven:spark-361579:3875647")

Expand Down Expand Up @@ -278,8 +281,14 @@ repositories {
url 'https://maven.tterrag.com'
}

maven {
name 'edtoaster maven'
url 'https://maven.edtoaster.ca'
}

maven {
name 'curseforge'
url 'https://cursemaven.com'
}
mavenLocal()
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ forge_version_range = [41,)

# Mod dependencies
jei_version = 9.5.0.132
lll_version = 1.0.1
patchouli_version = 1.18.2-66
patchouli_version_range = [1.18,)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package dev.murad.shipping.entity.accessor;

import dev.murad.shipping.util.EnrollmentHandler;
import net.minecraft.world.inventory.ContainerData;

import java.util.function.BooleanSupplier;
import java.util.function.IntSupplier;
import java.util.function.Supplier;

public class EnergyHeadVehicleDataAccessor extends HeadVehicleDataAccessor {
private static final int SHORT_MASK = 0xFFFF;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package dev.murad.shipping.entity.accessor;

import dev.murad.shipping.util.EnrollmentHandler;
import net.minecraft.world.inventory.ContainerData;

import java.util.function.BooleanSupplier;
import java.util.function.IntSupplier;
import java.util.function.Supplier;

public class SteamHeadVehicleDataAccessor extends HeadVehicleDataAccessor{
public SteamHeadVehicleDataAccessor(ContainerData data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package dev.murad.shipping.entity.container;

import dev.murad.shipping.ShippingMod;
import dev.murad.shipping.entity.accessor.DataAccessor;
import dev.murad.liteloadlib.api.LLLClientAPI;
import dev.murad.shipping.entity.accessor.HeadVehicleDataAccessor;
import dev.murad.shipping.entity.custom.HeadVehicle;
import dev.murad.shipping.global.PlayerTrainChunkManager;
import dev.murad.shipping.network.EnrollVehiclePacket;
import dev.murad.shipping.network.VehiclePacketHandler;
import dev.murad.shipping.network.SetEnginePacket;
import dev.murad.shipping.util.EnrollmentHandler;
import dev.murad.shipping.network.VehiclePacketHandler;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Inventory;
Expand Down Expand Up @@ -65,7 +61,7 @@ public void setEngine(boolean state){
}

public void enroll(){
VehiclePacketHandler.INSTANCE.sendToServer(new EnrollVehiclePacket(entity.getId()));
LLLClientAPI.sendEntityEnrollmentPacket(entity);
}

public String getOwner(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,13 @@
import com.mojang.blaze3d.vertex.PoseStack;
import dev.murad.shipping.ShippingMod;
import dev.murad.shipping.entity.custom.HeadVehicle;
import dev.murad.shipping.util.EnrollmentHandler;
import lombok.RequiredArgsConstructor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.font.TextFieldHelper;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Inventory;

import java.awt.font.FontRenderContext;

public abstract class AbstractHeadVehicleScreen<U extends Entity & HeadVehicle, T extends AbstractHeadVehicleContainer<?, U>> extends AbstractVehicleScreen<T>{
private static final ResourceLocation REGISTRATION = new ResourceLocation(ShippingMod.MOD_ID, "textures/container/vehicle_registration.png");
private Button on;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import dev.murad.shipping.entity.custom.HeadVehicle;
import dev.murad.shipping.setup.ModItems;
import dev.murad.shipping.setup.ModMenuTypes;
import dev.murad.shipping.util.EnrollmentHandler;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import dev.murad.shipping.entity.accessor.SteamHeadVehicleDataAccessor;
import dev.murad.shipping.entity.custom.HeadVehicle;
import dev.murad.shipping.setup.ModMenuTypes;
import dev.murad.shipping.util.EnrollmentHandler;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.level.Level;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package dev.murad.shipping.entity.custom;

import dev.murad.shipping.util.EnrollmentHandler;
import dev.murad.liteloadlib.api.EnrollableEntity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.items.ItemStackHandler;

import java.util.UUID;

public interface HeadVehicle {
public interface HeadVehicle extends EnrollableEntity {

void setEngineOn(boolean state);

Expand All @@ -19,7 +19,5 @@ public interface HeadVehicle {

ResourceLocation getRouteIcon();

void enroll(UUID uuid);

String owner();
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package dev.murad.shipping.entity.custom.train.locomotive;

import dev.murad.liteloadlib.api.EnrollmentHandler;
import dev.murad.shipping.ShippingConfig;
import dev.murad.shipping.block.rail.MultiShapeRail;
import dev.murad.shipping.block.rail.blockentity.LocomotiveDockTileEntity;
import dev.murad.shipping.capability.StallingCapability;
import dev.murad.shipping.entity.accessor.DataAccessor;
import dev.murad.shipping.entity.custom.HeadVehicle;
import dev.murad.shipping.entity.custom.train.AbstractTrainCarEntity;
import dev.murad.shipping.entity.custom.vessel.tug.AbstractTugEntity;
import dev.murad.shipping.entity.custom.vessel.tug.VehicleFrontPart;
import dev.murad.shipping.entity.navigation.LocomotiveNavigator;
import dev.murad.shipping.global.PlayerTrainChunkManager;
import dev.murad.shipping.item.LocoRouteItem;
import dev.murad.shipping.setup.ModBlocks;
import dev.murad.shipping.setup.ModItems;
Expand All @@ -33,8 +32,8 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.PoweredRailBlock;
Expand Down Expand Up @@ -103,8 +102,8 @@ public AbstractLocomotiveEntity(EntityType<?> type, Level level, Double x, Doubl
}

@Override
public void enroll(UUID uuid) {
enrollmentHandler.enroll(uuid);
public EnrollmentHandler getEnrollmentHandler() {
return enrollmentHandler;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import dev.murad.shipping.entity.container.EnergyHeadVehicleContainer;
import dev.murad.shipping.setup.ModEntityTypes;
import dev.murad.shipping.setup.ModItems;
import dev.murad.shipping.util.EnrollmentHandler;
import dev.murad.shipping.util.InventoryUtils;
import dev.murad.shipping.util.ItemHandlerVanillaContainerWrapper;
import net.minecraft.core.Direction;
Expand All @@ -19,7 +18,6 @@
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.capabilities.Capability;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package dev.murad.shipping.entity.custom.vessel.tug;

import dev.murad.liteloadlib.api.EnrollmentHandler;
import dev.murad.shipping.ShippingConfig;
import dev.murad.shipping.block.dock.TugDockTileEntity;
import dev.murad.shipping.block.guiderail.TugGuideRailBlock;
import dev.murad.shipping.capability.StallingCapability;
import dev.murad.shipping.entity.accessor.DataAccessor;
import dev.murad.shipping.entity.custom.HeadVehicle;
import dev.murad.shipping.global.PlayerTrainChunkManager;
import dev.murad.shipping.setup.ModItems;
import dev.murad.shipping.util.*;
import dev.murad.shipping.entity.custom.vessel.VesselEntity;
Expand All @@ -26,7 +26,6 @@
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.RandomSource;
import net.minecraft.world.*;
Expand Down Expand Up @@ -310,8 +309,8 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) {
}

@Override
public void enroll(UUID uuid) {
enrollmentHandler.enroll(uuid);
public EnrollmentHandler getEnrollmentHandler() {
return enrollmentHandler;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package dev.murad.shipping.event;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Matrix4f;
import com.mojang.math.Vector3f;
import dev.murad.liteloadlib.api.EntityPosition;
import dev.murad.liteloadlib.api.LLLClientAPI;
import dev.murad.shipping.ShippingConfig;
import dev.murad.shipping.ShippingMod;
import dev.murad.shipping.item.LocoRouteItem;
import dev.murad.shipping.item.TugRouteItem;
import dev.murad.shipping.network.client.EntityPosition;
import dev.murad.shipping.network.client.VehicleTrackerPacketHandler;
import dev.murad.shipping.setup.EntityItemMap;
import dev.murad.shipping.setup.ModEntityTypes;
import dev.murad.shipping.setup.ModItems;
import dev.murad.shipping.util.LocoRoute;
import dev.murad.shipping.util.LocoRouteNode;
Expand All @@ -30,9 +28,7 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.state.properties.RailShape;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
Expand All @@ -42,7 +38,6 @@
import net.minecraftforge.fml.common.Mod;

import java.util.List;
import java.util.Map;
import java.util.OptionalDouble;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -181,15 +176,15 @@ public static void onRenderWorldLast(RenderLevelStageEvent event) {
renderTypeBuffer.endBatch();
}

if (stack.getItem().equals(ModItems.CONDUCTORS_WRENCH.get()) && player.level.dimension().toString().equals(VehicleTrackerPacketHandler.toRenderDimension)){
if (stack.getItem().equals(ModItems.CONDUCTORS_WRENCH.get()) && player.level.dimension().toString().equals(LLLClientAPI.getTrackedEntitiesDimension())){
MultiBufferSource.BufferSource renderTypeBuffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
var camera = Minecraft.getInstance().getEntityRenderDispatcher().camera;
Vec3 cameraPosition = camera.getPosition();
double d0 = cameraPosition.x();
double d1 = cameraPosition.y();
double d2 = cameraPosition.z();

for(EntityPosition position : VehicleTrackerPacketHandler.toRender){
for(EntityPosition position : LLLClientAPI.getEntitiesToRender()){
Entity entity = player.level.getEntity(position.id());
double x;
double y;
Expand Down
42 changes: 0 additions & 42 deletions src/main/java/dev/murad/shipping/event/ForgeEventHandler.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
package dev.murad.shipping.event;

import dev.murad.shipping.ShippingConfig;
import dev.murad.shipping.ShippingMod;
import dev.murad.shipping.entity.custom.vessel.tug.VehicleFrontPart;
import dev.murad.shipping.global.PlayerTrainChunkManager;
import dev.murad.shipping.global.TrainChunkManagerManager;
import dev.murad.shipping.item.SpringItem;
import dev.murad.shipping.util.LinkableEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ShearsItem;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.UUID;

/**
* Forge-wide event bus
*/
Expand All @@ -37,40 +29,6 @@ public static void entitySpecificInteract(PlayerInteractEvent.EntityInteractSpec
handleEvent(event, event.getTarget());
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onWorldTick(TickEvent.LevelTickEvent event) {
if (event.phase == TickEvent.Phase.START) {
return;
}
// Don't do anything client side
if (event.level instanceof ServerLevel serverLevel) {
TrainChunkManagerManager.get(serverLevel.getServer()).getManagers(event.level.dimension()).forEach(PlayerTrainChunkManager::tick);

}
}

@SubscribeEvent
public static void onPlayerSignInEvent(PlayerEvent.PlayerLoggedInEvent event){
if (event.getEntity().level.isClientSide || ShippingConfig.Server.OFFLINE_LOADING.get()) {
return;
}

TrainChunkManagerManager.get(event.getEntity().level.getServer())
.getManagers(event.getEntity().getUUID())
.forEach(PlayerTrainChunkManager::activate);
}

@SubscribeEvent
public static void onPlayerSignInEvent(PlayerEvent.PlayerLoggedOutEvent event){
if (event.getEntity().level.isClientSide || ShippingConfig.Server.OFFLINE_LOADING.get()) {
return;
}

TrainChunkManagerManager.get(event.getEntity().level.getServer())
.getManagers(event.getEntity().getUUID())
.forEach(PlayerTrainChunkManager::deactivate);
}

private static void handleEvent(PlayerInteractEvent event, Entity target) {
if(!event.getItemStack().isEmpty()) {
Item item = event.getItemStack().getItem();
Expand Down
Loading