entry point

This commit is contained in:
zelophed 2021-04-06 00:05:29 +02:00
parent 19020b39bf
commit d4994ddc8b
8 changed files with 158 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.relays.encased.CasingConnectivit
import com.simibubi.create.content.schematics.ClientSchematicLoader;
import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler;
import com.simibubi.create.content.schematics.client.SchematicHandler;
import com.simibubi.create.events.ClientEvents;
import com.simibubi.create.foundation.ResourceReloadHandler;
import com.simibubi.create.foundation.block.render.CustomBlockModels;
import com.simibubi.create.foundation.block.render.SpriteShifter;
@ -78,6 +79,7 @@ public class CreateClient {
modEventBus.addListener(CreateClient::onModelRegistry);
modEventBus.addListener(CreateClient::onTextureStitch);
modEventBus.addListener(AllParticleTypes::registerFactories);
modEventBus.addListener(ClientEvents::loadCompleted);
Backend.init();
OptifineHandler.init();
@ -113,6 +115,8 @@ public class CreateClient {
.getResourceManager();
if (resourceManager instanceof IReloadableResourceManager)
((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler());
}
public static void onTextureStitch(TextureStitchEvent.Pre event) {

View file

@ -29,6 +29,7 @@ import com.simibubi.create.content.curiosities.zapper.terrainzapper.WorldshaperR
import com.simibubi.create.content.logistics.block.depot.EjectorTargetHandler;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmInteractionPointHandler;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.config.ui.ConfigScreen;
import com.simibubi.create.foundation.item.ItemDescription;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.networking.AllPackets;
@ -76,7 +77,11 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
@EventBusSubscriber(value = Dist.CLIENT)
public class ClientEvents {
@ -305,4 +310,9 @@ public class ClientEvents {
}
}
public static void loadCompleted(FMLLoadCompleteEvent event) {
ModContainer createContainer = ModList.get().getModContainerById("create").orElseThrow(() -> new IllegalStateException("Create Mod Container missing after loadCompleted"));
createContainer.registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (mc, previousScreen) -> new ConfigScreen(previousScreen));
}
}

View file

@ -29,6 +29,7 @@ public class AllCommands {
.then(FixLightingCommand.register())
.then(HighlightCommand.register())
.then(CouplingCommand.register())
.then(ConfigCommand.register())
.then(CloneCommand.register())
.then(PonderCommand.register())

View file

@ -0,0 +1,27 @@
package com.simibubi.create.foundation.command;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.fml.network.PacketDistributor;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.simibubi.create.foundation.networking.AllPackets;
public class ConfigCommand {
public static ArgumentBuilder<CommandSource, ?> register() {
return Commands.literal("config")
.executes(ctx -> {
ServerPlayerEntity player = ctx.getSource().asPlayer();
AllPackets.channel.send(
PacketDistributor.PLAYER.with(() -> player),
new ConfigureConfigPacket(ConfigureConfigPacket.Actions.configScreen.name(), "")
);
return Command.SINGLE_SUCCESS;
});
}
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.foundation.command;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.goggles.GoggleConfigScreen;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.config.ui.ConfigScreen;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.networking.SimplePacketBase;
import com.simibubi.create.foundation.ponder.PonderRegistry;
@ -68,6 +69,7 @@ public class ConfigureConfigPacket extends SimplePacketBase {
}
enum Actions {
configScreen(() -> Actions::configScreen),
rainbowDebug(() -> Actions::rainbowDebug),
overlayScreen(() -> Actions::overlayScreen),
fixLighting(() -> Actions::experimentalLighting),
@ -89,6 +91,11 @@ public class ConfigureConfigPacket extends SimplePacketBase {
.accept(value);
}
@OnlyIn(Dist.CLIENT)
private static void configScreen(String value) {
ScreenOpener.open(new ConfigScreen(null));
}
@OnlyIn(Dist.CLIENT)
private static void rainbowDebug(String value) {
ClientPlayerEntity player = Minecraft.getInstance().player;

View file

@ -107,8 +107,7 @@ public abstract class ConfigBase {
if (comment.length > 0) {
String[] comments = new String[comment.length + 1];
comments[0] = "";
for (int i = 0; i < comment.length; i++)
comments[i + 1] = comment[i];
System.arraycopy(comment, 0, comments, 1, comment.length);
builder.comment(comments);
} else
builder.comment("");

View file

@ -0,0 +1,90 @@
package com.simibubi.create.foundation.config.ui;
import net.minecraft.block.BlockState;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.Direction;
import javax.annotation.Nonnull;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.gui.UIRenderHelper;
import com.simibubi.create.foundation.ponder.NavigatableSimiScreen;
import com.simibubi.create.foundation.utility.animation.Force;
import com.simibubi.create.foundation.utility.animation.PhysicalFloat;
public class ConfigScreen extends NavigatableSimiScreen {
private final Screen parent;
protected static final PhysicalFloat cogSpin = PhysicalFloat.create().withDrag(0.3).addForce(new Force.Static(.2f));
protected static final BlockState cogwheelState = AllBlocks.LARGE_COGWHEEL.getDefaultState().with(CogWheelBlock.AXIS, Direction.Axis.Y);
public ConfigScreen(Screen parent) {
this.parent = parent;
}
@Override
public void tick() {
cogSpin.tick();
super.tick();
}
@Override
protected void init() {
super.init();
}
@Override
public void renderBackground(@Nonnull MatrixStack ms) {
fill(ms, 0, 0, this.width, this.height, 0xe8_101010);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, ms));
}
@Override
protected void renderWindowBackground(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
RenderSystem.disableDepthTest();
if (this.client != null && this.client.world != null){
fill(ms, 0, 0, this.width, this.height, 0xb0_282c34);
} else {
fill(ms, 0, 0, this.width, this.height, 0xff_282c34);
}
renderCog(ms, partialTicks);
super.renderWindowBackground(ms, mouseX, mouseY, partialTicks);
}
protected void renderCog(MatrixStack ms, float partialTicks) {
ms.push();
ms.translate(.5 * width - 100, .5 * height + 110, -200);
ms.scale(200, 200, .1f);
GuiGameElement.of(cogwheelState)
.rotateBlock(22.5, cogSpin.getValue(partialTicks), 22.5)
.render(ms);
ms.pop();
}
@Override
protected void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
int x = (int) (width * 0.5f);
int y = (int) (height * 0.5f);
this.drawHorizontalLine(ms, x-25, x+25, y, 0xff_807060);
this.drawVerticalLine(ms, x, y-25, y+25, 0xff_90a0b0);
//UIRenderHelper.streak(ms, 0, mouseX, mouseY, 16, 50, 0xaa_1e1e1e);
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
cogSpin.bump(3, -delta * 5);
return super.mouseScrolled(mouseX, mouseY, delta);
}
}

View file

@ -81,4 +81,22 @@ public interface Force {
return timeRemaining <= 0;
}
}
class Static implements Force {
float force;
public Static(float force) {
this.force = force;
}
@Override
public float get(float mass, float value, float speed) {
return force;
}
@Override
public boolean finished() {
return false;
}
}
}