Fix, Refactor and Polish

- Tidied up and renamed Classes
- Added useful tooltips to all items
- Added tooltips to blueprint overlay tools
- Made Schematic And Quill more bearable to use
- Changed rendering order for blueprint overlay, Fixes Issue #1
This commit is contained in:
simibubi 2019-07-19 17:50:23 +02:00
parent f0b9c30ef5
commit dbfb60b809
62 changed files with 794 additions and 465 deletions

View file

@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
version = '0.0.1'
version = '0.0.2'
group = 'com.simibubi.create' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'create'

View file

@ -1,13 +1,13 @@
package com.simibubi.create;
import com.simibubi.create.block.CreativeCrateBlock;
import com.simibubi.create.block.IJustForRendering;
import com.simibubi.create.block.RenderingBlock;
import com.simibubi.create.block.SchematicTableBlock;
import com.simibubi.create.block.SchematicannonBlock;
import com.simibubi.create.block.symmetry.BlockSymmetryCrossPlane;
import com.simibubi.create.block.symmetry.BlockSymmetryPlane;
import com.simibubi.create.block.symmetry.BlockSymmetryTriplePlane;
import com.simibubi.create.block.symmetry.CrossPlaneSymmetryBlock;
import com.simibubi.create.block.symmetry.PlaneSymmetryBlock;
import com.simibubi.create.block.symmetry.TriplePlaneSymmetryBlock;
import com.simibubi.create.utility.IJustForRendering;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -24,9 +24,9 @@ public enum AllBlocks {
SCHEMATIC_TABLE(new SchematicTableBlock()),
SYMMETRY_PLANE(new BlockSymmetryPlane()),
SYMMETRY_CROSSPLANE(new BlockSymmetryCrossPlane()),
SYMMETRY_TRIPLEPLANE(new BlockSymmetryTriplePlane());
SYMMETRY_PLANE(new PlaneSymmetryBlock()),
SYMMETRY_CROSSPLANE(new CrossPlaneSymmetryBlock()),
SYMMETRY_TRIPLEPLANE(new TriplePlaneSymmetryBlock());
public Block block;

View file

@ -1,9 +1,9 @@
package com.simibubi.create;
import com.simibubi.create.item.ItemBlueprint;
import com.simibubi.create.item.ItemBlueprintAndQuill;
import com.simibubi.create.item.ItemTreeFertilizer;
import com.simibubi.create.item.ItemWandSymmetry;
import com.simibubi.create.item.BlueprintItem;
import com.simibubi.create.item.BlueprintAndQuillItem;
import com.simibubi.create.item.TreeFertilizerItem;
import com.simibubi.create.item.SymmetryWandItem;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Properties;
@ -14,11 +14,11 @@ import net.minecraftforge.registries.IForgeRegistry;
public enum AllItems {
TREE_FERTILIZER(new ItemTreeFertilizer(standardProperties())),
SYMMETRY_WAND(new ItemWandSymmetry(standardProperties())),
TREE_FERTILIZER(new TreeFertilizerItem(standardProperties())),
SYMMETRY_WAND(new SymmetryWandItem(standardProperties())),
EMPTY_BLUEPRINT(new Item(standardProperties().maxStackSize(1))),
BLUEPRINT_AND_QUILL(new ItemBlueprintAndQuill(standardProperties().maxStackSize(1))),
BLUEPRINT(new ItemBlueprint(standardProperties()));
BLUEPRINT_AND_QUILL(new BlueprintAndQuillItem(standardProperties().maxStackSize(1))),
BLUEPRINT(new BlueprintItem(standardProperties()));
public Item item;

View file

@ -16,8 +16,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import com.simibubi.create.networking.PacketSchematicUpload;
import com.simibubi.create.networking.Packets;
import com.simibubi.create.networking.SchematicUploadPacket;
import com.simibubi.create.networking.AllPackets;
import com.simibubi.create.utility.FilesHelper;
import net.minecraft.client.Minecraft;
@ -76,7 +76,7 @@ public class ClientSchematicLoader {
in = Files.newInputStream(path, StandardOpenOption.READ);
activeUploads.put(schematic, in);
Packets.channel.sendToServer(PacketSchematicUpload.begin(schematic, size));
AllPackets.channel.sendToServer(SchematicUploadPacket.begin(schematic, size));
} catch (IOException e) {
e.printStackTrace();
}
@ -92,7 +92,7 @@ public class ClientSchematicLoader {
}
if (Minecraft.getInstance().world != null)
Packets.channel.sendToServer(PacketSchematicUpload.write(schematic, data));
AllPackets.channel.sendToServer(SchematicUploadPacket.write(schematic, data));
else {
activeUploads.remove(schematic);
return;
@ -108,7 +108,7 @@ public class ClientSchematicLoader {
private void finishUpload(String schematic) {
if (activeUploads.containsKey(schematic)) {
Packets.channel.sendToServer(PacketSchematicUpload.finish(schematic));
AllPackets.channel.sendToServer(SchematicUploadPacket.finish(schematic));
activeUploads.remove(schematic);
}
}

View file

@ -3,10 +3,10 @@ package com.simibubi.create;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.simibubi.create.gui.Keyboard;
import com.simibubi.create.networking.Packets;
import com.simibubi.create.networking.AllPackets;
import com.simibubi.create.schematic.BlueprintHandler;
import com.simibubi.create.schematic.SchematicHologram;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.block.Block;
import net.minecraft.client.settings.KeyBinding;
@ -35,7 +35,7 @@ public class Create {
public static final String ID = "create";
public static final String NAME = "Create";
public static final String VERSION = "0.0.1";
public static final String VERSION = "0.0.2";
public static Logger logger = LogManager.getLogger();
@ -68,7 +68,7 @@ public class Create {
}
private void init(final FMLCommonSetupEvent event) {
Packets.registerPackets();
AllPackets.registerPackets();
DistExecutor.runWhenOn(Dist.CLIENT, () -> AllContainers::registerScreenFactories);
sSchematicLoader = new ServerSchematicLoader();
}

View file

@ -15,8 +15,8 @@ import java.util.Set;
import java.util.stream.Stream;
import com.simibubi.create.block.SchematicTableTileEntity;
import com.simibubi.create.item.ItemBlueprint;
import com.simibubi.create.networking.PacketSchematicUpload.DimensionPos;
import com.simibubi.create.item.BlueprintItem;
import com.simibubi.create.networking.SchematicUploadPacket.DimensionPos;
import com.simibubi.create.utility.FilesHelper;
import net.minecraft.block.BlockState;
@ -224,7 +224,7 @@ public class ServerSchematicLoader {
tileEntity.finishUpload();
tileEntity.inventory.setStackInSlot(0, ItemStack.EMPTY);
tileEntity.inventory.setStackInSlot(1,
ItemBlueprint.create(schematic, player.getName().getFormattedText()));
BlueprintItem.create(schematic, player.getName().getFormattedText()));
} catch (IOException e) {
Create.logger.error("Exception Thrown when finishing Upload: " + playerSchematicId);

View file

@ -1,12 +1,23 @@
package com.simibubi.create.block;
import java.util.List;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class CreativeCrateBlock extends Block {
@ -21,6 +32,19 @@ public class CreativeCrateBlock extends Block {
return false;
}
@Override
@OnlyIn(value = Dist.CLIENT)
public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComponent> tooltip,
ITooltipFlag flagIn) {
if (Keyboard.isKeyDown(Keyboard.LSHIFT)) {
tooltip.add(new StringTextComponent(TextFormatting.LIGHT_PURPLE + "Creative Item"));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Grants an attached " + TextFormatting.BLUE + "Schematicannon"));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "unlimited access to blocks."));
} else
tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + "< Hold Shift >"));
super.addInformation(stack, worldIn, tooltip, flagIn);
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return shape;

View file

@ -1,5 +1,7 @@
package com.simibubi.create.block;
import com.simibubi.create.utility.IJustForRendering;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

View file

@ -1,20 +1,31 @@
package com.simibubi.create.block;
import java.util.List;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.network.NetworkHooks;
public class SchematicTableBlock extends HorizontalBlock {
@ -33,6 +44,18 @@ public class SchematicTableBlock extends HorizontalBlock {
public boolean isSolid(BlockState state) {
return false;
}
@Override
@OnlyIn(value = Dist.CLIENT)
public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComponent> tooltip,
ITooltipFlag flagIn) {
if (Keyboard.isKeyDown(Keyboard.LSHIFT)) {
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Writes saved Schematics onto"));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "an " + TextFormatting.BLUE + "Empty Schematic"));
} else
tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + "< Hold Shift >"));
super.addInformation(stack, worldIn, tooltip, flagIn);
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {

View file

@ -1,10 +1,14 @@
package com.simibubi.create.block;
import java.util.List;
import com.simibubi.create.AllItems;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.InventoryHelper;
@ -14,10 +18,15 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.network.NetworkHooks;
public class SchematicannonBlock extends Block {
@ -36,6 +45,19 @@ public class SchematicannonBlock extends Block {
return new SchematicannonTileEntity();
}
@Override
@OnlyIn(value = Dist.CLIENT)
public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComponent> tooltip,
ITooltipFlag flagIn) {
if (Keyboard.isKeyDown(Keyboard.LSHIFT)) {
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Prints a deployed " + TextFormatting.BLUE + "Schematic"));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "into the world using blocks from inventories"));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "placed right next to it."));
} else
tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + "< Hold Shift >"));
super.addInformation(stack, worldIn, tooltip, flagIn);
}
@Override
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn,
BlockPos currentPos, BlockPos facingPos) {

View file

@ -7,7 +7,7 @@ import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.item.ItemBlueprint;
import com.simibubi.create.item.BlueprintItem;
import com.simibubi.create.schematic.Cuboid;
import com.simibubi.create.schematic.MaterialChecklist;
import com.simibubi.create.schematic.SchematicWorld;
@ -495,7 +495,7 @@ public class SchematicannonTileEntity extends TileEntitySynced implements ITicka
}
// Load blocks into reader
Template activeTemplate = ItemBlueprint.getSchematic(blueprint);
Template activeTemplate = BlueprintItem.getSchematic(blueprint);
BlockPos anchor = NBTUtil.readBlockPos(blueprint.getTag().getCompound("Anchor"));
if (activeTemplate.getSize().equals(BlockPos.ZERO)) {
@ -514,7 +514,7 @@ public class SchematicannonTileEntity extends TileEntitySynced implements ITicka
schematicAnchor = anchor;
blockReader = new SchematicWorld(new HashMap<>(), new Cuboid(), schematicAnchor);
activeTemplate.addBlocksToWorld(blockReader, schematicAnchor, ItemBlueprint.getSettings(blueprint));
activeTemplate.addBlocksToWorld(blockReader, schematicAnchor, BlueprintItem.getSettings(blueprint));
schematicLoaded = true;
state = State.PAUSED;
statusMsg = "Ready";

View file

@ -1,13 +0,0 @@
package com.simibubi.create.block.symmetry;
import com.simibubi.create.block.IJustForRendering;
import net.minecraft.block.Block;
public class BlockSymmetry extends Block implements IJustForRendering {
public BlockSymmetry(Properties properties) {
super(properties);
}
}

View file

@ -8,12 +8,12 @@ import net.minecraft.block.material.Material;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer.Builder;
public class BlockSymmetryCrossPlane extends BlockSymmetry {
public class CrossPlaneSymmetryBlock extends SymmetryBlock {
public static final EnumProperty<SymmetryCrossPlane.Align> align = EnumProperty.create("align",
SymmetryCrossPlane.Align.class);
public BlockSymmetryCrossPlane() {
public CrossPlaneSymmetryBlock() {
super(Properties.create(Material.AIR));
this.setDefaultState(getDefaultState().with(align, SymmetryCrossPlane.Align.Y));
}

View file

@ -8,11 +8,11 @@ import net.minecraft.block.material.Material;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer.Builder;
public class BlockSymmetryPlane extends BlockSymmetry {
public class PlaneSymmetryBlock extends SymmetryBlock {
public static final EnumProperty<SymmetryPlane.Align> align = EnumProperty.create("align", SymmetryPlane.Align.class);
public BlockSymmetryPlane() {
public PlaneSymmetryBlock() {
super(Properties.create(Material.AIR));
this.setDefaultState(getDefaultState().with(align, SymmetryPlane.Align.XY));
}

View file

@ -0,0 +1,13 @@
package com.simibubi.create.block.symmetry;
import com.simibubi.create.utility.IJustForRendering;
import net.minecraft.block.Block;
public class SymmetryBlock extends Block implements IJustForRendering {
public SymmetryBlock(Properties properties) {
super(properties);
}
}

View file

@ -2,9 +2,9 @@ package com.simibubi.create.block.symmetry;
import net.minecraft.block.material.Material;
public class BlockSymmetryTriplePlane extends BlockSymmetry {
public class TriplePlaneSymmetryBlock extends SymmetryBlock {
public BlockSymmetryTriplePlane() {
public TriplePlaneSymmetryBlock() {
super(Properties.create(Material.AIR));
}

View file

@ -6,9 +6,9 @@ import java.util.List;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllItems;
import com.simibubi.create.gui.widgets.DynamicLabel;
import com.simibubi.create.gui.widgets.OptionScrollArea;
import com.simibubi.create.gui.widgets.ScrollArea;
import com.simibubi.create.gui.widgets.Label;
import com.simibubi.create.gui.widgets.SelectionScrollInput;
import com.simibubi.create.gui.widgets.ScrollInput;
import com.simibubi.create.schematic.BlueprintHandler;
import net.minecraft.client.gui.widget.TextFieldWidget;
@ -27,12 +27,12 @@ public class BlueprintEditScreen extends AbstractSimiScreen {
"Clockwise 270");
private static final List<String> mirrorOptions = ImmutableList.of("None", "Left-Right", "Front-Back");
private ScrollArea rotationArea;
private ScrollArea mirrorArea;
private ScrollInput rotationArea;
private ScrollInput mirrorArea;
@Override
protected void init() {
setWindowSize(GuiResources.SCHEMATIC.width + 50, GuiResources.SCHEMATIC.height);
setWindowSize(ScreenResources.SCHEMATIC.width + 50, ScreenResources.SCHEMATIC.height);
int x = topLeftX;
int y = topLeftY;
BlueprintHandler bh = BlueprintHandler.instance;
@ -70,12 +70,12 @@ public class BlueprintEditScreen extends AbstractSimiScreen {
});
}
DynamicLabel labelR = new DynamicLabel(x + 99, y + 52, "").withShadow();
rotationArea = new OptionScrollArea(x + 96, y + 49, 94, 14).forOptions(rotationOptions).titled("Rotation")
Label labelR = new Label(x + 99, y + 52, "").withShadow();
rotationArea = new SelectionScrollInput(x + 96, y + 49, 94, 14).forOptions(rotationOptions).titled("Rotation")
.setState(bh.cachedSettings.getRotation().ordinal()).writingTo(labelR);
DynamicLabel labelM = new DynamicLabel(x + 99, y + 72, "").withShadow();
mirrorArea = new OptionScrollArea(x + 96, y + 69, 94, 14).forOptions(mirrorOptions).titled("Mirror")
Label labelM = new Label(x + 99, y + 72, "").withShadow();
mirrorArea = new SelectionScrollInput(x + 96, y + 69, 94, 14).forOptions(mirrorOptions).titled("Mirror")
.setState(bh.cachedSettings.getMirror().ordinal()).writingTo(labelM);
Collections.addAll(widgets, xInput, yInput, zInput);
@ -118,15 +118,15 @@ public class BlueprintEditScreen extends AbstractSimiScreen {
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
int x = topLeftX;
int y = topLeftY;
GuiResources.SCHEMATIC.draw(this, x, y);
ScreenResources.SCHEMATIC.draw(this, x, y);
BlueprintHandler bh = BlueprintHandler.instance;
font.drawStringWithShadow(bh.cachedSchematicName, x + 103 - font.getStringWidth(bh.cachedSchematicName) / 2,
y + 10, 0xDDEEFF);
font.drawString("Position", x + 10, y + 32, GuiResources.FONT_COLOR);
font.drawString("Rotation", x + 10, y + 52, GuiResources.FONT_COLOR);
font.drawString("Mirror", x + 10, y + 72, GuiResources.FONT_COLOR);
font.drawString("Position", x + 10, y + 32, ScreenResources.FONT_COLOR);
font.drawString("Rotation", x + 10, y + 52, ScreenResources.FONT_COLOR);
font.drawString("Mirror", x + 10, y + 72, ScreenResources.FONT_COLOR);
GlStateManager.pushMatrix();
GlStateManager.translated(topLeftX + 220, topLeftY + 20, 0);

View file

@ -13,7 +13,7 @@ public class BlueprintHotbarOverlay extends AbstractGui {
int x = mainWindow.getScaledWidth() / 2 - 92;
int y = mainWindow.getScaledHeight() - 23;
GlStateManager.enableAlphaTest();
GuiResources.BLUEPRINT_SLOT.draw(this, x + 20 * slot, y);
ScreenResources.BLUEPRINT_SLOT.draw(this, x + 20 * slot, y);
GlStateManager.disableAlphaTest();
}

View file

@ -7,10 +7,10 @@ import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create;
import com.simibubi.create.block.SchematicTableContainer;
import com.simibubi.create.gui.widgets.DynamicLabel;
import com.simibubi.create.gui.widgets.OptionScrollArea;
import com.simibubi.create.gui.widgets.ScrollArea;
import com.simibubi.create.gui.widgets.SimiButton;
import com.simibubi.create.gui.widgets.Label;
import com.simibubi.create.gui.widgets.SelectionScrollInput;
import com.simibubi.create.gui.widgets.ScrollInput;
import com.simibubi.create.gui.widgets.IconButton;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.IHasContainer;
@ -24,11 +24,11 @@ import net.minecraft.util.text.ITextComponent;
public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicTableContainer>
implements IHasContainer<SchematicTableContainer> {
private ScrollArea schematicsArea;
private SimiButton confirmButton;
private SimiButton folderButton;
private SimiButton refreshButton;
private DynamicLabel schematicsLabel;
private ScrollInput schematicsArea;
private IconButton confirmButton;
private IconButton folderButton;
private IconButton refreshButton;
private Label schematicsLabel;
private float progress;
private float chasingProgress;
@ -41,7 +41,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
@Override
protected void init() {
setWindowSize(GuiResources.SCHEMATIC_TABLE.width, GuiResources.SCHEMATIC_TABLE.height + 50);
setWindowSize(ScreenResources.SCHEMATIC_TABLE.width, ScreenResources.SCHEMATIC_TABLE.height + 50);
super.init();
widgets.clear();
@ -52,16 +52,16 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
List<String> availableSchematics = Create.cSchematicLoader.getAvailableSchematics();
if (!availableSchematics.isEmpty()) {
schematicsLabel = new DynamicLabel(mainLeft + 36, mainTop + 26, "").withShadow();
schematicsArea = new OptionScrollArea(mainLeft + 33, mainTop + 23, 134, 14).forOptions(availableSchematics)
schematicsLabel = new Label(mainLeft + 36, mainTop + 26, "").withShadow();
schematicsArea = new SelectionScrollInput(mainLeft + 33, mainTop + 23, 134, 14).forOptions(availableSchematics)
.titled("Available Schematics").writingTo(schematicsLabel);
widgets.add(schematicsArea);
widgets.add(schematicsLabel);
}
confirmButton = new SimiButton(mainLeft + 69, mainTop + 55, GuiResources.ICON_CONFIRM);
folderButton = new SimiButton(mainLeft + 204, mainTop + 6, GuiResources.ICON_OPEN_FOLDER);
refreshButton = new SimiButton(mainLeft + 204, mainTop + 26, GuiResources.ICON_REFRESH);
confirmButton = new IconButton(mainLeft + 69, mainTop + 55, ScreenResources.ICON_CONFIRM);
folderButton = new IconButton(mainLeft + 204, mainTop + 6, ScreenResources.ICON_OPEN_FOLDER);
refreshButton = new IconButton(mainLeft + 204, mainTop + 26, ScreenResources.ICON_REFRESH);
widgets.add(confirmButton);
widgets.add(folderButton);
widgets.add(refreshButton);
@ -83,28 +83,28 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
int mainLeft = guiLeft - 56;
int mainTop = guiTop - 16;
GuiResources.PLAYER_INVENTORY.draw(this, x- 16, y + 70 + 14);
ScreenResources.PLAYER_INVENTORY.draw(this, x- 16, y + 70 + 14);
font.drawString("Inventory", x - 15 + 7, y + 64 + 26, 0x666666);
GuiResources.SCHEMATIC_TABLE.draw(this, mainLeft, mainTop);
ScreenResources.SCHEMATIC_TABLE.draw(this, mainLeft, mainTop);
if (container.getTileEntity().isUploading)
font.drawString("Uploading...", mainLeft + 76, mainTop + 10, GuiResources.FONT_COLOR);
font.drawString("Uploading...", mainLeft + 76, mainTop + 10, ScreenResources.FONT_COLOR);
else if (container.getSlot(1).getHasStack())
font.drawString("Upload Finished!", mainLeft + 60, mainTop + 10, GuiResources.FONT_COLOR);
font.drawString("Upload Finished!", mainLeft + 60, mainTop + 10, ScreenResources.FONT_COLOR);
else
font.drawString("Schematic Table", mainLeft + 60, mainTop + 10, GuiResources.FONT_COLOR);
font.drawString("Schematic Table", mainLeft + 60, mainTop + 10, ScreenResources.FONT_COLOR);
if (schematicsArea == null) {
font.drawStringWithShadow(" No Schematics Saved ", mainLeft + 39, mainTop + 26, 0xFFDD44);
}
minecraft.getTextureManager().bindTexture(GuiResources.SCHEMATIC_TABLE_PROGRESS.location);
int width = (int) (GuiResources.SCHEMATIC_TABLE_PROGRESS.width
minecraft.getTextureManager().bindTexture(ScreenResources.SCHEMATIC_TABLE_PROGRESS.location);
int width = (int) (ScreenResources.SCHEMATIC_TABLE_PROGRESS.width
* MathHelper.lerp(partialTicks, lastChasingProgress, chasingProgress));
int height = GuiResources.SCHEMATIC_TABLE_PROGRESS.height;
int height = ScreenResources.SCHEMATIC_TABLE_PROGRESS.height;
GlStateManager.disableLighting();
blit(mainLeft + 94, mainTop + 56, GuiResources.SCHEMATIC_TABLE_PROGRESS.startX,
GuiResources.SCHEMATIC_TABLE_PROGRESS.startY, width, height);
blit(mainLeft + 94, mainTop + 56, ScreenResources.SCHEMATIC_TABLE_PROGRESS.startX,
ScreenResources.SCHEMATIC_TABLE_PROGRESS.startY, width, height);
GlStateManager.pushMatrix();
@ -185,7 +185,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
Create.cSchematicLoader.refresh();
List<String> availableSchematics = Create.cSchematicLoader.getAvailableSchematics();
widgets.remove(schematicsArea);
schematicsArea = new OptionScrollArea(guiLeft - 56 + 33, guiTop - 16 + 23, 134, 14).forOptions(availableSchematics)
schematicsArea = new SelectionScrollInput(guiLeft - 56 + 33, guiTop - 16 + 23, 134, 14).forOptions(availableSchematics)
.titled("Available Schematics").writingTo(schematicsLabel);
widgets.add(schematicsArea);
}

View file

@ -9,12 +9,12 @@ import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.block.SchematicannonContainer;
import com.simibubi.create.block.SchematicannonTileEntity;
import com.simibubi.create.gui.widgets.GuiIndicator;
import com.simibubi.create.gui.widgets.GuiIndicator.State;
import com.simibubi.create.gui.widgets.SimiButton;
import com.simibubi.create.networking.PacketConfigureSchematicannon;
import com.simibubi.create.networking.PacketConfigureSchematicannon.Option;
import com.simibubi.create.networking.Packets;
import com.simibubi.create.gui.widgets.Indicator;
import com.simibubi.create.gui.widgets.Indicator.State;
import com.simibubi.create.gui.widgets.IconButton;
import com.simibubi.create.networking.ConfigureSchematicannonPacket;
import com.simibubi.create.networking.ConfigureSchematicannonPacket.Option;
import com.simibubi.create.networking.AllPackets;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.renderer.RenderHelper;
@ -25,20 +25,20 @@ import net.minecraft.util.text.TextFormatting;
public class SchematicannonScreen extends AbstractSimiContainerScreen<SchematicannonContainer> {
protected Vector<GuiIndicator> replaceLevelIndicators;
protected Vector<SimiButton> replaceLevelButtons;
protected Vector<Indicator> replaceLevelIndicators;
protected Vector<IconButton> replaceLevelButtons;
protected SimiButton skipMissingButton;
protected GuiIndicator skipMissingIndicator;
protected SimiButton skipTilesButton;
protected GuiIndicator skipTilesIndicator;
protected IconButton skipMissingButton;
protected Indicator skipMissingIndicator;
protected IconButton skipTilesButton;
protected Indicator skipTilesIndicator;
protected SimiButton playButton;
protected GuiIndicator playIndicator;
protected SimiButton pauseButton;
protected GuiIndicator pauseIndicator;
protected SimiButton resetButton;
protected GuiIndicator resetIndicator;
protected IconButton playButton;
protected Indicator playIndicator;
protected IconButton pauseButton;
protected Indicator pauseIndicator;
protected IconButton resetButton;
protected Indicator resetIndicator;
public SchematicannonScreen(SchematicannonContainer container, PlayerInventory inventory,
ITextComponent p_i51105_3_) {
@ -47,7 +47,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
@Override
protected void init() {
setWindowSize(GuiResources.SCHEMATICANNON.width + 50, GuiResources.SCHEMATICANNON.height + 80);
setWindowSize(ScreenResources.SCHEMATICANNON.width + 50, ScreenResources.SCHEMATICANNON.height + 80);
super.init();
int x = guiLeft + 20;
@ -56,12 +56,12 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
widgets.clear();
// Play Pause Stop
playButton = new SimiButton(x + 70, y + 55, GuiResources.ICON_PLAY);
playIndicator = new GuiIndicator(x + 70, y + 50, "");
pauseButton = new SimiButton(x + 88, y + 55, GuiResources.ICON_PAUSE);
pauseIndicator = new GuiIndicator(x + 88, y + 50, "");
resetButton = new SimiButton(x + 106, y + 55, GuiResources.ICON_STOP);
resetIndicator = new GuiIndicator(x + 106, y + 50, "Not Running");
playButton = new IconButton(x + 70, y + 55, ScreenResources.ICON_PLAY);
playIndicator = new Indicator(x + 70, y + 50, "");
pauseButton = new IconButton(x + 88, y + 55, ScreenResources.ICON_PAUSE);
pauseIndicator = new Indicator(x + 88, y + 50, "");
resetButton = new IconButton(x + 106, y + 55, ScreenResources.ICON_STOP);
resetIndicator = new Indicator(x + 106, y + 50, "Not Running");
resetIndicator.state = State.RED;
Collections.addAll(widgets, playButton, playIndicator, pauseButton, pauseIndicator, resetButton,
resetIndicator);
@ -69,28 +69,28 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
// Replace settings
replaceLevelButtons = new Vector<>(4);
replaceLevelIndicators = new Vector<>(4);
List<GuiResources> icons = ImmutableList.of(GuiResources.ICON_DONT_REPLACE, GuiResources.ICON_REPLACE_SOLID,
GuiResources.ICON_REPLACE_ANY, GuiResources.ICON_REPLACE_EMPTY);
List<ScreenResources> icons = ImmutableList.of(ScreenResources.ICON_DONT_REPLACE, ScreenResources.ICON_REPLACE_SOLID,
ScreenResources.ICON_REPLACE_ANY, ScreenResources.ICON_REPLACE_EMPTY);
List<String> toolTips = ImmutableList.of("Don't Replace Solid Blocks", "Replace Solid with Solid",
"Replace Solid with Any", "Replace Solid with Empty");
for (int i = 0; i < 4; i++) {
replaceLevelIndicators.add(new GuiIndicator(x + 16 + i * 18, y + 96, ""));
replaceLevelButtons.add(new SimiButton(x + 16 + i * 18, y + 101, icons.get(i)));
replaceLevelIndicators.add(new Indicator(x + 16 + i * 18, y + 96, ""));
replaceLevelButtons.add(new IconButton(x + 16 + i * 18, y + 101, icons.get(i)));
replaceLevelButtons.get(i).setToolTip(toolTips.get(i));
}
widgets.addAll(replaceLevelButtons);
widgets.addAll(replaceLevelIndicators);
// Other Settings
skipMissingButton = new SimiButton(x + 106, y + 101, GuiResources.ICON_SKIP_MISSING);
skipMissingButton = new IconButton(x + 106, y + 101, ScreenResources.ICON_SKIP_MISSING);
skipMissingButton.setToolTip("Skip missing Blocks");
skipMissingIndicator = new GuiIndicator(x + 106, y + 96, "");
skipMissingIndicator = new Indicator(x + 106, y + 96, "");
Collections.addAll(widgets, skipMissingButton, skipMissingIndicator);
skipTilesButton = new SimiButton(x + 124, y + 101, GuiResources.ICON_SKIP_TILES);
skipTilesButton = new IconButton(x + 124, y + 101, ScreenResources.ICON_SKIP_TILES);
skipTilesButton.setToolTip("Protect Tile Entities");
skipTilesIndicator = new GuiIndicator(x + 124, y + 96, "");
skipTilesIndicator = new Indicator(x + 124, y + 96, "");
Collections.addAll(widgets, skipTilesButton, skipTilesIndicator);
tick();
@ -140,10 +140,10 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
protected void handleTooltips() {
for (Widget w : widgets)
if (w instanceof SimiButton)
if (!((SimiButton) w).getToolTip().isEmpty()) {
((SimiButton) w).setToolTip(((SimiButton) w).getToolTip().get(0));
((SimiButton) w).getToolTip()
if (w instanceof IconButton)
if (!((IconButton) w).getToolTip().isEmpty()) {
((IconButton) w).setToolTip(((IconButton) w).getToolTip().get(0));
((IconButton) w).getToolTip()
.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + "[Ctrl] for more Info");
}
@ -209,8 +209,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
@Override
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
GuiResources.PLAYER_INVENTORY.draw(this, guiLeft - 10, guiTop + 145);
GuiResources.SCHEMATICANNON.draw(this, guiLeft + 20, guiTop);
ScreenResources.PLAYER_INVENTORY.draw(this, guiLeft - 10, guiTop + 145);
ScreenResources.SCHEMATICANNON.draw(this, guiLeft + 20, guiTop);
SchematicannonTileEntity te = container.getTileEntity();
renderPrintingProgress(te.schematicProgress);
@ -222,7 +222,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
renderCannon();
font.drawString("Schematicannon", guiLeft + 80, guiTop + 10, GuiResources.FONT_COLOR);
font.drawString("Schematicannon", guiLeft + 80, guiTop + 10, ScreenResources.FONT_COLOR);
String msg = te.statusMsg;
int stringWidth = font.getStringWidth(msg);
@ -231,7 +231,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
else
font.drawSplitString(msg, guiLeft + 20 + 45, guiTop + 24, 120, 0xCCDDFF);
font.drawString("Placement Settings", guiLeft + 20 + 13, guiTop + 84, GuiResources.FONT_COLOR);
font.drawString("Placement Settings", guiLeft + 20 + 13, guiTop + 84, ScreenResources.FONT_COLOR);
font.drawString("Inventory", guiLeft - 10 + 7, guiTop + 145 + 6, 0x666666);
}
@ -253,26 +253,26 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
}
protected void renderBlueprintHighlight() {
GuiResources.SCHEMATICANNON_HIGHLIGHT.draw(this, guiLeft + 20 + 8, guiTop + 31);
ScreenResources.SCHEMATICANNON_HIGHLIGHT.draw(this, guiLeft + 20 + 8, guiTop + 31);
}
protected void renderPrintingProgress(float progress) {
progress = Math.min(progress, 1);
GuiResources sprite = GuiResources.SCHEMATICANNON_PROGRESS;
ScreenResources sprite = ScreenResources.SCHEMATICANNON_PROGRESS;
minecraft.getTextureManager().bindTexture(sprite.location);
blit(guiLeft + 20 + 39, guiTop + 36, sprite.startX, sprite.startY, (int) (sprite.width * progress),
sprite.height);
}
protected void renderChecklistPrinterProgress(float progress) {
GuiResources sprite = GuiResources.SCHEMATICANNON_PROGRESS_2;
ScreenResources sprite = ScreenResources.SCHEMATICANNON_PROGRESS_2;
minecraft.getTextureManager().bindTexture(sprite.location);
blit(guiLeft + 20 + 222, guiTop + 42, sprite.startX, sprite.startY, sprite.width,
(int) (sprite.height * progress));
}
protected void renderFuelBar(float amount) {
GuiResources sprite = GuiResources.SCHEMATICANNON_FUEL;
ScreenResources sprite = ScreenResources.SCHEMATICANNON_FUEL;
minecraft.getTextureManager().bindTexture(sprite.location);
blit(guiLeft + 20 + 73, guiTop + 135, sprite.startX, sprite.startY, (int) (sprite.width * amount),
sprite.height);
@ -281,8 +281,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
@Override
protected void renderWindowForeground(int mouseX, int mouseY, float partialTicks) {
int fuelX = guiLeft + 20 + 73, fuelY = guiTop + 135;
if (mouseX >= fuelX && mouseY >= fuelY && mouseX <= fuelX + GuiResources.SCHEMATICANNON_FUEL.width
&& mouseY <= fuelY + GuiResources.SCHEMATICANNON_FUEL.height) {
if (mouseX >= fuelX && mouseY >= fuelY && mouseX <= fuelX + ScreenResources.SCHEMATICANNON_FUEL.width
&& mouseY <= fuelY + ScreenResources.SCHEMATICANNON_FUEL.height) {
container.getTileEntity();
SchematicannonTileEntity te = container.getTileEntity();
int shotsLeft = (int) (te.fuelLevel / SchematicannonTileEntity.FUEL_USAGE_RATE);
@ -331,8 +331,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
}
protected void sendOptionUpdate(Option option, boolean set) {
Packets.channel
.sendToServer(PacketConfigureSchematicannon.setOption(container.getTileEntity().getPos(), option, set));
AllPackets.channel
.sendToServer(ConfigureSchematicannonPacket.setOption(container.getTileEntity().getPos(), option, set));
}
}

View file

@ -10,7 +10,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
@OnlyIn(Dist.CLIENT)
@EventBusSubscriber(value = Dist.CLIENT)
public class GuiOpener {
public class ScreenOpener {
private static Screen openedGuiNextTick;

View file

@ -6,7 +6,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.util.ResourceLocation;
public enum GuiResources {
public enum ScreenResources {
// Inventories
PLAYER_INVENTORY("player_inventory.png", 176, 108),
@ -72,11 +72,11 @@ public enum GuiResources {
public int width, height;
public int startX, startY;
private GuiResources(String location, int width, int height) {
private ScreenResources(String location, int width, int height) {
this(location, 0, 0, width, height);
}
private GuiResources(String location, int startX, int startY, int width, int height) {
private ScreenResources(String location, int startX, int startY, int width, int height) {
this.location = new ResourceLocation(Create.ID, "textures/gui/" + location);
this.width = width; this.height = height;
this.startX = startX; this.startY = startY;

View file

@ -3,17 +3,17 @@ package com.simibubi.create.gui;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.gui.widgets.DynamicLabel;
import com.simibubi.create.gui.widgets.OptionScrollArea;
import com.simibubi.create.gui.widgets.ScrollArea;
import com.simibubi.create.item.ItemWandSymmetry;
import com.simibubi.create.gui.widgets.Label;
import com.simibubi.create.gui.widgets.SelectionScrollInput;
import com.simibubi.create.gui.widgets.ScrollInput;
import com.simibubi.create.item.SymmetryWandItem;
import com.simibubi.create.item.symmetry.SymmetryCrossPlane;
import com.simibubi.create.item.symmetry.SymmetryElement;
import com.simibubi.create.item.symmetry.SymmetryEmptySlot;
import com.simibubi.create.item.symmetry.SymmetryPlane;
import com.simibubi.create.item.symmetry.SymmetryTriplePlane;
import com.simibubi.create.networking.PacketNbt;
import com.simibubi.create.networking.Packets;
import com.simibubi.create.networking.NbtPacket;
import com.simibubi.create.networking.AllPackets;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.RenderHelper;
@ -28,21 +28,21 @@ import net.minecraft.util.math.Vec3d;
import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.fml.network.PacketDistributor;
public class GuiWandSymmetry extends AbstractSimiScreen {
public class SymmetryWandScreen extends AbstractSimiScreen {
private ScrollArea areaType;
private DynamicLabel labelType;
private ScrollArea areaAlign;
private DynamicLabel labelAlign;
private ScrollInput areaType;
private Label labelType;
private ScrollInput areaAlign;
private Label labelAlign;
private SymmetryElement currentElement;
private float animationProgress;
private ItemStack wand;
public GuiWandSymmetry(ItemStack wand) {
public SymmetryWandScreen(ItemStack wand) {
super();
currentElement = ItemWandSymmetry.getMirror(wand);
currentElement = SymmetryWandItem.getMirror(wand);
if (currentElement instanceof SymmetryEmptySlot) {
currentElement = new SymmetryPlane(Vec3d.ZERO);
}
@ -53,14 +53,14 @@ public class GuiWandSymmetry extends AbstractSimiScreen {
@Override
public void init() {
super.init();
this.setWindowSize(GuiResources.WAND_SYMMETRY.width + 50, GuiResources.WAND_SYMMETRY.height + 50);
this.setWindowSize(ScreenResources.WAND_SYMMETRY.width + 50, ScreenResources.WAND_SYMMETRY.height + 50);
labelType = new DynamicLabel(topLeftX + 122, topLeftY + 15, "").colored(0xFFFFFFFF).withShadow();
labelAlign = new DynamicLabel(topLeftX + 122, topLeftY + 35, "").colored(0xFFFFFFFF).withShadow();
labelType = new Label(topLeftX + 122, topLeftY + 15, "").colored(0xFFFFFFFF).withShadow();
labelAlign = new Label(topLeftX + 122, topLeftY + 35, "").colored(0xFFFFFFFF).withShadow();
int state = currentElement instanceof SymmetryTriplePlane ? 2
: currentElement instanceof SymmetryCrossPlane ? 1 : 0;
areaType = new OptionScrollArea(topLeftX + 119, topLeftY + 12, 70, 14)
areaType = new SelectionScrollInput(topLeftX + 119, topLeftY + 12, 70, 14)
.forOptions(SymmetryElement.TOOLTIP_ELEMENTS).titled("Type of Mirror").writingTo(labelType)
.setState(state);
@ -96,7 +96,7 @@ public class GuiWandSymmetry extends AbstractSimiScreen {
widgets.remove(areaAlign);
}
areaAlign = new OptionScrollArea(topLeftX + 119, topLeftY + 32, 70, 14).forOptions(element.getAlignToolTips())
areaAlign = new SelectionScrollInput(topLeftX + 119, topLeftY + 32, 70, 14).forOptions(element.getAlignToolTips())
.titled("Direction").writingTo(labelAlign).setState(element.getOrientationIndex())
.calling(element::setOrientation);
@ -111,13 +111,13 @@ public class GuiWandSymmetry extends AbstractSimiScreen {
@Override
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
GuiResources.WAND_SYMMETRY.draw(this, topLeftX, topLeftY);
ScreenResources.WAND_SYMMETRY.draw(this, topLeftX, topLeftY);
int x = topLeftX + 63;
int y = topLeftY + 15;
font.drawString("Symmetry", x, y, GuiResources.FONT_COLOR);
font.drawString("Direction", x, y + 20, GuiResources.FONT_COLOR);
font.drawString("Symmetry", x, y, ScreenResources.FONT_COLOR);
font.drawString("Direction", x, y + 20, ScreenResources.FONT_COLOR);
minecraft.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
GlStateManager.enableBlend();
@ -168,9 +168,9 @@ public class GuiWandSymmetry extends AbstractSimiScreen {
public void removed() {
ItemStack heldItemMainhand = minecraft.player.getHeldItemMainhand();
CompoundNBT compound = heldItemMainhand.getTag();
compound.put(ItemWandSymmetry.$SYMMETRY, currentElement.writeToNbt());
compound.put(SymmetryWandItem.$SYMMETRY, currentElement.writeToNbt());
heldItemMainhand.setTag(compound);
Packets.channel.send(PacketDistributor.SERVER.noArg(), new PacketNbt(heldItemMainhand));
AllPackets.channel.send(PacketDistributor.SERVER.noArg(), new NbtPacket(heldItemMainhand));
minecraft.player.setHeldItem(Hand.MAIN_HAND, heldItemMainhand);
super.removed();
}

View file

@ -7,7 +7,7 @@ import org.lwjgl.glfw.GLFW;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.button.Button;
public class GuiTextPrompt extends AbstractSimiScreen {
public class TextInputPromptScreen extends AbstractSimiScreen {
private Consumer<String> callback;
private Consumer<String> abortCallback;
@ -22,7 +22,7 @@ public class GuiTextPrompt extends AbstractSimiScreen {
private boolean confirmed;
public GuiTextPrompt(Consumer<String> callBack, Consumer<String> abortCallback) {
public TextInputPromptScreen(Consumer<String> callBack, Consumer<String> abortCallback) {
super();
this.callback = callBack;
this.abortCallback = abortCallback;
@ -35,7 +35,7 @@ public class GuiTextPrompt extends AbstractSimiScreen {
@Override
public void init() {
super.init();
setWindowSize(GuiResources.TEXT_INPUT.width, GuiResources.TEXT_INPUT.height + 30);
setWindowSize(ScreenResources.TEXT_INPUT.width, ScreenResources.TEXT_INPUT.height + 30);
this.nameField = new TextFieldWidget(font, topLeftX + 33, topLeftY + 26, 128, 8, "");
this.nameField.setTextColor(-1);
@ -61,9 +61,9 @@ public class GuiTextPrompt extends AbstractSimiScreen {
@Override
public void renderWindow(int mouseX, int mouseY, float partialTicks) {
GuiResources.TEXT_INPUT.draw(this, topLeftX, topLeftY);
ScreenResources.TEXT_INPUT.draw(this, topLeftX, topLeftY);
font.drawString(title, topLeftX + (sWidth / 2) - (font.getStringWidth(title) / 2), topLeftY + 11,
GuiResources.FONT_COLOR);
ScreenResources.FONT_COLOR);
}
@Override

View file

@ -4,10 +4,12 @@ import java.util.List;
import java.util.function.Consumer;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.schematic.Tools;
import com.simibubi.create.Create;
import com.simibubi.create.schematic.tools.Tools;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.text.StringTextComponent;
@ -33,7 +35,7 @@ public class ToolSelectionScreen extends Screen {
callback.accept(tools.get(selection));
w = tools.size() * 50 + 30;
w = Math.max(tools.size() * 50 + 30, 220);
h = 30;
}
@ -55,16 +57,46 @@ public class ToolSelectionScreen extends Screen {
int y = mainWindow.getScaledHeight() - h - 75;
GlStateManager.pushMatrix();
GlStateManager.translatef(0, -yOffset, 0);
GlStateManager.translatef(0, -yOffset, focused? 100 : 0);
GuiResources gray = GuiResources.GRAY;
ScreenResources gray = ScreenResources.GRAY;
GlStateManager.enableBlend();
GlStateManager.enableAlphaTest();
GlStateManager.color4f(1, 1, 1, focused? 7 / 8f : 1 / 2f);
Minecraft.getInstance().getTextureManager().bindTexture(gray.location);
blit(x - 15, y, gray.startX, gray.startY, w, h, gray.width, gray.height);
float toolTipAlpha = yOffset / 10;
FontRenderer font = minecraft.fontRenderer;
List<String> toolTip = tools.get(selection).getDescription();
int stringAlphaComponent = ((int) (toolTipAlpha * 0xFF)) << 24;
if (toolTipAlpha > 0.25f) {
GlStateManager.color4f(.7f, .7f, .8f, toolTipAlpha);
blit(x - 15, y + 33, gray.startX, gray.startY, w, h + 22, gray.width, gray.height);
GlStateManager.color4f(1, 1, 1, 1);
if (toolTip.size() > 0)
drawString(font, toolTip.get(0), x - 10, y + 38, 0xEEEEEE + stringAlphaComponent);
if (toolTip.size() > 1)
drawString(font, toolTip.get(1), x - 10, y + 50, 0xCCDDFF + stringAlphaComponent);
if (toolTip.size() > 2)
drawString(font, toolTip.get(2), x - 10, y + 60, 0xCCDDFF + stringAlphaComponent);
if (toolTip.size() > 3)
drawString(font, toolTip.get(3), x - 10, y + 72, 0xCCCCDD + stringAlphaComponent);
}
GlStateManager.color4f(1, 1, 1, 1);
if (tools.size() > 1) {
String translationKey = Create.TOOL_MENU.getLocalizedName().toUpperCase();
int width = minecraft.mainWindow.getScaledWidth();
if (!focused)
drawCenteredString(minecraft.fontRenderer, "Hold [" + translationKey + "] to focus", width/2, y - 10, 0xCCDDFF);
else
drawCenteredString(minecraft.fontRenderer, "[SCROLL] to Cycle", width/2, y - 10, 0xCCDDFF);
} else {
x += 65;
}
for (int i = 0; i < tools.size(); i++) {
GlStateManager.pushMatrix();

View file

@ -1,35 +0,0 @@
package com.simibubi.create.gui.widgets;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.gui.GuiResources;
public class GuiIndicator extends AbstractSimiWidget {
public enum State {
OFF, ON,
RED, YELLOW, GREEN;
}
public State state;
public GuiIndicator(int x, int y, String tooltip) {
super(x, y, GuiResources.INDICATOR.width, GuiResources.INDICATOR.height);
this.toolTip = ImmutableList.of(tooltip);
this.state = State.OFF;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks ) {
GuiResources toDraw;
switch(state) {
case ON: toDraw = GuiResources.INDICATOR_WHITE; break;
case OFF: toDraw = GuiResources.INDICATOR; break;
case RED: toDraw = GuiResources.INDICATOR_RED; break;
case YELLOW: toDraw = GuiResources.INDICATOR_YELLOW; break;
case GREEN: toDraw = GuiResources.INDICATOR_GREEN; break;
default: toDraw = GuiResources.INDICATOR; break;
}
toDraw.draw(this, x, y);
}
}

View file

@ -1,17 +1,17 @@
package com.simibubi.create.gui.widgets;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.gui.GuiResources;
import com.simibubi.create.gui.ScreenResources;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
public class SimiButton extends AbstractSimiWidget {
public class IconButton extends AbstractSimiWidget {
private GuiResources icon;
private ScreenResources icon;
protected boolean pressed;
public SimiButton(int x, int y, GuiResources icon) {
public IconButton(int x, int y, ScreenResources icon) {
super(x, y, 18, 18);
this.icon = icon;
}
@ -19,14 +19,14 @@ public class SimiButton extends AbstractSimiWidget {
@Override
public void renderButton(int mouseX, int mouseY, float partialTicks) {
if (this.visible) {
ResourceLocation buttonTextures = GuiResources.BUTTON.location;
ResourceLocation buttonTextures = ScreenResources.BUTTON.location;
ResourceLocation iconTexture = icon.location;
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
GuiResources button =
(pressed || !active) ? button = GuiResources.BUTTON_DOWN :
(isHovered) ? GuiResources.BUTTON_HOVER :
GuiResources.BUTTON;
ScreenResources button =
(pressed || !active) ? button = ScreenResources.BUTTON_DOWN :
(isHovered) ? ScreenResources.BUTTON_HOVER :
ScreenResources.BUTTON;
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getInstance().getTextureManager().bindTexture(buttonTextures);

View file

@ -0,0 +1,35 @@
package com.simibubi.create.gui.widgets;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.gui.ScreenResources;
public class Indicator extends AbstractSimiWidget {
public enum State {
OFF, ON,
RED, YELLOW, GREEN;
}
public State state;
public Indicator(int x, int y, String tooltip) {
super(x, y, ScreenResources.INDICATOR.width, ScreenResources.INDICATOR.height);
this.toolTip = ImmutableList.of(tooltip);
this.state = State.OFF;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks ) {
ScreenResources toDraw;
switch(state) {
case ON: toDraw = ScreenResources.INDICATOR_WHITE; break;
case OFF: toDraw = ScreenResources.INDICATOR; break;
case RED: toDraw = ScreenResources.INDICATOR_RED; break;
case YELLOW: toDraw = ScreenResources.INDICATOR_YELLOW; break;
case GREEN: toDraw = ScreenResources.INDICATOR_GREEN; break;
default: toDraw = ScreenResources.INDICATOR; break;
}
toDraw.draw(this, x, y);
}
}

View file

@ -3,14 +3,14 @@ package com.simibubi.create.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
public class DynamicLabel extends AbstractSimiWidget {
public class Label extends AbstractSimiWidget {
public String text;
protected boolean hasShadow;
protected int color;
protected FontRenderer font;
public DynamicLabel(int x, int y, String text) {
public Label(int x, int y, String text) {
super(x, y, Minecraft.getInstance().fontRenderer.getStringWidth(text), 10);
font = Minecraft.getInstance().fontRenderer;
this.text = "Label";
@ -18,12 +18,12 @@ public class DynamicLabel extends AbstractSimiWidget {
hasShadow = false;
}
public DynamicLabel colored(int color) {
public Label colored(int color) {
this.color = color;
return this;
}
public DynamicLabel withShadow() {
public Label withShadow() {
this.hasShadow = true;
return this;
}

View file

@ -2,44 +2,44 @@ package com.simibubi.create.gui.widgets;
import java.util.function.Consumer;
import com.simibubi.create.gui.Keyboard;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.util.text.TextFormatting;
public class ScrollArea extends AbstractSimiWidget {
public class ScrollInput extends AbstractSimiWidget {
protected Consumer<Integer> onScroll;
protected int state;
protected String title = "Choose an option";
protected DynamicLabel displayLabel;
protected Label displayLabel;
protected int min, max;
public ScrollArea(int xIn, int yIn, int widthIn, int heightIn) {
public ScrollInput(int xIn, int yIn, int widthIn, int heightIn) {
super(xIn, yIn, widthIn, heightIn);
state = 0;
min = 0;
max = 1;
}
public ScrollArea withRange(int min, int max) {
public ScrollInput withRange(int min, int max) {
this.min = min;
this.max = max;
return this;
}
public ScrollArea calling(Consumer<Integer> onScroll) {
public ScrollInput calling(Consumer<Integer> onScroll) {
this.onScroll = onScroll;
return this;
}
public ScrollArea titled(String title) {
public ScrollInput titled(String title) {
this.title = title;
updateTooltip();
return this;
}
public ScrollArea writingTo(DynamicLabel label) {
public ScrollInput writingTo(Label label) {
this.displayLabel = label;
writeToLabel();
return this;
@ -49,7 +49,7 @@ public class ScrollArea extends AbstractSimiWidget {
return state;
}
public ScrollArea setState(int state) {
public ScrollInput setState(int state) {
this.state = state;
clampState();
updateTooltip();

View file

@ -5,16 +5,16 @@ import java.util.List;
import net.minecraft.util.text.TextFormatting;
public class OptionScrollArea extends ScrollArea {
public class SelectionScrollInput extends ScrollInput {
protected List<String> options;
public OptionScrollArea(int xIn, int yIn, int widthIn, int heightIn) {
public SelectionScrollInput(int xIn, int yIn, int widthIn, int heightIn) {
super(xIn, yIn, widthIn, heightIn);
options = new ArrayList<>();
}
public ScrollArea forOptions(List<String> options) {
public ScrollInput forOptions(List<String> options) {
this.options = options;
this.max = options.size();
updateTooltip();

View file

@ -0,0 +1,45 @@
package com.simibubi.create.item;
import java.util.List;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
public class BlueprintAndQuillItem extends Item {
public BlueprintAndQuillItem(Properties properties) {
super(properties);
}
@Override
public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
if (Keyboard.isKeyDown(Keyboard.LSHIFT)) {
TextFormatting gray = TextFormatting.GRAY;
TextFormatting blue = TextFormatting.BLUE;
tooltip.add(new StringTextComponent(gray + "Saves selected blocks in a Schematic File."));
tooltip.add(new StringTextComponent(""));
tooltip.add(new StringTextComponent(blue + "Step 1: Select two corner points"));
tooltip.add(new StringTextComponent(gray + "Hold [CTRL] to select at a fixed distance."));
tooltip.add(new StringTextComponent(gray + "[CTRL]-Scroll to modify the distance."));
tooltip.add(new StringTextComponent("Right-Click to put a point."));
tooltip.add(new StringTextComponent(""));
tooltip.add(new StringTextComponent(blue + "Step 2: Adjust the bounding box"));
tooltip.add(new StringTextComponent(gray + "Point at the Selection and use"));
tooltip.add(new StringTextComponent(gray + "[CTRL]-Scroll to move the face in-/outward."));
tooltip.add(new StringTextComponent("Right-Click to save."));
tooltip.add(new StringTextComponent(""));
tooltip.add(new StringTextComponent(gray + "Use Sneak-Right-Click to reset."));
} else
tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + "< Hold Shift >"));
super.addInformation(stack, worldIn, tooltip, flagIn);
}
}

View file

@ -5,13 +5,16 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.List;
import org.apache.commons.io.IOUtils;
import com.simibubi.create.AllItems;
import com.simibubi.create.gui.BlueprintEditScreen;
import com.simibubi.create.gui.GuiOpener;
import com.simibubi.create.gui.ScreenOpener;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -25,6 +28,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
@ -35,9 +39,9 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.thread.SidedThreadGroups;
public class ItemBlueprint extends Item {
public class BlueprintItem extends Item {
public ItemBlueprint(Properties properties) {
public BlueprintItem(Properties properties) {
super(properties.maxStackSize(1));
}
@ -60,6 +64,21 @@ public class ItemBlueprint extends Item {
return blueprint;
}
@Override
@OnlyIn(value = Dist.CLIENT)
public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
if (Keyboard.isKeyDown(Keyboard.LSHIFT)) {
TextFormatting gray = TextFormatting.GRAY;
tooltip.add(new StringTextComponent(gray + "Holds a structure to be printed"));
tooltip.add(new StringTextComponent(gray + "by the Schematicannon."));
tooltip.add(new StringTextComponent(""));
tooltip.add(new StringTextComponent(gray + "Sneak R-Click to put coordinates."));
tooltip.add(new StringTextComponent(gray + "Otherwise use the overlay to position it."));
} else
tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + "< Hold Shift >"));
super.addInformation(stack, worldIn, tooltip, flagIn);
}
public static void writeSize(ItemStack blueprint) {
CompoundNBT tag = blueprint.getTag();
Template t = getSchematic(blueprint);
@ -119,7 +138,7 @@ public class ItemBlueprint extends Item {
@OnlyIn(value = Dist.CLIENT)
protected void displayBlueprintScreen() {
GuiOpener.open(new BlueprintEditScreen());
ScreenOpener.open(new BlueprintEditScreen());
}
@Override

View file

@ -1,11 +0,0 @@
package com.simibubi.create.item;
import net.minecraft.item.Item;
public class ItemBlueprintAndQuill extends Item {
public ItemBlueprintAndQuill(Properties properties) {
super(properties);
}
}

View file

@ -51,7 +51,7 @@ public class SymmetryHandler {
PlayerInventory inv = player.inventory;
for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) {
if (!inv.getStackInSlot(i).isEmpty() && inv.getStackInSlot(i).getItem() == AllItems.SYMMETRY_WAND.get()) {
ItemWandSymmetry.apply(player.world, inv.getStackInSlot(i), player, event.getPos(),
SymmetryWandItem.apply(player.world, inv.getStackInSlot(i), player, event.getPos(),
event.getPlacedBlock());
}
}
@ -66,7 +66,7 @@ public class SymmetryHandler {
PlayerInventory inv = player.inventory;
for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) {
if (!inv.getStackInSlot(i).isEmpty() && AllItems.SYMMETRY_WAND.typeOf(inv.getStackInSlot(i))) {
ItemWandSymmetry.remove(player.world, inv.getStackInSlot(i), player, event.getPos());
SymmetryWandItem.remove(player.world, inv.getStackInSlot(i), player, event.getPos());
}
}
}
@ -82,8 +82,8 @@ public class SymmetryHandler {
for (int i = 0; i < PlayerInventory.getHotbarSize(); i++) {
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
if (stackInSlot != null && AllItems.SYMMETRY_WAND.typeOf(stackInSlot)
&& ItemWandSymmetry.isEnabled(stackInSlot)) {
SymmetryElement mirror = ItemWandSymmetry.getMirror(stackInSlot);
&& SymmetryWandItem.isEnabled(stackInSlot)) {
SymmetryElement mirror = SymmetryWandItem.getMirror(stackInSlot);
if (mirror instanceof SymmetryEmptySlot)
continue;
@ -128,9 +128,9 @@ public class SymmetryHandler {
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
if (stackInSlot != null && AllItems.SYMMETRY_WAND.typeOf(stackInSlot)
&& ItemWandSymmetry.isEnabled(stackInSlot)) {
&& SymmetryWandItem.isEnabled(stackInSlot)) {
SymmetryElement mirror = ItemWandSymmetry.getMirror(stackInSlot);
SymmetryElement mirror = SymmetryWandItem.getMirror(stackInSlot);
if (mirror instanceof SymmetryEmptySlot)
continue;

View file

@ -5,18 +5,20 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.simibubi.create.gui.GuiOpener;
import com.simibubi.create.gui.GuiWandSymmetry;
import com.simibubi.create.gui.ScreenOpener;
import com.simibubi.create.gui.SymmetryWandScreen;
import com.simibubi.create.item.symmetry.SymmetryCrossPlane;
import com.simibubi.create.item.symmetry.SymmetryElement;
import com.simibubi.create.item.symmetry.SymmetryEmptySlot;
import com.simibubi.create.item.symmetry.SymmetryPlane;
import com.simibubi.create.networking.PacketSymmetryEffect;
import com.simibubi.create.networking.Packets;
import com.simibubi.create.networking.SymmetryEffectPacket;
import com.simibubi.create.utility.Keyboard;
import com.simibubi.create.networking.AllPackets;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
@ -31,6 +33,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
@ -39,14 +42,33 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.network.PacketDistributor;
public class ItemWandSymmetry extends Item {
public class SymmetryWandItem extends Item {
public static final String $SYMMETRY = "symmetry";
private static final String $ENABLE = "enable";
public ItemWandSymmetry(Properties properties) {
public SymmetryWandItem(Properties properties) {
super(properties.maxStackSize(1));
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
if (Keyboard.isKeyDown(Keyboard.LSHIFT)) {
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Perfectly mirrors your Block placement"));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "across the configured planes."));
tooltip.add(new StringTextComponent(""));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "> [Right-Click] on ground to place mirror"));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "> [Right-Click] in air to configure mirror"));
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "> [Shift-Right-Click] to toggle"));
tooltip.add(new StringTextComponent(""));
tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + "Active while held in the Hotbar"));
} else
tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + "< Hold Shift >"));
super.addInformation(stack, worldIn, tooltip, flagIn);
}
@Override
public ActionResultType onItemUse(ItemUseContext context) {
@ -122,7 +144,7 @@ public class ItemWandSymmetry extends Item {
@OnlyIn(Dist.CLIENT)
private void openWandGUI(ItemStack wand) {
GuiOpener.open(new GuiWandSymmetry(wand));
ScreenOpener.open(new SymmetryWandScreen(wand));
}
private static void checkNBT(ItemStack wand) {
@ -187,8 +209,8 @@ public class ItemWandSymmetry extends Item {
}
}
Packets.channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> player),
new PacketSymmetryEffect(to, targets));
AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> player),
new SymmetryEffectPacket(to, targets));
}
public static void remove(World world, ItemStack wand, PlayerEntity player, BlockPos pos) {
@ -235,8 +257,8 @@ public class ItemWandSymmetry extends Item {
}
}
Packets.channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> player),
new PacketSymmetryEffect(to, targets));
AllPackets.channel.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> player),
new SymmetryEffectPacket(to, targets));
}
}

View file

@ -6,15 +6,19 @@ import java.util.List;
import java.util.Random;
import java.util.function.Predicate;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SaplingBlock;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.BoneMealItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.crafting.RecipeManager;
import net.minecraft.scoreboard.Scoreboard;
@ -23,16 +27,31 @@ import net.minecraft.util.ActionResultType;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.EmptyTickList;
import net.minecraft.world.ITickList;
import net.minecraft.world.World;
import net.minecraft.world.storage.MapData;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class ItemTreeFertilizer extends Item {
public class TreeFertilizerItem extends Item {
public ItemTreeFertilizer(Properties properties) {
public TreeFertilizerItem(Properties properties) {
super(properties);
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
if (Keyboard.isKeyDown(Keyboard.LSHIFT))
tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Tree won't grow? Try this on it."));
else
tooltip.add(new StringTextComponent(TextFormatting.DARK_GRAY + "< Hold Shift >"));
super.addInformation(stack, worldIn, tooltip, flagIn);
}
@Override
public ActionResultType onItemUse(ItemUseContext context) {

View file

@ -6,7 +6,7 @@ import java.util.Map;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.block.symmetry.BlockSymmetryCrossPlane;
import com.simibubi.create.block.symmetry.CrossPlaneSymmetryBlock;
import net.minecraft.block.BlockState;
import net.minecraft.util.IStringSerializable;
@ -84,7 +84,7 @@ public class SymmetryCrossPlane extends SymmetryElement {
@Override
public BlockState getModel() {
return AllBlocks.SYMMETRY_CROSSPLANE.block.getDefaultState().with(BlockSymmetryCrossPlane.align,
return AllBlocks.SYMMETRY_CROSSPLANE.block.getDefaultState().with(CrossPlaneSymmetryBlock.align,
(Align) orientation);
}

View file

@ -6,7 +6,7 @@ import java.util.Map;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.block.symmetry.BlockSymmetryPlane;
import com.simibubi.create.block.symmetry.PlaneSymmetryBlock;
import net.minecraft.block.BlockState;
import net.minecraft.util.IStringSerializable;
@ -80,7 +80,7 @@ public class SymmetryPlane extends SymmetryElement {
@Override
public BlockState getModel() {
return AllBlocks.SYMMETRY_PLANE.block.getDefaultState().with(BlockSymmetryPlane.align, (Align) orientation);
return AllBlocks.SYMMETRY_PLANE.block.getDefaultState().with(PlaneSymmetryBlock.align, (Align) orientation);
}
@Override

View file

@ -0,0 +1,30 @@
package com.simibubi.create.networking;
import com.simibubi.create.Create;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;
public class AllPackets {
private static final String PROTOCOL_VERSION = "1";
public static SimpleChannel channel;
public static void registerPackets() {
int i = 0;
channel = NetworkRegistry.newSimpleChannel(new ResourceLocation(Create.ID, "main"), () -> PROTOCOL_VERSION,
PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
channel.registerMessage(i++, NbtPacket.class, NbtPacket::toBytes, NbtPacket::new, NbtPacket::handle);
channel.registerMessage(i++, ConfigureSchematicannonPacket.class, ConfigureSchematicannonPacket::toBytes,
ConfigureSchematicannonPacket::new, ConfigureSchematicannonPacket::handle);
channel.registerMessage(i++, SchematicUploadPacket.class, SchematicUploadPacket::toBytes,
SchematicUploadPacket::new, SchematicUploadPacket::handle);
channel.registerMessage(i++, SymmetryEffectPacket.class, SymmetryEffectPacket::toBytes,
SymmetryEffectPacket::new, SymmetryEffectPacket::handle);
}
}

View file

@ -12,7 +12,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkEvent.Context;
public class PacketConfigureSchematicannon {
public class ConfigureSchematicannonPacket {
public static enum Option {
DONT_REPLACE, REPLACE_SOLID, REPLACE_ANY, REPLACE_EMPTY, SKIP_MISSING, SKIP_TILES, PLAY, PAUSE, STOP;
@ -22,18 +22,18 @@ public class PacketConfigureSchematicannon {
private boolean set;
private BlockPos pos;
public static PacketConfigureSchematicannon setOption(BlockPos pos, Option option, boolean set) {
PacketConfigureSchematicannon packet = new PacketConfigureSchematicannon(pos);
public static ConfigureSchematicannonPacket setOption(BlockPos pos, Option option, boolean set) {
ConfigureSchematicannonPacket packet = new ConfigureSchematicannonPacket(pos);
packet.option = option;
packet.set = set;
return packet;
}
public PacketConfigureSchematicannon(BlockPos pos) {
public ConfigureSchematicannonPacket(BlockPos pos) {
this.pos = pos;
}
public PacketConfigureSchematicannon(PacketBuffer buffer) {
public ConfigureSchematicannonPacket(PacketBuffer buffer) {
pos = buffer.readBlockPos();
option = Option.values()[buffer.readInt()];
set = buffer.readBoolean();

View file

@ -7,21 +7,21 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.network.NetworkEvent.Context;
public class PacketNbt {
public class NbtPacket {
public ItemStack stack;
public int slot;
public PacketNbt(ItemStack stack) {
public NbtPacket(ItemStack stack) {
this(stack, -1);
}
public PacketNbt(ItemStack stack, int slot) {
public NbtPacket(ItemStack stack, int slot) {
this.stack = stack;
this.slot = slot;
}
public PacketNbt(PacketBuffer buffer) {
public NbtPacket(PacketBuffer buffer) {
stack = buffer.readItemStack();
slot = buffer.readInt();
}

View file

@ -1,30 +0,0 @@
package com.simibubi.create.networking;
import com.simibubi.create.Create;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;
public class Packets {
private static final String PROTOCOL_VERSION = "1";
public static SimpleChannel channel;
public static void registerPackets() {
int i = 0;
channel = NetworkRegistry.newSimpleChannel(new ResourceLocation(Create.ID, "main"), () -> PROTOCOL_VERSION,
PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
channel.registerMessage(i++, PacketNbt.class, PacketNbt::toBytes, PacketNbt::new, PacketNbt::handle);
channel.registerMessage(i++, PacketConfigureSchematicannon.class, PacketConfigureSchematicannon::toBytes,
PacketConfigureSchematicannon::new, PacketConfigureSchematicannon::handle);
channel.registerMessage(i++, PacketSchematicUpload.class, PacketSchematicUpload::toBytes,
PacketSchematicUpload::new, PacketSchematicUpload::handle);
channel.registerMessage(i++, PacketSymmetryEffect.class, PacketSymmetryEffect::toBytes,
PacketSymmetryEffect::new, PacketSymmetryEffect::handle);
}
}

View file

@ -11,7 +11,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ServerWorld;
import net.minecraftforge.fml.network.NetworkEvent.Context;
public class PacketSchematicUpload {
public class SchematicUploadPacket {
public static final int BEGIN = 0;
public static final int WRITE = 1;
@ -22,28 +22,28 @@ public class PacketSchematicUpload {
private String schematic;
private byte[] data;
public PacketSchematicUpload(int code, String schematic) {
public SchematicUploadPacket(int code, String schematic) {
this.code = code;
this.schematic = schematic;
}
public static PacketSchematicUpload begin(String schematic, long size) {
PacketSchematicUpload pkt = new PacketSchematicUpload(BEGIN, schematic);
public static SchematicUploadPacket begin(String schematic, long size) {
SchematicUploadPacket pkt = new SchematicUploadPacket(BEGIN, schematic);
pkt.size = size;
return pkt;
}
public static PacketSchematicUpload write(String schematic, byte[] data) {
PacketSchematicUpload pkt = new PacketSchematicUpload(WRITE, schematic);
public static SchematicUploadPacket write(String schematic, byte[] data) {
SchematicUploadPacket pkt = new SchematicUploadPacket(WRITE, schematic);
pkt.data = data;
return pkt;
}
public static PacketSchematicUpload finish(String schematic) {
return new PacketSchematicUpload(FINISH, schematic);
public static SchematicUploadPacket finish(String schematic) {
return new SchematicUploadPacket(FINISH, schematic);
}
public PacketSchematicUpload(PacketBuffer buffer) {
public SchematicUploadPacket(PacketBuffer buffer) {
code = buffer.readInt();
schematic = buffer.readString(256);

View file

@ -12,17 +12,17 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.network.NetworkEvent.Context;
public class PacketSymmetryEffect {
public class SymmetryEffectPacket {
private BlockPos mirror;
private List<BlockPos> positions;
public PacketSymmetryEffect(BlockPos mirror, List<BlockPos> positions) {
public SymmetryEffectPacket(BlockPos mirror, List<BlockPos> positions) {
this.mirror = mirror;
this.positions = positions;
}
public PacketSymmetryEffect(PacketBuffer buffer) {
public SymmetryEffectPacket(PacketBuffer buffer) {
mirror = buffer.readBlockPos();
int amt = buffer.readInt();
positions = new ArrayList<>(amt);

View file

@ -11,28 +11,36 @@ import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllItems;
import com.simibubi.create.gui.GuiOpener;
import com.simibubi.create.gui.GuiTextPrompt;
import com.simibubi.create.gui.Keyboard;
import com.simibubi.create.gui.ScreenOpener;
import com.simibubi.create.gui.TextInputPromptScreen;
import com.simibubi.create.utility.FilesHelper;
import com.simibubi.create.utility.Keyboard;
import com.simibubi.create.utility.RaycastHelper;
import com.simibubi.create.utility.RaycastHelper.PredicateTraceResult;
import com.simibubi.create.utility.TessellatorHelper;
import com.simibubi.create.utility.TessellatorTextures;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.gen.feature.template.Template;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.GuiScreenEvent.MouseScrollEvent;
@ -47,7 +55,9 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
public class BlueprintAndQuillHandler {
static BlockPos firstPos;
static BlockPos secondPos;
static BlockPos selectedPos;
static Direction selectedFace;
static int range = 10;
private static boolean active() {
@ -56,11 +66,12 @@ public class BlueprintAndQuillHandler {
private static boolean present() {
return Minecraft.getInstance() != null && Minecraft.getInstance().world != null
&& Minecraft.getInstance().currentScreen == null && !Minecraft.getInstance().player.isSneaking();
&& Minecraft.getInstance().currentScreen == null;
}
@SubscribeEvent
// TODO: This is a fabricated event call by ScrollFixer until a proper event exists
// TODO: This is a fabricated event call by ScrollFixer until a proper event
// exists
public static void onMouseScrolled(MouseScrollEvent.Post event) {
if (event.getGui() != null)
return;
@ -68,7 +79,33 @@ public class BlueprintAndQuillHandler {
return;
if (!Keyboard.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL))
return;
range = (int) MathHelper.clamp(range + event.getScrollDelta(), 1, 100);
int delta = (int) event.getScrollDelta();
if (secondPos == null)
range = (int) MathHelper.clamp(range + delta, 1, 100);
if (selectedFace != null) {
MutableBoundingBox bb = new MutableBoundingBox(firstPos, secondPos);
Vec3i vec = selectedFace.getDirectionVec();
int x = vec.getX() * delta;
int y = vec.getY() * delta;
int z = vec.getZ() * delta;
AxisDirection axisDirection = selectedFace.getAxisDirection();
if (axisDirection == AxisDirection.NEGATIVE)
bb.offset(-x, -y, -z);
bb.maxX = Math.max(bb.maxX - x * axisDirection.getOffset(), bb.minX);
bb.maxY = Math.max(bb.maxY - y * axisDirection.getOffset(), bb.minY);
bb.maxZ = Math.max(bb.maxZ - z * axisDirection.getOffset(), bb.minZ);
firstPos = new BlockPos(bb.minX, bb.minY, bb.minZ);
secondPos = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
Minecraft.getInstance().player.sendStatusMessage(
new StringTextComponent(
"Schematic size: " + (bb.getXSize()) + "x" + (bb.getYSize()) + "x" + (bb.getZSize())),
true);
}
event.setCanceled(true);
}
@ -78,32 +115,45 @@ public class BlueprintAndQuillHandler {
return;
if (event.getButton() != 1)
return;
if (!active() && !Minecraft.getInstance().player.isSneaking())
if (!active())
return;
if (selectedPos == null)
return;
if (Minecraft.getInstance().player.isSneaking()) {
ClientPlayerEntity player = Minecraft.getInstance().player;
if (player.isSneaking()) {
firstPos = null;
secondPos = null;
player.sendStatusMessage(new StringTextComponent("Removed selection."), true);
return;
}
if (firstPos != null) {
GuiTextPrompt guiScreenIn = new GuiTextPrompt(BlueprintAndQuillHandler::saveSchematic, s -> {
firstPos = null;
if (secondPos != null) {
TextInputPromptScreen guiScreenIn = new TextInputPromptScreen(BlueprintAndQuillHandler::saveSchematic, s -> {
});
guiScreenIn.setTitle("Enter a name for the Schematic:");
guiScreenIn.setButtonTextConfirm("Save");
guiScreenIn.setButtonTextAbort("Cancel");
GuiOpener.open(guiScreenIn);
ScreenOpener.open(guiScreenIn);
return;
}
if (selectedPos == null) {
player.sendStatusMessage(new StringTextComponent("Hold [CTRL] to select Air blocks."), true);
return;
}
if (firstPos != null) {
secondPos = selectedPos;
player.sendStatusMessage(new StringTextComponent(TextFormatting.GREEN + "Second position set."), true);
return;
}
firstPos = selectedPos;
player.sendStatusMessage(new StringTextComponent(TextFormatting.GREEN + "First position set."), true);
}
public static void saveSchematic(String string) {
Template t = new Template();
MutableBoundingBox bb = new MutableBoundingBox(firstPos, selectedPos);
MutableBoundingBox bb = new MutableBoundingBox(firstPos, secondPos);
t.takeBlocksFromWorld(Minecraft.getInstance().world, new BlockPos(bb.minX, bb.minY, bb.minZ),
new BlockPos(bb.getXSize(), bb.getYSize(), bb.getZSize()), false, Blocks.AIR);
@ -127,6 +177,7 @@ public class BlueprintAndQuillHandler {
IOUtils.closeQuietly(outputStream);
}
firstPos = null;
secondPos = null;
Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent("Saved as " + filepath), true);
}
@ -136,29 +187,60 @@ public class BlueprintAndQuillHandler {
return;
TessellatorHelper.prepareForDrawing();
GlStateManager.lineWidth(3);
GlStateManager.lineWidth(2);
GlStateManager.color4f(1, 1, 1, 1);
GlStateManager.disableTexture();
if (firstPos != null) {
MutableBoundingBox bb = new MutableBoundingBox(firstPos, firstPos.add(1, 1, 1));
BlockPos min = new BlockPos(bb.minX, bb.minY, bb.minZ);
BlockPos max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
drawBox(min, max);
}
if (selectedPos != null) {
MutableBoundingBox bb = new MutableBoundingBox(selectedPos, selectedPos.add(1, 1, 1));
BlockPos min = new BlockPos(bb.minX, bb.minY, bb.minZ);
BlockPos max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
drawBox(min, max);
if (firstPos != null) {
bb = new MutableBoundingBox(firstPos, selectedPos);
min = new BlockPos(bb.minX, bb.minY, bb.minZ);
max = new BlockPos(bb.maxX + 1, bb.maxY + 1, bb.maxZ + 1);
drawBox(min, max);
if (secondPos == null) {
// 1st Step
if (firstPos != null && selectedPos == null) {
MutableBoundingBox bb = new MutableBoundingBox(firstPos, firstPos.add(1, 1, 1));
BlockPos min = new BlockPos(bb.minX, bb.minY, bb.minZ);
BlockPos max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
drawBox(min, max, true);
}
if (firstPos != null && selectedPos != null) {
MutableBoundingBox bb = new MutableBoundingBox(firstPos, selectedPos);
BlockPos min = new BlockPos(bb.minX, bb.minY, bb.minZ);
BlockPos max = new BlockPos(bb.maxX + 1, bb.maxY + 1, bb.maxZ + 1);
drawBox(min, max, true);
}
if (firstPos == null && selectedPos != null) {
MutableBoundingBox bb = new MutableBoundingBox(selectedPos, selectedPos.add(1, 1, 1));
BlockPos min = new BlockPos(bb.minX, bb.minY, bb.minZ);
BlockPos max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
drawBox(min, max, true);
}
} else {
// 2nd Step
MutableBoundingBox bb = new MutableBoundingBox(firstPos, secondPos);
BlockPos min = new BlockPos(bb.minX, bb.minY, bb.minZ);
BlockPos max = new BlockPos(bb.maxX + 1, bb.maxY + 1, bb.maxZ + 1);
drawBox(min, max, false);
if (selectedFace != null) {
Vec3d vec = new Vec3d(selectedFace.getDirectionVec());
Vec3d center = new Vec3d(min.add(max)).scale(1 / 2f);
Vec3d radii = new Vec3d(max.subtract(min)).scale(1 / 2f);
Vec3d onFaceOffset = new Vec3d(1 - Math.abs(vec.x), 1 - Math.abs(vec.y), 1 - Math.abs(vec.z))
.mul(radii);
Vec3d faceMin = center.add(vec.mul(radii).add(onFaceOffset));
Vec3d faceMax = center.add(vec.mul(radii).subtract(onFaceOffset));
GlStateManager.enableTexture();
TessellatorHelper.begin();
TessellatorTextures.SelectedRoom.bind();
TessellatorHelper.doubleFace(Tessellator.getInstance().getBuffer(), new BlockPos(faceMin),
new BlockPos(faceMax.subtract(faceMin)), 1 / 16f * selectedFace.getAxisDirection().getOffset(),
false, false, false);
TessellatorHelper.draw();
GlStateManager.disableTexture();
}
}
GlStateManager.lineWidth(1);
@ -166,9 +248,11 @@ public class BlueprintAndQuillHandler {
TessellatorHelper.cleanUpAfterDrawing();
}
protected static void drawBox(BlockPos min, BlockPos max) {
WorldRenderer.drawBoundingBox(min.getX() - 1 / 16d, min.getY() - 1 / 16d, min.getZ() - 1 / 16d,
max.getX() + 1 / 16d, max.getY() + 1 / 16d, max.getZ() + 1 / 16d, .3f, .4f, 1, 1);
protected static void drawBox(BlockPos min, BlockPos max, boolean blue) {
float red = blue ? .8f : 1;
float green = blue ? .9f : 1;
WorldRenderer.drawBoundingBox(min.getX() - 1 / 16d, min.getY() + 1 / 16d, min.getZ() - 1 / 16d,
max.getX() + 1 / 16d, max.getY() + 1 / 16d, max.getZ() + 1 / 16d, red, green, 1, 1);
}
@SubscribeEvent
@ -197,5 +281,17 @@ public class BlueprintAndQuillHandler {
}
}
if (secondPos == null) {
selectedFace = null;
return;
}
MutableBoundingBox bb = new MutableBoundingBox(firstPos, secondPos);
bb.maxX++;
bb.maxY++;
bb.maxZ++;
PredicateTraceResult result = RaycastHelper.rayTraceUntil(player, 70, pos -> bb.isVecInside(pos));
selectedFace = result.missed() ? null : result.getFacing();
}
}

View file

@ -9,11 +9,12 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.Create;
import com.simibubi.create.gui.BlueprintHotbarOverlay;
import com.simibubi.create.gui.Keyboard;
import com.simibubi.create.gui.ToolSelectionScreen;
import com.simibubi.create.item.ItemBlueprint;
import com.simibubi.create.networking.PacketNbt;
import com.simibubi.create.networking.Packets;
import com.simibubi.create.item.BlueprintItem;
import com.simibubi.create.networking.NbtPacket;
import com.simibubi.create.networking.AllPackets;
import com.simibubi.create.schematic.tools.Tools;
import com.simibubi.create.utility.Keyboard;
import com.simibubi.create.utility.TessellatorHelper;
import net.minecraft.client.Minecraft;
@ -36,6 +37,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.InputEvent.KeyInputEvent;
import net.minecraftforge.client.event.InputEvent.MouseInputEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.GuiScreenEvent.MouseScrollEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -169,11 +171,13 @@ public class BlueprintHandler {
}
@SubscribeEvent
public static void onRenderOverlay(RenderGameOverlayEvent event) {
if (instance.item != null)
instance.overlay.renderOn(instance.slot);
public static void onRenderOverlay(RenderGameOverlayEvent.Post event) {
if (!instance.active)
return;
if (event.getType() != ElementType.HOTBAR)
return;
if (instance.item != null)
instance.overlay.renderOn(instance.slot);
instance.currentTool.getTool().renderOverlay();
instance.selectionScreen.renderPassive(event.getPartialTicks());
@ -271,10 +275,10 @@ public class BlueprintHandler {
public void sync() {
Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent("Syncing..."), true);
Packets.channel.sendToServer(new PacketNbt(item, slot));
AllPackets.channel.sendToServer(new NbtPacket(item, slot));
if (deployed) {
Template schematic = ItemBlueprint.getSchematic(item);
Template schematic = BlueprintItem.getSchematic(item);
if (schematic.getSize().equals(BlockPos.ZERO))
return;

View file

@ -1,16 +0,0 @@
package com.simibubi.create.schematic;
public class SchematicMoveVerticalTool extends SchematicPlacementToolBase {
@Override
public boolean handleMouseWheel(double delta) {
if (blueprint.deployed) {
blueprint.moveTo(blueprint.anchor.add(0, delta, 0));
return true;
}
return super.handleMouseWheel(delta);
}
}

View file

@ -1,46 +0,0 @@
package com.simibubi.create.schematic;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.simibubi.create.gui.GuiResources;
public enum Tools {
Deploy(new SchematicDeployTool(), "Deploy", GuiResources.ICON_TOOL_DEPLOY),
Move(new SchematicMoveTool(), "Move XZ", GuiResources.ICON_TOOL_MOVE_XZ),
MoveY(new SchematicMoveVerticalTool(), "Move Y", GuiResources.ICON_TOOL_MOVE_Y),
Rotate(new SchematicRotateTool(), "Rotate", GuiResources.ICON_TOOL_ROTATE),
Flip(new SchematicFlipTool(), "Flip", GuiResources.ICON_TOOL_MIRROR);
private ISchematicTool tool;
private String displayName;
private GuiResources icon;
private Tools(ISchematicTool tool, String name, GuiResources icon) {
this.tool = tool;
this.displayName = name;
this.icon = icon;
}
public ISchematicTool getTool() {
return tool;
}
public String getDisplayName() {
return displayName;
}
public GuiResources getIcon() {
return icon;
}
public static List<Tools> getTools() {
List<Tools> tools = new ArrayList<>();
Collections.addAll(tools, Move, MoveY, Deploy, Rotate, Flip);
return tools;
}
}

View file

@ -1,16 +1,16 @@
package com.simibubi.create.schematic;
package com.simibubi.create.schematic.tools;
import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.gui.Keyboard;
import com.simibubi.create.utility.Keyboard;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.MutableBoundingBox;
public class SchematicDeployTool extends SchematicPlacementToolBase {
public class DeployTool extends PlacementToolBase {
@Override
public void init() {
@ -46,12 +46,12 @@ public class SchematicDeployTool extends SchematicPlacementToolBase {
max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
}
GlStateManager.lineWidth(3);
GlStateManager.lineWidth(2);
GlStateManager.color4f(.5f, .8f, 1, 1);
GlStateManager.disableTexture();
WorldRenderer.drawBoundingBox(min.getX() - 1 / 8d, min.getY() + 1 / 16d, min.getZ() - 1 / 8d,
max.getX() + 1 / 8d, max.getY() + 1 / 8d, max.getZ() + 1 / 8d, 1, 1, 1, 1);
max.getX() + 1 / 8d, max.getY() + 1 / 8d, max.getZ() + 1 / 8d, .8f, .9f, 1, 1);
GlStateManager.lineWidth(1);
GlStateManager.enableTexture();

View file

@ -1,6 +1,6 @@
package com.simibubi.create.schematic;
package com.simibubi.create.schematic.tools;
public class SchematicFlipTool extends SchematicPlacementToolBase {
public class FlipTool extends PlacementToolBase {
@Override
public void init() {

View file

@ -1,4 +1,4 @@
package com.simibubi.create.schematic;
package com.simibubi.create.schematic.tools;
public interface ISchematicTool {

View file

@ -1,6 +1,6 @@
package com.simibubi.create.schematic;
package com.simibubi.create.schematic.tools;
public class SchematicMoveTool extends SchematicPlacementToolBase {
public class MoveTool extends PlacementToolBase {
@Override
public void init() {
@ -9,15 +9,22 @@ public class SchematicMoveTool extends SchematicPlacementToolBase {
}
@Override
public boolean handleMouseWheel(double delta) {
public void updateSelection() {
super.updateSelection();
if (!schematicSelected)
return;
renderSelectedFace = selectedFace.getAxis().isHorizontal();
}
@Override
public boolean handleMouseWheel(double delta) {
if (schematicSelected && selectedFace.getAxis().isHorizontal()) {
blueprint.moveTo(delta < 0 ? blueprint.anchor.add(selectedFace.getDirectionVec())
: blueprint.anchor.subtract(selectedFace.getDirectionVec()));
return true;
}
return super.handleMouseWheel(delta);
return true;
}
}

View file

@ -0,0 +1,13 @@
package com.simibubi.create.schematic.tools;
public class MoveVerticalTool extends PlacementToolBase {
@Override
public boolean handleMouseWheel(double delta) {
if (blueprint.deployed) {
blueprint.moveTo(blueprint.anchor.add(0, delta, 0));
}
return true;
}
}

View file

@ -1,6 +1,6 @@
package com.simibubi.create.schematic;
package com.simibubi.create.schematic.tools;
public abstract class SchematicPlacementToolBase extends SchematicToolBase {
public abstract class PlacementToolBase extends SchematicToolBase {
@Override
public void init() {

View file

@ -1,8 +1,8 @@
package com.simibubi.create.schematic;
package com.simibubi.create.schematic.tools;
import net.minecraft.util.Rotation;
public class SchematicRotateTool extends SchematicPlacementToolBase {
public class RotateTool extends PlacementToolBase {
@Override
public boolean handleMouseWheel(double delta) {

View file

@ -1,6 +1,10 @@
package com.simibubi.create.schematic;
package com.simibubi.create.schematic.tools;
import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.schematic.BlueprintHandler;
import com.simibubi.create.utility.Keyboard;
import com.simibubi.create.utility.RaycastHelper;
import com.simibubi.create.utility.RaycastHelper.PredicateTraceResult;
@ -46,9 +50,10 @@ public abstract class SchematicToolBase implements ISchematicTool {
// Select Blueprint
if (blueprint.deployed) {
BlockPos min = blueprint.getTransformedAnchor();
MutableBoundingBox bb = new MutableBoundingBox(min, min.add(blueprint.getTransformedSize()));
PredicateTraceResult result = RaycastHelper.rayTraceUntil(player, 70,
pos -> new MutableBoundingBox(BlockPos.ZERO, blueprint.getTransformedSize())
.isVecInside(pos.subtract(blueprint.anchor)));
pos -> bb.isVecInside(pos));
schematicSelected = !result.missed();
selectedFace = schematicSelected ? result.getFacing() : null;
}
@ -80,7 +85,7 @@ public abstract class SchematicToolBase implements ISchematicTool {
public void renderTool() {
if (blueprint.deployed) {
GlStateManager.lineWidth(5);
GlStateManager.lineWidth(2);
GlStateManager.color4f(1, 1, 1, 1);
GlStateManager.disableTexture();
@ -90,21 +95,21 @@ public abstract class SchematicToolBase implements ISchematicTool {
BlockPos max = new BlockPos(bb.maxX, bb.maxY, bb.maxZ);
WorldRenderer.drawBoundingBox(min.getX() - 1 / 8d, min.getY() + 1 / 16d, min.getZ() - 1 / 8d,
max.getX() + 1 / 8d, max.getY() + 1 / 8d, max.getZ() + 1 / 8d, .3f, .4f, 1, 1);
max.getX() + 1 / 8d, max.getY() + 1 / 8d, max.getZ() + 1 / 8d, 1, 1, 1, 1);
if (schematicSelected && renderSelectedFace) {
if (schematicSelected && renderSelectedFace && Keyboard.isKeyDown(GLFW.GLFW_KEY_LEFT_CONTROL)) {
Vec3d vec = new Vec3d(selectedFace.getDirectionVec());
Vec3d center = new Vec3d(min.add(max)).scale(1 / 2f);
Vec3d radii = new Vec3d(max.subtract(min)).scale(1 / 2f);
Vec3d onFaceOffset = new Vec3d(1 - Math.abs(vec.x), 1 - Math.abs(vec.y), 1 - Math.abs(vec.z))
.mul(radii);
Vec3d faceMin = center.add(vec.mul(radii).add(onFaceOffset));
Vec3d faceMax = center.add(vec.mul(radii).subtract(onFaceOffset));
Vec3d faceMin = center.add(vec.mul(radii).add(onFaceOffset)).add(vec.scale(1/8f));
Vec3d faceMax = center.add(vec.mul(radii).subtract(onFaceOffset)).add(vec.scale(1/8f));
GlStateManager.lineWidth(4);
GlStateManager.lineWidth(6);
WorldRenderer.drawBoundingBox(faceMin.getX(), faceMin.getY() + 1 / 16d, faceMin.getZ(), faceMax.getX(),
faceMax.getY() + 1 / 8d, faceMax.getZ(), 1, 1, 1, 1);
faceMax.getY() + 1 / 8d, faceMax.getZ(), .6f, .7f, 1, 1);
}
GlStateManager.lineWidth(1);

View file

@ -0,0 +1,69 @@
package com.simibubi.create.schematic.tools;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.gui.ScreenResources;
public enum Tools {
Deploy(new DeployTool(), "Deploy", ScreenResources.ICON_TOOL_DEPLOY, ImmutableList.of(
"Moves the structure to a location.",
"Right-Click on the ground to place.",
"Hold [Ctrl] to select at a fixed distance.",
"[Ctrl]-Scroll to change the distance."
)),
Move(new MoveTool(), "Move XZ", ScreenResources.ICON_TOOL_MOVE_XZ, ImmutableList.of(
"Shifts the Schematic Horizontally",
"Point at the Schematic and [CTRL]-Scroll to push it."
)),
MoveY(new MoveVerticalTool(), "Move Y", ScreenResources.ICON_TOOL_MOVE_Y, ImmutableList.of(
"Shifts the Schematic Vertically",
"[CTRL]-Scroll to move it up/down"
)),
Rotate(new RotateTool(), "Rotate", ScreenResources.ICON_TOOL_ROTATE, ImmutableList.of(
"Rotates the Schematic around its center.",
"[CTRL]-Scroll to rotate by 90 Degrees"
)),
Flip(new FlipTool(), "Flip", ScreenResources.ICON_TOOL_MIRROR, ImmutableList.of(
"Flips the Schematic along the face you select.",
"Point at the Schematic and [CTRL]-Scroll to flip it."
));
private ISchematicTool tool;
private String displayName;
private ScreenResources icon;
private List<String> description;
private Tools(ISchematicTool tool, String name, ScreenResources icon, List<String> description) {
this.tool = tool;
this.displayName = name;
this.icon = icon;
this.description = description;
}
public ISchematicTool getTool() {
return tool;
}
public String getDisplayName() {
return displayName;
}
public ScreenResources getIcon() {
return icon;
}
public static List<Tools> getTools() {
List<Tools> tools = new ArrayList<>();
Collections.addAll(tools, Move, MoveY, Deploy, Rotate, Flip);
return tools;
}
public List<String> getDescription() {
return description;
}
}

View file

@ -1,4 +1,4 @@
package com.simibubi.create.block;
package com.simibubi.create.utility;
public interface IJustForRendering {

View file

@ -1,4 +1,4 @@
package com.simibubi.create.gui;
package com.simibubi.create.utility;
import org.lwjgl.glfw.GLFW;

View file

@ -14,7 +14,7 @@ loaderVersion="[26,)" #mandatory (26 is current forge version)
# The modid of the mod
modId="create" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="0.0.1" #mandatory
version="0.0.2" #mandatory
# A display name for the mod
displayName="Create" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 221 B