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
82 changes: 67 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import de.srendi.advancedperipherals.JustPlayingAroundStep
import net.darkhax.curseforgegradle.TaskPublishCurseForge

import java.text.SimpleDateFormat
Expand All @@ -12,7 +13,7 @@ plugins {
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'org.spongepowered.mixin' version '0.7.+'
id "com.github.breadmoirai.github-release" version "2.5.2"
id 'checkstyle'
id "com.diffplug.spotless" version "6.25.0"
id 'java'
}

Expand Down Expand Up @@ -366,6 +367,57 @@ dependencies {
// runtimeOnly fg.deobf("curse.maven:createaddition-439890:5099757")
}

spotless {
// optional: limit format enforcement to just the files changed by this feature branch
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '.gitattributes', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
java {
// don't need to set target, it is inferred from java
// apply a specific flavor of google-java-format
eclipse('4.26')
formatAnnotations()
indentWithSpaces()
// fix formatting of type annotations
//formatAnnotations()
// make sure every file has the following copyright header.
// optionally, Spotless can set copyright years by digging
// through git history (see "license" section below)
licenseHeader '''/*
* Copyright $YEAR Intelligence Modding @ https://intelligence-modding.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'''
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606
custom 'noWildcardImports', {
if (it.contains('*;\n')) {
throw new Error('No wildcard imports allowed')
}
}
bumpThisNumberIfACustomStepChanges(1)

// Needs to be placed after the eclipse formatter does its thing
//addStep(JustPlayingAroundStep.create())

}
}

changelog {
version = "${project.version}"
Expand Down Expand Up @@ -454,20 +506,20 @@ tasks.withType(Checkstyle) {

tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [minecraft_version : minecraft_version,
forge_version : forge_version,
loader_version : loader_version,
mod_id : mod_id,
version : version,
cc_version : cc_version,
curios_version : curios_version,
minecolonies_version : minecolonies_version,
appliedenergistics_version: appliedenergistics_version,
patchouli_version : patchouli_version,
refinedstorage_version : refinedstorage_version,
botania_version : botania_version,
mekanism_version : mekanism_version,
ae2things_version : ae2things_version,
powah_version : powah_version,]
forge_version : forge_version,
loader_version : loader_version,
mod_id : mod_id,
version : version,
cc_version : cc_version,
curios_version : curios_version,
minecolonies_version : minecolonies_version,
appliedenergistics_version: appliedenergistics_version,
patchouli_version : patchouli_version,
refinedstorage_version : refinedstorage_version,
botania_version : botania_version,
mekanism_version : mekanism_version,
ae2things_version : ae2things_version,
powah_version : powah_version,]

inputs.properties replaceProperties

Expand Down
7 changes: 7 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repositories {
mavenCentral()
}

dependencies {
implementation 'com.diffplug.spotless:spotless-lib-extra:2.45.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.srendi.advancedperipherals;

import com.diffplug.spotless.FormatterFunc;
import com.diffplug.spotless.FormatterStep;

import java.io.Serializable;

// Just a step for me to play around. Could evolve into something bigger when this branch gets merged into production
public class JustPlayingAroundStep {

public static FormatterStep create() {
return FormatterStep.create("", new State(), State::toFormatter);
}

private static class State implements Serializable {
FormatterFunc toFormatter() {
return input -> input;
}
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ pluginManagement {

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}
}
21 changes: 18 additions & 3 deletions src/main/java/de/srendi/advancedperipherals/APCreativeTab.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2024 Intelligence Modding @ https://intelligence-modding.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.srendi.advancedperipherals;

import de.srendi.advancedperipherals.common.setup.APBlocks;
Expand All @@ -22,7 +37,8 @@ public APCreativeTab() {

@Override
public void fillItemList(NonNullList<ItemStack> items) {
APRegistration.ITEMS.getEntries().stream().map(RegistryObject::get).forEach(item -> items.add(new ItemStack(item)));
APRegistration.ITEMS.getEntries().stream().map(RegistryObject::get)
.forEach(item -> items.add(new ItemStack(item)));
items.addAll(pocketUpgrade(CCRegistration.ID.COLONY_POCKET));
items.addAll(pocketUpgrade(CCRegistration.ID.CHATTY_POCKET));
items.addAll(pocketUpgrade(CCRegistration.ID.PLAYER_POCKET));
Expand Down Expand Up @@ -55,8 +71,7 @@ private static Collection<ItemStack> turtleUpgrade(ResourceLocation pocketId) {
}

@Override
@NotNull
public ItemStack makeIcon() {
@NotNull public ItemStack makeIcon() {
return new ItemStack(APBlocks.CHAT_BOX.get());
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2024 Intelligence Modding @ https://intelligence-modding.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.srendi.advancedperipherals;

import de.srendi.advancedperipherals.common.addons.APAddons;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2024 Intelligence Modding @ https://intelligence-modding.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.srendi.advancedperipherals.client;

import dan200.computercraft.api.client.ComputerCraftAPIClient;
Expand All @@ -23,12 +38,16 @@
@Mod.EventBusSubscriber(modid = AdvancedPeripherals.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ClientRegistry {

private static final String[] TURTLE_MODELS = new String[]{"turtle_chat_box_upgrade_left", "turtle_chat_box_upgrade_right", "turtle_environment_upgrade_left", "turtle_environment_upgrade_right", "turtle_player_upgrade_left", "turtle_player_upgrade_right", "turtle_geoscanner_upgrade_left", "turtle_geoscanner_upgrade_right"};
private static final String[] TURTLE_MODELS = new String[]{"turtle_chat_box_upgrade_left",
"turtle_chat_box_upgrade_right", "turtle_environment_upgrade_left", "turtle_environment_upgrade_right",
"turtle_player_upgrade_left", "turtle_player_upgrade_right", "turtle_geoscanner_upgrade_left",
"turtle_geoscanner_upgrade_right"};

@SubscribeEvent
public static void registerModels(ModelEvent.RegisterAdditional event) {
for (String model : TURTLE_MODELS) {
event.register(new ModelResourceLocation(new ResourceLocation(AdvancedPeripherals.MOD_ID, model), "inventory"));
event.register(
new ModelResourceLocation(new ResourceLocation(AdvancedPeripherals.MOD_ID, model), "inventory"));
}
}

Expand All @@ -37,18 +56,45 @@ public static void onClientSetup(FMLClientSetupEvent event) {
MenuScreens.register(APContainerTypes.INVENTORY_MANAGER_CONTAINER.get(), InventoryManagerScreen::new);
MenuScreens.register(APContainerTypes.SMART_GLASSES_CONTAINER.get(), SmartGlassesScreen::new);

ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHUNKY_TURTLE.get(), TurtleUpgradeModeller.flatItem());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.COMPASS_TURTLE.get(), TurtleUpgradeModeller.flatItem());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHAT_BOX_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_right"), "inventory")));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.ENVIRONMENT_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_right"), "inventory")));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.GEO_SCANNER_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_right"), "inventory")));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.PLAYER_DETECTOR_TURTLE.get(), TurtleUpgradeModeller.sided(new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_left"), "inventory"), new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_right"), "inventory")));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_END_TURTLE.get(), new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_HUSBANDRY_TURTLE.get(), new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_WEAK_TURTLE.get(), new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.HUSBANDRY_TURTLE.get(), new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.END_TURTLE.get(), new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.WEAK_TURTLE.get(), new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHUNKY_TURTLE.get(),
TurtleUpgradeModeller.flatItem());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.COMPASS_TURTLE.get(),
TurtleUpgradeModeller.flatItem());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.CHAT_BOX_TURTLE.get(),
TurtleUpgradeModeller.sided(
new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_left"),
"inventory"),
new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_chat_box_upgrade_right"),
"inventory")));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.ENVIRONMENT_TURTLE.get(),
TurtleUpgradeModeller.sided(
new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_left"),
"inventory"),
new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_environment_upgrade_right"),
"inventory")));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.GEO_SCANNER_TURTLE.get(),
TurtleUpgradeModeller.sided(
new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_left"),
"inventory"),
new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_geoscanner_upgrade_right"),
"inventory")));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.PLAYER_DETECTOR_TURTLE.get(),
TurtleUpgradeModeller.sided(
new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_left"), "inventory"),
new ModelResourceLocation(AdvancedPeripherals.getRL("turtle_player_upgrade_right"),
"inventory")));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_END_TURTLE.get(),
new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_HUSBANDRY_TURTLE.get(),
new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.OP_WEAK_TURTLE.get(),
new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.HUSBANDRY_TURTLE.get(),
new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.END_TURTLE.get(),
new MetaTurtleUpgradeModeller<>());
ComputerCraftAPIClient.registerTurtleUpgradeModeller(CCRegistration.WEAK_TURTLE.get(),
new MetaTurtleUpgradeModeller<>());

