mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-16 07:24:32 +01:00
3956875334
- Fixed concurrency / race condition issues with contraptions loading in during a collision cycle - Reworked implementation model of minecart tracking and couplings - Coupling items now get consumed when used in survival mode - Added some player feedback when couplings cannot be created - Fixed couplings disappearing on the client due to sync issues - Wrenches can now remove minecarts in one hit - Wrenches can now be used to remove couplings from minecarts - Cart assemblers now attach themselves to the block above, no longer requiring active "sticky-ness" of the contraption towards it - Minecarts can no longer be moved while a contraption is stalling them
121 lines
4.2 KiB
Java
121 lines
4.2 KiB
Java
package com.simibubi.create.events;
|
|
|
|
import com.simibubi.create.Create;
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingPhysics;
|
|
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
|
|
import com.simibubi.create.content.contraptions.wrench.WrenchItem;
|
|
import com.simibubi.create.content.schematics.ServerSchematicLoader;
|
|
import com.simibubi.create.foundation.command.AllCommands;
|
|
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
|
import com.simibubi.create.foundation.utility.WorldAttached;
|
|
import com.simibubi.create.foundation.utility.recipe.RecipeFinder;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.LivingEntity;
|
|
import net.minecraft.world.IWorld;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
|
import net.minecraftforge.event.TickEvent.Phase;
|
|
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
|
import net.minecraftforge.event.TickEvent.WorldTickEvent;
|
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
|
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
|
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
|
import net.minecraftforge.event.world.ChunkEvent;
|
|
import net.minecraftforge.event.world.WorldEvent;
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
|
|
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
|
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
|
|
|
@EventBusSubscriber
|
|
public class CommonEvents {
|
|
|
|
@SubscribeEvent
|
|
public static void onServerTick(ServerTickEvent event) {
|
|
if (event.phase == Phase.START)
|
|
return;
|
|
if (Create.schematicReceiver == null)
|
|
Create.schematicReceiver = new ServerSchematicLoader();
|
|
Create.schematicReceiver.tick();
|
|
Create.lagger.tick();
|
|
ServerSpeedProvider.serverTick();
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onChunkUnloaded(ChunkEvent.Unload event) {
|
|
CapabilityMinecartController.onChunkUnloaded(event);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onWorldTick(WorldTickEvent event) {
|
|
if (event.phase == Phase.START)
|
|
return;
|
|
World world = event.world;
|
|
ContraptionHandler.tick(world);
|
|
CapabilityMinecartController.tick(world);
|
|
CouplingPhysics.tick(world);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onUpdateLivingEntity(LivingUpdateEvent event) {
|
|
LivingEntity entityLiving = event.getEntityLiving();
|
|
World world = entityLiving.world;
|
|
if (world == null)
|
|
return;
|
|
ContraptionHandler.entitiesWhoJustDismountedGetSentToTheRightLocation(entityLiving, world);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onEntityAdded(EntityJoinWorldEvent event) {
|
|
Entity entity = event.getEntity();
|
|
World world = event.getWorld();
|
|
ContraptionHandler.addSpawnedContraptionsToCollisionList(entity, world);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onEntityAttackedByPlayer(AttackEntityEvent event) {
|
|
WrenchItem.wrenchInstaKillsMinecarts(event);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void serverStarted(FMLServerStartingEvent event) {
|
|
AllCommands.register(event.getCommandDispatcher());
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void serverAboutToStart(FMLServerAboutToStartEvent event) {
|
|
event.getServer()
|
|
.getResourceManager()
|
|
.addReloadListener(RecipeFinder.LISTENER);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void serverStopped(FMLServerStoppingEvent event) {
|
|
Create.schematicReceiver.shutdown();
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onLoadWorld(WorldEvent.Load event) {
|
|
IWorld world = event.getWorld();
|
|
Create.redstoneLinkNetworkHandler.onLoadWorld(world);
|
|
Create.torquePropagator.onLoadWorld(world);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onUnloadWorld(WorldEvent.Unload event) {
|
|
IWorld world = event.getWorld();
|
|
Create.redstoneLinkNetworkHandler.onUnloadWorld(world);
|
|
Create.torquePropagator.onUnloadWorld(world);
|
|
WorldAttached.invalidateWorld(world);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void attachCapabilities(AttachCapabilitiesEvent<Entity> event) {
|
|
CapabilityMinecartController.attach(event);
|
|
}
|
|
|
|
}
|