Skip to content

Commit 86c8744

Browse files
additional asteroid work
Signed-off-by: Real Ant Engineer <[email protected]>
1 parent 960faf0 commit 86c8744

File tree

22 files changed

+307
-48
lines changed

22 files changed

+307
-48
lines changed

src/main/java/com/rae/creatingspace/content/event/CSClientEvent.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import com.rae.creatingspace.content.rocket.engine.EngineItem;
1212
import com.rae.creatingspace.content.rocket.rocket_control.RocketControlsHandler;
1313
import com.rae.creatingspace.init.EngineMaterialInit;
14+
import com.simibubi.create.content.contraptions.actors.trainControls.ControlsHandler;
15+
import com.simibubi.create.content.kinetics.fan.AirCurrent;
16+
import com.simibubi.create.content.redstone.link.controller.LinkedControllerClientHandler;
1417
import com.simibubi.create.content.trains.CameraDistanceModifier;
1518
import net.minecraft.client.Minecraft;
1619
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
@@ -44,6 +47,10 @@ protected static boolean isGameActive() {
4447
public static void onTick(TickEvent.ClientTickEvent event){
4548
if (!isGameActive())
4649
return;
50+
if (event.phase == TickEvent.Phase.START) {
51+
RocketControlsHandler.tick();
52+
return;
53+
}
4754
CopperOxygenBacktankFirstPersonRenderer.clientTick();
4855
NetheriteOxygenBacktankFirstPersonRenderer.clientTick();
4956
}

src/main/java/com/rae/creatingspace/content/rocket/RocketHUD.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,19 @@
33
import com.mojang.blaze3d.vertex.PoseStack;
44
import com.rae.creatingspace.content.rocket.contraption.entity.RocketContraptionEntity;
55
import com.rae.creatingspace.content.rocket.rocket_control.RocketControlsHandler;
6-
import com.simibubi.create.AllPackets;
7-
import com.simibubi.create.content.contraptions.actors.trainControls.ControlsBlock;
8-
import com.simibubi.create.content.contraptions.actors.trainControls.ControlsHandler;
9-
import com.simibubi.create.content.trains.HonkPacket;
10-
import com.simibubi.create.content.trains.TrainHUD;
11-
import com.simibubi.create.content.trains.TrainHUDUpdatePacket;
12-
import com.simibubi.create.content.trains.entity.Carriage;
13-
import com.simibubi.create.content.trains.entity.CarriageContraptionEntity;
14-
import com.simibubi.create.content.trains.entity.Train;
15-
import com.simibubi.create.foundation.gui.AllGuiTextures;
16-
import com.simibubi.create.foundation.utility.ControlsUtil;
17-
import com.simibubi.create.infrastructure.config.AllConfigs;
186
import net.createmod.catnip.animation.LerpedFloat;
19-
import net.createmod.catnip.math.AngleHelper;
20-
import net.createmod.catnip.placement.PlacementClient;
217
import net.minecraft.client.Minecraft;
22-
import net.minecraft.client.gui.Font;
238
import net.minecraft.client.gui.GuiGraphics;
249
import net.minecraft.core.BlockPos;
25-
import net.minecraft.core.Direction;
2610
import net.minecraft.network.chat.Component;
27-
import net.minecraft.util.Mth;
2811
import net.minecraft.world.entity.Entity;
2912
import net.minecraft.world.level.GameType;
30-
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
31-
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
3213
import net.minecraftforge.client.gui.overlay.ForgeGui;
3314
import net.minecraftforge.client.gui.overlay.IGuiOverlay;
3415

3516
public class RocketHUD {
3617

37-
public static final IGuiOverlay OVERLAY = TrainHUD::renderOverlay;
18+
public static final IGuiOverlay OVERLAY = RocketHUD::renderOverlay;
3819

3920
static LerpedFloat displayedSpeed = LerpedFloat.linear();//speed will be for the
4021
static LerpedFloat displayedThrottle = LerpedFloat.linear();
@@ -78,14 +59,10 @@ public static void renderOverlay(ForgeGui gui, GuiGraphics graphics, float parti
7859
PoseStack poseStack = graphics.pose();
7960
poseStack.pushPose();
8061

62+
graphics.renderTooltip(gui.getFont(), Component.literal("test"), width / 2, height / 2);
8163
// todo put the custom rocket HUD logic here.
8264

8365

8466
poseStack.popPose();
8567
}
86-
87-
public static boolean onScroll(double delta) {
88-
return true;
89-
}
90-
9168
}

src/main/java/com/rae/creatingspace/content/rocket/contraption/behaviour/interaction/RocketControlInteraction.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,61 @@
11
package com.rae.creatingspace.content.rocket.contraption.behaviour.interaction;
22

3+
import com.google.common.base.Objects;
34
import com.rae.creatingspace.content.rocket.RocketMenu;
45
import com.rae.creatingspace.content.rocket.contraption.entity.RocketContraptionEntity;
6+
import com.rae.creatingspace.content.rocket.rocket_control.RocketControlsHandler;
7+
import com.simibubi.create.AllItems;
58
import com.simibubi.create.api.behaviour.interaction.MovingInteractionBehaviour;
69
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
10+
import com.simibubi.create.content.contraptions.actors.trainControls.ControlsHandler;
711
import net.minecraft.core.BlockPos;
812
import net.minecraft.network.chat.Component;
913
import net.minecraft.server.level.ServerPlayer;
1014
import net.minecraft.world.InteractionHand;
1115
import net.minecraft.world.SimpleMenuProvider;
1216
import net.minecraft.world.entity.Entity;
1317
import net.minecraft.world.entity.player.Player;
18+
import net.minecraftforge.api.distmarker.Dist;
19+
import net.minecraftforge.fml.DistExecutor;
1420
import net.minecraftforge.network.NetworkHooks;
1521

22+
import java.util.UUID;
23+
1624
public class RocketControlInteraction extends MovingInteractionBehaviour {
1725

1826
@Override
1927
public boolean handlePlayerInteraction(Player player, InteractionHand activeHand, BlockPos localPos,
2028
AbstractContraptionEntity contraptionEntity) {
2129
if (contraptionEntity instanceof RocketContraptionEntity rocketContraption) {
30+
/*
2231
if ((player instanceof ServerPlayer serverPlayer)) {
2332
2433
NetworkHooks.openScreen(serverPlayer, new SimpleMenuProvider((id, inv, p) -> RocketMenu.create(id, inv, rocketContraption), Component.translatable("container.my_item_menu")), buf ->
2534
buf.writeVarInt(rocketContraption.getId()));
2635
return true;
2736
}
2837
return true;
38+
*/
39+
if (AllItems.WRENCH.isIn(player.getItemInHand(activeHand)))
40+
return false;
41+
42+
UUID currentlyControlling = contraptionEntity.getControllingPlayer()
43+
.orElse(null);
44+
45+
if (currentlyControlling != null) {
46+
contraptionEntity.stopControlling(localPos);
47+
if (Objects.equal(currentlyControlling, player.getUUID()))
48+
return true;
49+
}
50+
51+
if (!contraptionEntity.startControlling(localPos, player))
52+
return false;
53+
54+
contraptionEntity.setControllingPlayer(player.getUUID());
55+
if (player.level().isClientSide)
56+
DistExecutor.unsafeRunWhenOn(Dist.CLIENT,
57+
() -> () -> RocketControlsHandler.startControlling(contraptionEntity, localPos));
58+
return true;
2959
}
3060
return false;
3161
}

src/main/java/com/rae/creatingspace/content/rocket/contraption/entity/RocketContraptionEntity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.rae.creatingspace.CreatingSpace;
55
import com.rae.creatingspace.api.contraption.Synced2AxisContraptionEntity;
66
import com.rae.creatingspace.configs.CSConfigs;
7+
import com.rae.creatingspace.content.rocket.RocketMenu;
78
import com.rae.creatingspace.content.rocket.RocketTeleporter;
89
import com.rae.creatingspace.content.rocket.squedule.RocketPath;
910
import com.rae.creatingspace.content.rocket.squedule.RocketScheduleRuntime;
@@ -19,6 +20,7 @@
1920
import net.minecraft.core.registries.Registries;
2021
import net.minecraft.nbt.CompoundTag;
2122
import net.minecraft.nbt.NbtOps;
23+
import net.minecraft.network.chat.Component;
2224
import net.minecraft.network.syncher.EntityDataAccessor;
2325
import net.minecraft.network.syncher.EntityDataSerializers;
2426
import net.minecraft.network.syncher.SynchedEntityData;
@@ -28,6 +30,7 @@
2830
import net.minecraft.sounds.SoundSource;
2931
import net.minecraft.tags.TagKey;
3032
import net.minecraft.util.Mth;
33+
import net.minecraft.world.SimpleMenuProvider;
3134
import net.minecraft.world.damagesource.DamageSource;
3235
import net.minecraft.world.entity.Entity;
3336
import net.minecraft.world.entity.EntityType;
@@ -44,6 +47,7 @@
4447
import net.minecraftforge.fluids.FluidStack;
4548
import net.minecraftforge.fluids.FluidType;
4649
import net.minecraftforge.fluids.capability.IFluidHandler;
50+
import net.minecraftforge.network.NetworkHooks;
4751
import org.jetbrains.annotations.NotNull;
4852
import org.jetbrains.annotations.Nullable;
4953
import org.slf4j.Logger;
@@ -413,6 +417,14 @@ public boolean control(BlockPos controlsLocalPos, Collection<Integer> heldContro
413417
float speedModificator = 0.2f;
414418
Vec3 speed = Vec3.ZERO;
415419
Vec2 rotSpeed = Vec2.ZERO;
420+
if (heldControls.contains(12)){
421+
if ((player instanceof ServerPlayer serverPlayer)) {
422+
423+
NetworkHooks.openScreen(serverPlayer, new SimpleMenuProvider((id, inv, p) ->
424+
RocketMenu.create(id, inv, this), Component.translatable("container.my_item_menu")), buf ->
425+
buf.writeVarInt(this.getId()));
426+
}
427+
}
416428
if (heldControls.contains(11)){
417429
speedModificator = 2f;
418430
}

src/main/java/com/rae/creatingspace/content/rocket/rocket_control/RocketControlsUtil.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,26 @@
1212
public class RocketControlsUtil {
1313

1414
private static Vector<KeyMapping> standardControls;
15-
15+
//todo it should be a map not a list, it's beginning to be hard to manage (magic numbers)
1616
public static Vector<KeyMapping> getControls() {
1717
if (standardControls == null) {
1818
Options gameSettings = Minecraft.getInstance().options;
1919
standardControls = new Vector<>(6);
20-
standardControls.add(gameSettings.keyUp);
21-
standardControls.add(gameSettings.keyDown);
22-
standardControls.add(gameSettings.keyLeft);
23-
standardControls.add(gameSettings.keyRight);
24-
standardControls.add(gameSettings.keyJump);
25-
standardControls.add(gameSettings.keyShift);
20+
standardControls.add(gameSettings.keyUp);//0
21+
standardControls.add(gameSettings.keyDown);//1
22+
standardControls.add(gameSettings.keyLeft);//2
23+
standardControls.add(gameSettings.keyRight);//3
24+
standardControls.add(gameSettings.keyJump);//4
25+
standardControls.add(gameSettings.keyShift);//5
2626
standardControls.add(KeysInit.PITCH_UP.getKeybind());//6
2727
standardControls.add(KeysInit.PITCH_DOWN.getKeybind());//7
2828
standardControls.add(KeysInit.YAW_LEFT.getKeybind());//8
2929
standardControls.add(KeysInit.YAW_RIGHT.getKeybind());//9
3030
standardControls.add(KeysInit.SWITCH_MODE.getKeybind());//10
3131
standardControls.add(gameSettings.keySprint);//11
32+
standardControls.add(KeysInit.ROCKET_INVENTORY.getKeybind());//12
33+
standardControls.add(KeysInit.ROCKET_SCHEDULE.getKeybind());//13
34+
3235
}
3336
return standardControls;
3437
}
Lines changed: 121 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,134 @@
11
package com.rae.creatingspace.content.rocket.squedule;
22

33

4+
import com.mojang.blaze3d.vertex.PoseStack;
5+
import com.rae.creatingspace.content.rocket.squedule.condition.ScheduleWaitCondition;
6+
import com.simibubi.create.foundation.gui.AllGuiTextures;
7+
import net.createmod.catnip.data.Pair;
8+
import net.createmod.catnip.gui.UIRenderHelper;
9+
import net.createmod.catnip.gui.element.GuiGameElement;
410
import net.createmod.catnip.gui.widget.AbstractSimiWidget;
11+
import net.minecraft.client.gui.GuiGraphics;
12+
import net.minecraft.network.chat.Component;
13+
import net.minecraft.world.item.ItemStack;
14+
import net.minecraft.world.item.Items;
15+
16+
import java.util.List;
517

618
public class ScheduleEntryWidget extends AbstractSimiWidget {
719

20+
private final int entryIndex;
21+
//need a reference to the entry
22+
private final ScheduleEntry entry;
23+
private static final int CARD_HEADER = 22;
24+
private static final int CARD_WIDTH = 195;
25+
826
//for later
9-
protected ScheduleEntryWidget(int x, int y) {
27+
protected ScheduleEntryWidget(int x, int y, ScheduleEntry entry, int entryIndex) {
1028
super(x, y);
29+
this.entry = entry;
30+
this.entryIndex = entryIndex;
1131
}
1232

13-
private static final int CARD_HEADER = 22;
14-
private static final int CARD_WIDTH = 195;
33+
1534
//to do latter
35+
36+
/*
37+
public int renderScheduleEntry(GuiGraphics graphics, int yOffset) {
38+
int zLevel = -100;
39+
40+
AllGuiTextures light = AllGuiTextures.SCHEDULE_CARD_LIGHT;
41+
AllGuiTextures medium = AllGuiTextures.SCHEDULE_CARD_MEDIUM;
42+
AllGuiTextures dark = AllGuiTextures.SCHEDULE_CARD_DARK;
43+
44+
int cardWidth = CARD_WIDTH;
45+
int cardHeader = CARD_HEADER;
46+
int maxRows = 0;
47+
for (List<ScheduleWaitCondition> list : entry.conditions)
48+
maxRows = Math.max(maxRows, list.size());
49+
boolean supportsConditions = entry.instruction.supportsConditions();
50+
int cardHeight = cardHeader + (supportsConditions ? 24 + maxRows * 18 : 4);
51+
52+
PoseStack matrixStack = graphics.pose();
53+
54+
55+
matrixStack.pushPose();
56+
matrixStack.translate(getX() + 25, getY() + yOffset, 0);
57+
58+
UIRenderHelper.drawStretched(graphics, 0, 1, cardWidth, cardHeight - 2, zLevel, light);
59+
UIRenderHelper.drawStretched(graphics, 1, 0, cardWidth - 2, cardHeight, zLevel, light);
60+
UIRenderHelper.drawStretched(graphics, 1, 1, cardWidth - 2, cardHeight - 2, zLevel, dark);
61+
UIRenderHelper.drawStretched(graphics, 2, 2, cardWidth - 4, cardHeight - 4, zLevel, medium);
62+
UIRenderHelper.drawStretched(graphics, 2, 2, cardWidth - 4, cardHeader, zLevel,
63+
supportsConditions ? light : medium);
64+
65+
AllGuiTextures.SCHEDULE_CARD_REMOVE.render(graphics, cardWidth - 14, 2);
66+
AllGuiTextures.SCHEDULE_CARD_DUPLICATE.render(graphics, cardWidth - 14, cardHeight - 14);
67+
68+
int i = entryIndex;
69+
if (i > 0)
70+
AllGuiTextures.SCHEDULE_CARD_MOVE_UP.render(graphics, cardWidth, cardHeader - 14);
71+
if (i < schedule.entries.size() - 1)
72+
AllGuiTextures.SCHEDULE_CARD_MOVE_DOWN.render(graphics, cardWidth, cardHeader);
73+
74+
UIRenderHelper.drawStretched(graphics, 8, 0, 3, cardHeight + 10, zLevel,
75+
AllGuiTextures.SCHEDULE_STRIP_LIGHT);
76+
(supportsConditions ? AllGuiTextures.SCHEDULE_STRIP_TRAVEL : AllGuiTextures.SCHEDULE_STRIP_ACTION)
77+
.render(graphics, 4, 6);
78+
79+
if (supportsConditions)
80+
AllGuiTextures.SCHEDULE_STRIP_WAIT.render(graphics, 4, 28);
81+
82+
Pair<ItemStack, Component> destination = entry.instruction.getSummary();
83+
renderInput(graphics, destination, 26, 5, false, 100);
84+
entry.instruction.renderSpecialIcon(graphics, 30, 5);
85+
86+
matrixStack.popPose();
87+
88+
return cardHeight;
89+
}
90+
private int getFieldSize(int minSize, Pair<ItemStack, Component> pair) {
91+
ItemStack stack = pair.getFirst();
92+
Component text = pair.getSecond();
93+
boolean hasItem = !stack.isEmpty();
94+
return Math.max((text == null ? 0 : font.width(text)) + (hasItem ? 20 : 0) + TOP_BORDER_WIDTH, minSize);
95+
}
96+
97+
protected int renderInput(GuiGraphics graphics, Pair<ItemStack, Component> pair, int x, int y, boolean clean,
98+
int minSize) {
99+
ItemStack stack = pair.getFirst();
100+
Component text = pair.getSecond();
101+
boolean hasItem = !stack.isEmpty();
102+
int fieldSize = Math.min(getFieldSize(minSize, pair), 150);
103+
PoseStack matrixStack = graphics.pose();
104+
105+
matrixStack.pushPose();
106+
107+
AllGuiTextures left =
108+
clean ? AllGuiTextures.SCHEDULE_CONDITION_LEFT_CLEAN : AllGuiTextures.SCHEDULE_CONDITION_LEFT;
109+
AllGuiTextures middle = AllGuiTextures.SCHEDULE_CONDITION_MIDDLE;
110+
AllGuiTextures item = AllGuiTextures.SCHEDULE_CONDITION_ITEM;
111+
AllGuiTextures right = AllGuiTextures.SCHEDULE_CONDITION_RIGHT;
112+
113+
matrixStack.translate(x, y, 0);
114+
UIRenderHelper.drawStretched(graphics, 0, 0, fieldSize, TOP_BORDER_WIDTH, -100, middle);
115+
left.render(graphics, clean ? 0 : -3, 0);
116+
right.render(graphics, fieldSize - 2, 0);
117+
if (hasItem)
118+
item.render(graphics, 3, 0);
119+
if (hasItem) {
120+
item.render(graphics, 3, 0);
121+
if (stack.getItem() != Items.STRUCTURE_VOID)
122+
GuiGameElement.of(stack)
123+
.at(4, 0)
124+
.render(graphics);
125+
}
126+
127+
if (text != null)
128+
graphics.drawString(font, font.substrByWidth(text, 120)
129+
.getString(), hasItem ? 28 : 8, 4, 0xff_f2f2ee);
130+
131+
matrixStack.popPose();
132+
return fieldSize;
133+
}*/
16134
}

src/main/java/com/rae/creatingspace/init/KeysInit.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public enum KeysInit {
2424
PITCH_UP("pitch_up", GLFW.GLFW_KEY_K, "pitch up"),
2525
YAW_LEFT("yaw_left", GLFW.GLFW_KEY_J, "rotate left"),
2626
YAW_RIGHT("yaw_right", GLFW.GLFW_KEY_L, "rotate right"),
27-
SWITCH_MODE("switch_mode", GLFW.GLFW_KEY_M, "switch flight mode")
27+
SWITCH_MODE("switch_mode", GLFW.GLFW_KEY_M, "switch flight mode"),
28+
ROCKET_INVENTORY("rocket_inventory", GLFW.GLFW_KEY_R, "rocket inventory"),//rocket manager -> will do everything at once
29+
ROCKET_SCHEDULE("rocket_schedule", GLFW.GLFW_KEY_F, "rocket schedule")
2830

2931
;
3032

src/main/java/com/rae/creatingspace/init/ingameobject/BlockInit.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,15 @@ public class BlockInit {
475475
.item()
476476
.build()
477477
.register();
478+
public static final BlockEntry<Block> ASTEROID_COBALT_ORE = REGISTRATE.block(
479+
"asteroid_cobalt_ore", Block::new)
480+
.initialProperties(()-> Blocks.STONE)
481+
.properties(p-> p.strength(3.0f).requiresCorrectToolForDrops())
482+
.tag(BlockTags.NEEDS_DIAMOND_TOOL)
483+
.transform(TagGen.pickaxeOnly())
484+
.item()
485+
.build()
486+
.register();
478487
public static final BlockEntry<Block> RAW_COBALT_BLOCK = REGISTRATE.block(
479488
"raw_cobalt_block",Block::new)
480489
.initialProperties(()-> Blocks.STONE)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"variants" : {
3+
"": {
4+
"model" : "creatingspace:block/asteroid_cobalt_ore"
5+
}
6+
}
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"parent": "block/cube_all",
3+
"textures": {"all": "creatingspace:block/asteroid_cobalt_ore"}
4+
}

0 commit comments

Comments
 (0)