ItemPropertiesRegistry.register();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2024 Intelligence Modding @ https://intelligence-modding.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.srendi.advancedperipherals.client;

import de.srendi.advancedperipherals.AdvancedPeripherals;
Expand All @@ -8,10 +23,11 @@
public class ItemPropertiesRegistry {

public static void register() {
ItemProperties.register(APItems.MEMORY_CARD.get(), new ResourceLocation(AdvancedPeripherals.MOD_ID, "bounded"), (stack, level, entity, seed) -> {
boolean bounded = stack.getOrCreateTag().contains("owner");
return bounded ? 1 : 0;
});
ItemProperties.register(APItems.MEMORY_CARD.get(), new ResourceLocation(AdvancedPeripherals.MOD_ID, "bounded"),
(stack, level, entity, seed) -> {
boolean bounded = stack.getOrCreateTag().contains("owner");
return bounded ? 1 : 0;
});
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2024 Intelligence Modding @ https://intelligence-modding.de
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.srendi.advancedperipherals.client;

import net.minecraft.client.KeyMapping;
Expand All @@ -6,8 +21,10 @@

public class KeyBindings {

public static final KeyMapping DESCRIPTION_KEYBINDING = new KeyMapping("keybind.advancedperipherals.description", GLFW.GLFW_KEY_LEFT_CONTROL, "keybind.advancedperipherals.category");
public static final KeyMapping GLASSES_HOTKEY_KEYBINDING = new KeyMapping("keybind.advancedperipherals.glasses_hotkey", GLFW.GLFW_KEY_G, "keybind.advancedperipherals.category");
public static final KeyMapping DESCRIPTION_KEYBINDING = new KeyMapping("keybind.advancedperipherals.description",
GLFW.GLFW_KEY_LEFT_CONTROL, "keybind.advancedperipherals.category");
public static final KeyMapping GLASSES_HOTKEY_KEYBINDING = new KeyMapping(
"keybind.advancedperipherals.glasses_hotkey", GLFW.GLFW_KEY_G, "keybind.advancedperipherals.category");

public static void register(RegisterKeyMappingsEvent event) {
event.register(DESCRIPTION_KEYBINDING);
Expand Down
Loading