mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 18:33:41 +01:00
Merge branch '0.2' of https://github.com/simibubi/Create into 0.2
This commit is contained in:
commit
c195acf62b
6 changed files with 128 additions and 3 deletions
|
@ -1,5 +1,9 @@
|
||||||
package com.simibubi.create;
|
package com.simibubi.create;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.command.CreateCommand;
|
||||||
|
import com.simibubi.create.foundation.command.ServerLagger;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
@ -44,6 +48,7 @@ public class Create {
|
||||||
public static LogisticalNetworkHandler logisticalNetworkHandler;
|
public static LogisticalNetworkHandler logisticalNetworkHandler;
|
||||||
public static TorquePropagator torquePropagator;
|
public static TorquePropagator torquePropagator;
|
||||||
public static LogisticianHandler logisticianHandler;
|
public static LogisticianHandler logisticianHandler;
|
||||||
|
public static ServerLagger lagger;
|
||||||
|
|
||||||
public static ModConfig config;
|
public static ModConfig config;
|
||||||
|
|
||||||
|
@ -51,6 +56,8 @@ public class Create {
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
modEventBus.addListener(Create::init);
|
modEventBus.addListener(Create::init);
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.addListener(Create::serverStarting);
|
||||||
|
|
||||||
modEventBus.addGenericListener(Block.class, AllBlocks::register);
|
modEventBus.addGenericListener(Block.class, AllBlocks::register);
|
||||||
modEventBus.addGenericListener(Item.class, AllItems::register);
|
modEventBus.addGenericListener(Item.class, AllItems::register);
|
||||||
modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipes::register);
|
modEventBus.addGenericListener(IRecipeSerializer.class, AllRecipes::register);
|
||||||
|
@ -74,11 +81,16 @@ public class Create {
|
||||||
frequencyHandler = new FrequencyHandler();
|
frequencyHandler = new FrequencyHandler();
|
||||||
logisticalNetworkHandler = new LogisticalNetworkHandler();
|
logisticalNetworkHandler = new LogisticalNetworkHandler();
|
||||||
torquePropagator = new TorquePropagator();
|
torquePropagator = new TorquePropagator();
|
||||||
|
lagger = new ServerLagger();
|
||||||
|
|
||||||
CraftingHelper.register(new ModuleLoadedCondition.Serializer());
|
CraftingHelper.register(new ModuleLoadedCondition.Serializer());
|
||||||
AllPackets.registerPackets();
|
AllPackets.registerPackets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void serverStarting(FMLServerStartingEvent event){
|
||||||
|
new CreateCommand(event.getCommandDispatcher());
|
||||||
|
}
|
||||||
|
|
||||||
public static void registerVillagerProfessions(RegistryEvent.Register<VillagerProfession> event) {
|
public static void registerVillagerProfessions(RegistryEvent.Register<VillagerProfession> event) {
|
||||||
LogisticianHandler.registerVillagerProfessions(event);
|
LogisticianHandler.registerVillagerProfessions(event);
|
||||||
}
|
}
|
||||||
|
@ -96,6 +108,8 @@ public class Create {
|
||||||
if (schematicReceiver == null)
|
if (schematicReceiver == null)
|
||||||
schematicReceiver = new ServerSchematicLoader();
|
schematicReceiver = new ServerSchematicLoader();
|
||||||
schematicReceiver.tick();
|
schematicReceiver.tick();
|
||||||
|
|
||||||
|
lagger.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class Events {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onTick(ServerTickEvent event) {
|
public static void onTick(ServerTickEvent event) {
|
||||||
if (event.phase == Phase.START)
|
if (event.phase == Phase.END)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Create.tick();
|
Create.tick();
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.simibubi.create.foundation.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
|
||||||
|
public class CreateCommand {
|
||||||
|
|
||||||
|
public CreateCommand(CommandDispatcher<CommandSource> dispatcher){
|
||||||
|
|
||||||
|
KillTPSCommand.register(dispatcher);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.simibubi.create.foundation.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
|
import com.simibubi.create.Create;
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraft.command.Commands;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
|
||||||
|
public class KillTPSCommand {
|
||||||
|
|
||||||
|
public static void register(CommandDispatcher<CommandSource> dispatcher) {
|
||||||
|
dispatcher.register(
|
||||||
|
Commands.literal("killtps")//todo replace String Components with Translation Components
|
||||||
|
.requires(cs -> cs.hasPermissionLevel(2))
|
||||||
|
.executes(ctx -> {
|
||||||
|
//killtps no arguments
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent(String.format("[Create]: Server tick is currently slowed by %s ms",Create.lagger.isLagging() ? Create.lagger.getTickTime() : 0)), true);
|
||||||
|
if (Create.lagger.isLagging())
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent("[Create]: use /killtps stop to bring back server tick to regular speed"), true);
|
||||||
|
else
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent("[Create]: use /killtps start <tickTime> to artificially slow down the server tick"),true);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(Commands.literal("start")
|
||||||
|
.executes(ctx -> {
|
||||||
|
//killtps start no time
|
||||||
|
int tickTime = Create.lagger.getTickTime();
|
||||||
|
if (tickTime > 0){
|
||||||
|
Create.lagger.setLagging(true);
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent(String.format("[Create]: Server tick is slowed by %s ms now :)", tickTime)),true);
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent("[Create]: use /killtps stop to bring back server tick to regular speed"),true);
|
||||||
|
} else {
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent("[Create]: use /killtps start <tickTime> to artificially slow down the server tick"),true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(Commands.argument("tickTime", IntegerArgumentType.integer(1))
|
||||||
|
.executes(ctx -> {
|
||||||
|
//killtps start tickTime
|
||||||
|
int tickTime = IntegerArgumentType.getInteger(ctx, "tickTime");
|
||||||
|
Create.lagger.setTickTime(tickTime);
|
||||||
|
Create.lagger.setLagging(true);
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent(String.format("[Create]: Server tick is slowed by %s ms now :)", tickTime)),true);
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent("[Create]: use /killtps stop to bring server tick to regular speed again"),true);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(Commands.literal("stop")
|
||||||
|
.executes(ctx -> {
|
||||||
|
//killtps stop
|
||||||
|
Create.lagger.setLagging(false);
|
||||||
|
ctx.getSource().sendFeedback(new StringTextComponent("[Create]: Server tick is back to regular speed"), false);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.simibubi.create.foundation.command;
|
||||||
|
|
||||||
|
public class ServerLagger {
|
||||||
|
|
||||||
|
private int tickTime;
|
||||||
|
private boolean isLagging = false;
|
||||||
|
|
||||||
|
public void tick(){
|
||||||
|
if (!isLagging || tickTime <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(tickTime);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTickTime(int tickTime){
|
||||||
|
this.tickTime = Math.max(tickTime, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLagging(boolean lagging){
|
||||||
|
this.isLagging = lagging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTickTime() {
|
||||||
|
return tickTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLagging() {
|
||||||
|
return isLagging;
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,7 +28,7 @@ public class AllShapes {
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static final VoxelShape
|
private static final VoxelShape
|
||||||
LOGISTICAL_CASING_MIDDLE_SHAPE = VoxelShapes.or(
|
LOGISTICAL_CASING_MIDDLE_SHAPE = VoxelShapes.or(
|
||||||
makeCuboidShape(1,0,1,15,16,15),
|
makeCuboidShape(1,0,1,15,16,15),
|
||||||
|
@ -42,7 +42,7 @@ public class AllShapes {
|
||||||
CART_ASSEMBLER_SHAPE = VoxelShapes.or(
|
CART_ASSEMBLER_SHAPE = VoxelShapes.or(
|
||||||
VoxelShapes.fullCube(),
|
VoxelShapes.fullCube(),
|
||||||
makeCuboidShape(-2, 0, 1, 18, 13, 15)),
|
makeCuboidShape(-2, 0, 1, 18, 13, 15)),
|
||||||
MECHANICAL_PISTON_HEAD_SHAPE_UP = Blocks.PISTON_HEAD.getShape(Blocks.PISTON_HEAD.getStateContainer().getBaseState().with(DirectionalBlock.FACING, Direction.UP).with(PistonHeadBlock.SHORT, true), null, null, null),
|
MECHANICAL_PISTON_HEAD_SHAPE_UP = Blocks.PISTON_HEAD.getStateContainer().getBaseState().with(DirectionalBlock.FACING, Direction.UP).with(PistonHeadBlock.SHORT, true).getShape(null, null),
|
||||||
MECHANICAL_PISTON_EXTENDED_SHAPE_UP = VoxelShapes.or(
|
MECHANICAL_PISTON_EXTENDED_SHAPE_UP = VoxelShapes.or(
|
||||||
SHORT_CASING_12_VOXEL.get(Direction.UP),
|
SHORT_CASING_12_VOXEL.get(Direction.UP),
|
||||||
FOUR_VOXEL_POLE.get(Direction.Axis.Y)),
|
FOUR_VOXEL_POLE.get(Direction.Axis.Y)),
|
||||||
|
|
Loading…
Reference in a new issue