From cc3bea6e72433ef00d290191c2620f26b3f2e89d Mon Sep 17 00:00:00 2001 From: DarkWeird Date: Fri, 9 Jul 2021 16:53:18 +0300 Subject: [PATCH 1/2] fix(ecs-gestalt): Migrate Components to gestalt's Components. --- .../component/GeneratedHerbComponent.java | 26 +++++--------- .../herbalism/component/HerbComponent.java | 21 +++--------- .../herbalism/component/HerbHueComponent.java | 27 ++++++--------- .../HerbalismStationRecipeComponent.java | 34 +++++++++---------- .../component/PollinatingHerbComponent.java | 21 +++--------- .../component/PredefinedHerbComponent.java | 26 +++++--------- 6 files changed, 53 insertions(+), 102 deletions(-) diff --git a/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java b/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java index a641305..a87d428 100644 --- a/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java @@ -1,26 +1,18 @@ -/* - * Copyright 2014 MovingBlocks - * - * 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 - * - * http://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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; /** * This component is used for storing the base genome of a generated herb. */ -public final class GeneratedHerbComponent implements Component { +public final class GeneratedHerbComponent implements Component { /** A string description of this herb's base genome. */ public String herbBaseGenome; + + @Override + public void copy(GeneratedHerbComponent other) { + this.herbBaseGenome = other.herbBaseGenome; + } } diff --git a/src/main/java/org/terasology/herbalism/component/HerbComponent.java b/src/main/java/org/terasology/herbalism/component/HerbComponent.java index dfbfb4f..4382034 100644 --- a/src/main/java/org/terasology/herbalism/component/HerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/HerbComponent.java @@ -1,24 +1,11 @@ -/* - * Copyright 2014 MovingBlocks - * - * 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 - * - * http://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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.EmptyComponent; /** * Add this component to an item to indicate that it is a herb. */ -public class HerbComponent implements Component { +public class HerbComponent extends EmptyComponent { } diff --git a/src/main/java/org/terasology/herbalism/component/HerbHueComponent.java b/src/main/java/org/terasology/herbalism/component/HerbHueComponent.java index 906df41..f078d1b 100644 --- a/src/main/java/org/terasology/herbalism/component/HerbHueComponent.java +++ b/src/main/java/org/terasology/herbalism/component/HerbHueComponent.java @@ -1,27 +1,20 @@ -/* - * Copyright 2014 MovingBlocks - * - * 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 - * - * http://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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import com.google.common.collect.Lists; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.List; /** * This component is used for storing the hue ranges of a particular herb. */ -public class HerbHueComponent implements Component { +public class HerbHueComponent implements Component { public List hueRanges; + + @Override + public void copy(HerbHueComponent other) { + this.hueRanges = Lists.newArrayList(other.hueRanges); + } } diff --git a/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java b/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java index f7eb071..3725eb6 100644 --- a/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java +++ b/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java @@ -1,21 +1,9 @@ -/* - * Copyright 2016 MovingBlocks - * - * 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 - * - * http://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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import com.google.common.collect.Lists; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.List; @@ -23,7 +11,7 @@ * Add this Component to any recipe prefab that is supposed to be creatable in a HerbalismStation or similar. * Include in prefab along with CraftingStationRecipeComponent to work properly. */ -public class HerbalismStationRecipeComponent implements Component { +public class HerbalismStationRecipeComponent implements Component { // The following variables are unused. public String recipeId; public List recipeComponents; @@ -35,4 +23,16 @@ public class HerbalismStationRecipeComponent implements Component { public String itemResult; public String blockResult; + + @Override + public void copy(HerbalismStationRecipeComponent other) { + this.recipeId = other.recipeId; + this.recipeComponents = Lists.newArrayList(other.recipeComponents); + this.recipeTools = Lists.newArrayList(other.recipeTools); + this.recipeFluids = Lists.newArrayList(other.recipeFluids); + this.requiredTemperature = other.requiredTemperature; + this.processingDuration = other.processingDuration; + this.itemResult = other.itemResult; + this.blockResult = other.blockResult; + } } diff --git a/src/main/java/org/terasology/herbalism/component/PollinatingHerbComponent.java b/src/main/java/org/terasology/herbalism/component/PollinatingHerbComponent.java index e1158a2..85ea399 100644 --- a/src/main/java/org/terasology/herbalism/component/PollinatingHerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/PollinatingHerbComponent.java @@ -1,24 +1,11 @@ -/* - * Copyright 2014 MovingBlocks - * - * 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 - * - * http://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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.EmptyComponent; /** * Add this component to an item (specficially an herb) to indicate that it's pollinating. */ -public class PollinatingHerbComponent implements Component { +public class PollinatingHerbComponent extends EmptyComponent { } diff --git a/src/main/java/org/terasology/herbalism/component/PredefinedHerbComponent.java b/src/main/java/org/terasology/herbalism/component/PredefinedHerbComponent.java index 84757e3..eaaf561 100644 --- a/src/main/java/org/terasology/herbalism/component/PredefinedHerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/PredefinedHerbComponent.java @@ -1,26 +1,18 @@ -/* - * Copyright 2016 MovingBlocks - * - * 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 - * - * http://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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; /** * Add this component to an item to indicate that it is a predefined herb. That is, a prefab was directly used to generate * this. */ -public final class PredefinedHerbComponent implements Component { +public final class PredefinedHerbComponent implements Component { public String herbBaseGenome; + + @Override + public void copy(PredefinedHerbComponent other) { + this.herbBaseGenome = other.herbBaseGenome; + } } From bce4c56383617f8021269f0137ad067becd0318c Mon Sep 17 00:00:00 2001 From: Tobias Nett Date: Sat, 14 Aug 2021 12:19:00 +0200 Subject: [PATCH 2/2] chore: rename copy >>> copyFrom (as per MovingBlocks/gestalt#123) --- .../terasology/herbalism/component/GeneratedHerbComponent.java | 2 +- .../org/terasology/herbalism/component/HerbHueComponent.java | 2 +- .../herbalism/component/HerbalismStationRecipeComponent.java | 2 +- .../terasology/herbalism/component/PredefinedHerbComponent.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java b/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java index a87d428..6261287 100644 --- a/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java @@ -12,7 +12,7 @@ public final class GeneratedHerbComponent implements Component { public List hueRanges; @Override - public void copy(HerbHueComponent other) { + public void copyFrom(HerbHueComponent other) { this.hueRanges = Lists.newArrayList(other.hueRanges); } } diff --git a/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java b/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java index 3725eb6..1631250 100644 --- a/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java +++ b/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java @@ -25,7 +25,7 @@ public class HerbalismStationRecipeComponent implements Component