Fix coupling data not being sent to clients
This commit is contained in:
parent
a49aad24c2
commit
cbe23a6aba
2 changed files with 17 additions and 0 deletions
|
@ -36,6 +36,7 @@ import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
|||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.common.util.NonNullConsumer;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
|
||||
public class CapabilityMinecartController implements ICapabilitySerializable<CompoundNBT> {
|
||||
|
@ -200,6 +201,7 @@ public class CapabilityMinecartController implements ICapabilitySerializable<Com
|
|||
Entity entity = event.getObject();
|
||||
if (!(entity instanceof AbstractMinecartEntity))
|
||||
return;
|
||||
|
||||
CapabilityMinecartController capability = new CapabilityMinecartController((AbstractMinecartEntity) entity);
|
||||
ResourceLocation id = Create.asResource("minecart_controller");
|
||||
event.addCapability(id, capability);
|
||||
|
@ -211,6 +213,14 @@ public class CapabilityMinecartController implements ICapabilitySerializable<Com
|
|||
.add((AbstractMinecartEntity) entity);
|
||||
}
|
||||
|
||||
public static void startTracking(PlayerEvent.StartTracking event) {
|
||||
Entity entity = event.getTarget();
|
||||
if (!(entity instanceof AbstractMinecartEntity))
|
||||
return;
|
||||
entity.getCapability(MINECART_CONTROLLER_CAPABILITY)
|
||||
.ifPresent(MinecartController::sendData);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
CapabilityManager.INSTANCE.register(MinecartController.class, new Capability.IStorage<MinecartController>() {
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipe
|
|||
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.Debug;
|
||||
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
|
||||
import com.simibubi.create.foundation.utility.WorldAttached;
|
||||
import com.simibubi.create.foundation.utility.recipe.RecipeFinder;
|
||||
|
@ -25,6 +26,7 @@ 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.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -121,5 +123,10 @@ public class CommonEvents {
|
|||
public static void attachCapabilities(AttachCapabilitiesEvent<Entity> event) {
|
||||
CapabilityMinecartController.attach(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void startTracking(PlayerEvent.StartTracking event) {
|
||||
CapabilityMinecartController.startTracking(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue