Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

File renamed without changes.
6 changes: 1 addition & 5 deletions src/main/java/com/gtnewhorizon/structurelib/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,7 @@ public HintParticleInfo(World w, int x, int y, int z, IIcon[] icons, short[] tin
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof HintParticleInfo)) return false;

HintParticleInfo that = (HintParticleInfo) o;
if (!(o instanceof HintParticleInfo that)) return false;

return x == that.x && y == that.y && z == that.z;
}
Expand Down Expand Up @@ -397,8 +395,6 @@ public void draw(Tessellator tes, double eyeX, double eyeY, double eyeZ, int eye
double worldY = y + 0.25;
double worldZ = z + 0.25;

// this rendering code is independently written by glee8e on July 10th, 2023
// and is released as part of StructureLib under LGPL terms, just like everything else in this project
// cube is a very special model. its facings can be rendered correctly by viewer distance without using
// surface normals and view vector
// here we do a 2 pass render.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public GuiEditRegistryConfig(GuiScreen parentScreen, IConfigElement disabled, IC
/**
* Adds the buttons (and other controls) to the screen in question.
*/
@SuppressWarnings("unchecked")
@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
Expand Down Expand Up @@ -185,8 +184,7 @@ public void initGui() {
*/
@Override
public void onGuiClosed() {
if (this.configID != null && this.parentScreen instanceof GuiConfig) {
GuiConfig parentGuiConfig = (GuiConfig) this.parentScreen;
if (this.configID != null && this.parentScreen instanceof GuiConfig parentGuiConfig) {
parentGuiConfig.needsRefresh = true;
parentGuiConfig.initGui();
}
Expand Down Expand Up @@ -319,21 +317,16 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
for (EntriesList list : lists) {
list.drawScreenPost(mouseX, mouseY, partialTicks);
}
if (this.undoHoverChecker.checkHover(mouseX, mouseY)) this.drawToolTip(
if (this.undoHoverChecker.checkHover(mouseX, mouseY)) this.func_146283_a(
this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.undoAll"), 300),
mouseX,
mouseY);
if (this.resetHoverChecker.checkHover(mouseX, mouseY)) this.drawToolTip(
if (this.resetHoverChecker.checkHover(mouseX, mouseY)) this.func_146283_a(
this.mc.fontRenderer.listFormattedStringToWidth(I18n.format("fml.configgui.tooltip.resetAll"), 300),
mouseX,
mouseY);
}

@SuppressWarnings("rawtypes")
public void drawToolTip(List stringList, int x, int y) {
this.func_146283_a(stringList, x, y);
}

private class EntriesList extends GuiListExtended {

final String heading;
Expand Down Expand Up @@ -571,13 +564,13 @@ private void drawLabel(int y, int slotHeight) {
void drawToolTip(int mouseX, int mouseY) {
// ensure checkHover() is always called, or the hover threshold might fail under certain corner cases
if (hoverCheckerText.checkHover(mouseX, mouseY)) {
GuiEditRegistryConfig.this.drawToolTip(
GuiEditRegistryConfig.this.func_146283_a(
mc.fontRenderer.listFormattedStringToWidth(tooltip, entriesList.getListWidth()),
mouseX,
mouseY);
}
if (hoverCheckerBtnDrag.checkHover(mouseX, mouseY) && !isDragging) {
GuiEditRegistryConfig.this.drawToolTip(
GuiEditRegistryConfig.this.func_146283_a(
mc.fontRenderer.listFormattedStringToWidth(
I18n.format("structurelib.configgui.drag.tooltip"),
entriesList.getListWidth()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public static SortedRegistry<?> getRegistry(String name) {
}

static void cleanup(MinecraftServer server) {
@SuppressWarnings("unchecked")
List<EntityPlayerMP> players = server.getConfigurationManager().playerEntityList;
Set<UUID> onlinePlayerIDs = players.stream().map(EntityPlayerMP::getUniqueID).collect(Collectors.toSet());
int removed = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ else if (tTileEntity instanceof IConstructable) {

if (constructable == null) return false;

if (aPlayer instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) aPlayer;
if (aPlayer instanceof EntityPlayerMP playerMP) {
// server side and sneaking (already checked above)
// do construct
if (aPlayer.capabilities.isCreativeMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, in
}

@Override
@SuppressWarnings("unchecked")
public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) {
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (int i = 0; i <= 15; i++) {
aList.add(new ItemStack(aItem, 1, i));
list.add(new ItemStack(item, 1, i));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ public List<String> addTabCompletionOptions(ICommandSender p_71516_1_, String[]
public void processCommand(ICommandSender sender, String[] args) {
if (args.length == 0) throw new WrongUsageException(getCommandUsage(sender));

if (!(sender instanceof EntityPlayerMP)) throw new WrongUsageException("must be a player");

EntityPlayerMP player = (EntityPlayerMP) sender;
if (!(sender instanceof EntityPlayerMP player)) throw new WrongUsageException("must be a player");

ItemStack heldItem = player.getHeldItem();
if (heldItem == null || !(heldItem.getItem() instanceof ItemConstructableTrigger)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public List<String> addTabCompletionOptions(ICommandSender p_71516_1_, String[]
public void processCommand(ICommandSender sender, String[] args) {
if (args.length != 1) throw new WrongUsageException(getCommandUsage(sender));

if (!(sender instanceof EntityPlayerMP)) throw new WrongUsageException("must be a player");

EntityPlayerMP player = (EntityPlayerMP) sender;
if (!(sender instanceof EntityPlayerMP player)) throw new WrongUsageException("must be a player");

SortedRegistry<?> registry = SortedRegistry.getRegistry(args[0]);
if (registry == null) throw new WrongUsageException("registry not found");
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/com/gtnewhorizon/structurelib/item/ItemBlockHint.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ public ItemBlockHint(Block p_i45328_1_) {
}

@Override
@SuppressWarnings("unchecked")
public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) {
aList.add(translateToLocal("structurelib.blockhint.desc.0")); // Helps while building
switch (aStack.getItemDamage()) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean adv) {
tooltip.add(translateToLocal("structurelib.blockhint.desc.0")); // Helps while building
switch (stack.getItemDamage()) {
case 0:
case 1:
case 2:
Expand All @@ -37,35 +36,36 @@ public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, b
case 9:
case 10:
case 11:
aList.add(
// Placeholder for a certain group.
tooltip.add(
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
+ translateToLocal("structurelib.blockhint.desc.1")); // Placeholder for a certain
// group.
+ translateToLocal("structurelib.blockhint.desc.1"));
break;
case 12:
aList.add(
// General placeholder.
tooltip.add(
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
+ translateToLocal("structurelib.blockhint.desc.2")); // General placeholder.
+ translateToLocal("structurelib.blockhint.desc.2"));
break;
case 13:
aList.add(
// Make sure it contains Air material.
tooltip.add(
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
+ translateToLocal("structurelib.blockhint.desc.3")); // Make sure it contains Air
// material.
+ translateToLocal("structurelib.blockhint.desc.3"));
break;
case 14:
aList.add(
// Make sure it does not contain Air material.
tooltip.add(
EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD
+ translateToLocal("structurelib.blockhint.desc.4")); // Make sure it does not contain
// Air material.
+ translateToLocal("structurelib.blockhint.desc.4"));
break;
case 15:
aList.add(EnumChatFormatting.BLUE + translateToLocal("structurelib.blockhint.desc.5")); // ERROR, what
// did u expect?
// ERROR, what did u expect?
tooltip.add(EnumChatFormatting.BLUE + translateToLocal("structurelib.blockhint.desc.5"));
break;
default: // WTF?
aList.add("Damn son where did you get that!?");
aList.add(EnumChatFormatting.BLUE + "From outer space... I guess...");
tooltip.add("Damn son where did you get that!?");
tooltip.add(EnumChatFormatting.BLUE + "From outer space... I guess...");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,30 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world,
return ConstructableUtility.handle(stack, player, world, x, y, z, side);
}

@SuppressWarnings("unchecked")
@Override
public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean adv) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
aList.add(
tooltip.add(
translateToLocalFormatted(
"item.structurelib.constructableTrigger.desc.lshift.0",
ChannelDataAccessor.countChannelData(aStack)));
ChannelDataAccessor.iterateChannelData(aStack).map(e -> e.getKey() + ": " + e.getValue())
.forEach(aList::add);
ChannelDataAccessor.countChannelData(stack)));
ChannelDataAccessor.iterateChannelData(stack).map(e -> e.getKey() + ": " + e.getValue())
.forEach(tooltip::add);
} else {
aList.add(translateToLocal("item.structurelib.constructableTrigger.desc.0")); // Triggers Constructable
// Interface
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.1")); // Shows multiblock
// construction
// details,
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.2")); // just Use on a
// multiblock
// controller.
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.3")); // (Sneak Use in
// creative to build)
aList.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.4")); // Quantity affects
// tier/mode/type
if (ChannelDataAccessor.hasSubChannel(aStack))
aList.add(translateToLocal("item.structurelib.constructableTrigger.desc.5"));
// Tooltip text:
// Triggers Constructable Interface
// Shows multiblock construction details,
// just Use on a multiblock controller.
// (Sneak Use in creative to build)
// Quantity affects tier/mode/type

tooltip.add(translateToLocal("item.structurelib.constructableTrigger.desc.0"));
tooltip.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.1"));
tooltip.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.2"));
tooltip.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.3"));
tooltip.add(BLUE + translateToLocal("item.structurelib.constructableTrigger.desc.4"));
if (ChannelDataAccessor.hasSubChannel(stack))
tooltip.add(translateToLocal("item.structurelib.constructableTrigger.desc.5"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world,

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List<String> aList, boolean p_77624_4_) {
aList.add(translateToLocal("item.structurelib.frontRotationTool.desc.0")); // Triggers Front Rotation Interface
aList.add(EnumChatFormatting.BLUE + translateToLocal("item.structurelib.frontRotationTool.desc.1")); // Rotates
// only the
// front
// panel,
aList.add(EnumChatFormatting.BLUE + translateToLocal("item.structurelib.frontRotationTool.desc.2")); // which
// allows
// structure
// rotation.
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean adv) {
// Tooltip Text:
// Triggers Front Rotation Interface
// Rotates only the front panel,
// which allows structure rotation.

tooltip.add(translateToLocal("item.structurelib.frontRotationTool.desc.0"));
tooltip.add(EnumChatFormatting.BLUE + translateToLocal("item.structurelib.frontRotationTool.desc.1"));
tooltip.add(EnumChatFormatting.BLUE + translateToLocal("item.structurelib.frontRotationTool.desc.2"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public NoExplicitChannel(String subchannel) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof NoExplicitChannel)) return false;

NoExplicitChannel that = (NoExplicitChannel) o;
if (!(o instanceof NoExplicitChannel that)) return false;

return subchannel.equals(that.subchannel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public interface IStructureDefinition<T> {
* @throws java.util.NoSuchElementException if the given structure piece is not found and the moon phase perfectly
* matches
*/
IStructureElement<T>[] getStructureFor(String name);
IStructureElement<? super T>[] getStructureFor(String name);

boolean isContainedInStructure(String name, int offsetA, int offsetB, int offsetC);

Expand Down Expand Up @@ -356,7 +356,7 @@ default void iterate(String piece, World world, ExtendedFacing extendedFacing, i
* @return true if iteration completed successfully.
* @param <T> type of context object.
*/
static <T> boolean iterate(T object, ItemStack trigger, IStructureElement<T>[] elements, World world,
static <T> boolean iterate(T object, ItemStack trigger, IStructureElement<? super T>[] elements, World world,
ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA,
int basePositionB, int basePositionC, boolean hintsOnly, Boolean checkBlocksIfNotNullForceCheckAllIfTrue) {
if (!world.isRemote && hintsOnly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
/**
* Use StructureUtility to instantiate. These are the building blocks for your {@link IStructureDefinition}. It
* represents what a particular element can be and how this particular element should be autoplaced.
*
* @param <T> Type of the context object. {@link IStructureElement} is contravariant over T, so parameters and fields of
* type {@link IStructureElement} should be declared as {@code IStructureElement<? super T>}
*/
public interface IStructureElement<T> {

Expand Down Expand Up @@ -213,7 +216,7 @@ default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, It
* Forget the messed up class dependency graph for now. this is just so convenient.
*/
default IStructureElementNoPlacement<T> noPlacement() {
return new IStructureElementNoPlacement<T>() {
return new IStructureElementNoPlacement<>() {

@Override
public boolean check(T t, World world, int x, int y, int z) {
Expand Down
Loading
Loading