Skip to content

Commit

Permalink
Added new advancements and stuff
Browse files Browse the repository at this point in the history
Fixed Rocket Launch criterion not being triggered
Added Rocket Destroy criterion and an advancement using it
Added an advancement for eating a Lead Apple
Added non US English
  • Loading branch information
Shnupbups committed Oct 12, 2020
1 parent cebf3e0 commit 6512188
Show file tree
Hide file tree
Showing 11 changed files with 4,292 additions and 9 deletions.
1,030 changes: 1,030 additions & 0 deletions astromine-core/src/main/resources/assets/astromine/lang/en_au.json

Large diffs are not rendered by default.

1,030 changes: 1,030 additions & 0 deletions astromine-core/src/main/resources/assets/astromine/lang/en_ca.json

Large diffs are not rendered by default.

1,030 changes: 1,030 additions & 0 deletions astromine-core/src/main/resources/assets/astromine/lang/en_gb.json

Large diffs are not rendered by default.

1,030 changes: 1,030 additions & 0 deletions astromine-core/src/main/resources/assets/astromine/lang/en_nz.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1026,5 +1026,9 @@
"advancements.astromine.get_advanced_circuit.title": "Super Circuit Maker",
"advancements.astromine.get_advanced_circuit.description": "Craft an Advanced Circuit",
"advancements.astromine.get_elite_circuit.title": "New Super Circuit Maker U Deluxe",
"advancements.astromine.get_elite_circuit.description": "Craft an Elite Circuit"
"advancements.astromine.get_elite_circuit.description": "Craft an Elite Circuit",
"advancements.astromine.destroy_rocket.title": "We Have a Problem",
"advancements.astromine.destroy_rocket.description": "Have a Rocket you're riding experience rapid unscheduled disassembly",
"advancements.astromine.eat_lead_apple.title": "Why Would You Do That?",
"advancements.astromine.eat_lead_apple.description": "Get lead poisoning by ingesting a Lead Apple"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* MIT License
*
* Copyright (c) 2020 Chainmail Studios
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.github.chainmailstudios.astromine.discoveries.common.advancement;

import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
import net.minecraft.predicate.entity.EntityPredicate;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;

import com.github.chainmailstudios.astromine.discoveries.registry.AstromineDiscoveriesCriteria;

import com.google.gson.JsonObject;

public class DestroyRocketCriterion extends AbstractCriterion<DestroyRocketCriterion.Conditions> {
public final Identifier id;

public DestroyRocketCriterion(Identifier id) {
this.id = id;
}

@Override
protected DestroyRocketCriterion.Conditions conditionsFromJson(JsonObject obj, EntityPredicate.Extended playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
if(obj.has("intentional")) return new Conditions(this.id, playerPredicate, obj.get("intentional").getAsBoolean());
else return new Conditions(this.id, playerPredicate);
}

@Override
public Identifier getId() {
return id;
}

public void trigger(ServerPlayerEntity player, boolean intentional) {
this.test(player, conditions -> conditions.matches(intentional));
}

public static class Conditions extends AbstractCriterionConditions {
private final Boolean intentional;

public Conditions(Identifier id, EntityPredicate.Extended playerPredicate, Boolean intentional) {
super(id, playerPredicate);
this.intentional = intentional;
}

public Conditions(Identifier id, EntityPredicate.Extended playerPredicate) {
super(id, playerPredicate);
this.intentional = null;
}

public boolean matches(boolean intentional) {
return intentional() == null || intentional == intentional();
}

public Boolean intentional() {
return intentional;
}

public static Conditions create(boolean intentional) {
return new Conditions(AstromineDiscoveriesCriteria.DESTROY_ROCKET.getId(), EntityPredicate.Extended.EMPTY, intentional);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.minecraft.item.BucketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Arm;
Expand All @@ -51,6 +52,7 @@
import com.github.chainmailstudios.astromine.common.volume.fraction.Fraction;
import com.github.chainmailstudios.astromine.common.volume.handler.FluidHandler;
import com.github.chainmailstudios.astromine.common.volume.handler.ItemHandler;
import com.github.chainmailstudios.astromine.discoveries.registry.AstromineDiscoveriesCriteria;
import com.github.chainmailstudios.astromine.discoveries.registry.AstromineDiscoveriesParticles;
import org.joml.Vector3d;
import org.joml.Vector3f;
Expand Down Expand Up @@ -108,7 +110,7 @@ public void tick() {
if (tank.isEmpty() && !world.isClient) {
this.world.getPlayers().forEach(player -> player.sendMessage(new TranslatableText("text.astromine.rocket.disassemble_empty_fuel").formatted(Formatting.RED), false));

this.tryDisassemble();
this.tryDisassemble(false);
} else {
Vector3d acceleration = accelerationFunction.apply(this);

Expand All @@ -131,12 +133,12 @@ public void tick() {
if (BlockPos.Mutable.method_29715(getBoundingBox()).anyMatch(pos -> world.getBlockState(pos).isFullCube(world, pos)) && !world.isClient) {
this.world.getPlayers().forEach(player -> player.sendMessage(new TranslatableText("text.astromine.rocket.disassemble_collision").formatted(Formatting.RED), false));

this.tryDisassemble();
this.tryDisassemble(false);
}
} else if (!world.isClient) {
this.world.getPlayers().forEach(player -> player.sendMessage(new TranslatableText("text.astromine.rocket.disassemble_invalid_fuel").formatted(Formatting.RED), false));

this.tryDisassemble();
this.tryDisassemble(false);
}
} else {
setVelocity(Vec3d.ZERO);
Expand Down Expand Up @@ -190,10 +192,16 @@ private FluidVolume getTank() {
return getFluidComponent().getVolume(0);
}

public void tryDisassemble() {
public void tryDisassemble(boolean intentional) {
this.tryExplode();
this.explosionRemains.forEach(stack -> ItemScatterer.spawn(world, getX(), getY(), getZ(), stack.copy()));
this.getPassengersDeep().forEach(Entity::stopRiding);
Collection<Entity> passengers = this.getPassengersDeep();
for(Entity passenger:passengers) {
if (passenger instanceof ServerPlayerEntity) {
AstromineDiscoveriesCriteria.DESTROY_ROCKET.trigger((ServerPlayerEntity) passenger, intentional);
}
passenger.stopRiding();
}
this.remove();
}

Expand All @@ -207,4 +215,13 @@ public Vec3d updatePassengerForDismount(LivingEntity passenger) {
}

public abstract void openInventory(PlayerEntity player);

public void tryLaunch(PlayerEntity launcher) {
if (this.getFluidComponent().getVolume(0).biggerThan(Fraction.empty())) {
this.getDataTracker().set(RocketEntity.IS_RUNNING, true);
if(launcher instanceof ServerPlayerEntity) {
AstromineDiscoveriesCriteria.LAUNCH_ROCKET.trigger((ServerPlayerEntity) launcher);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public void initialize(int width, int height) {
super.initialize(width, height);

ButtonWidget launchButtonWidget = new ButtonWidget(() -> {
if (entity.getFluidComponent().getVolume(0).biggerThan(Fraction.empty()))
entity.getDataTracker().set(RocketEntity.IS_RUNNING, true);
((RocketEntity) entity).tryLaunch(this.getPlayer());

return null;
});
Expand All @@ -70,7 +69,7 @@ public void initialize(int width, int height) {
launchButtonWidget.setDisabled(() -> entity.getDataTracker().get(RocketEntity.IS_RUNNING) || entity.getFluidComponent().getVolume(0).smallerOrEqualThan(Fraction.empty()));

ButtonWidget abortButtonWidget = new ButtonWidget(() -> {
((RocketEntity) entity).tryDisassemble();
((RocketEntity) entity).tryDisassemble(true);

return null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
package com.github.chainmailstudios.astromine.discoveries.registry;

import com.github.chainmailstudios.astromine.AstromineCommon;
import com.github.chainmailstudios.astromine.discoveries.common.advancement.DestroyRocketCriterion;
import com.github.chainmailstudios.astromine.discoveries.common.advancement.LaunchRocketCriterion;
import com.github.chainmailstudios.astromine.registry.AstromineCriteria;

public class AstromineDiscoveriesCriteria extends AstromineCriteria {
public static final LaunchRocketCriterion LAUNCH_ROCKET = register(new LaunchRocketCriterion(AstromineCommon.identifier("launch_rocket")));
public static final DestroyRocketCriterion DESTROY_ROCKET = register(new DestroyRocketCriterion(AstromineCommon.identifier("destroy_rocket")));

public static void initialize() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parent": "astromine:astromine/launch_rocket",
"display": {
"icon": {
"item": "astromine:rocket"
},
"title": {
"translate": "advancements.astromine.destroy_rocket.title"
},
"description": {
"translate": "advancements.astromine.destroy_rocket.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"destroy_rocket": {
"trigger": "astromine:destroy_rocket",
"conditions": {
"intentional": false
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"parent": "astromine:astromine/root",
"display": {
"icon": {
"item": "astromine:lead_apple"
},
"title": {
"translate": "advancements.astromine.eat_lead_apple.title"
},
"description": {
"translate": "advancements.astromine.eat_lead_apple.description"
},
"frame": "task",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"criteria": {
"eat_lead_apple": {
"trigger": "minecraft:consume_item",
"conditions": {
"items": [
{
"item": "astromine:lead_apple"
}
]
}
}
}
}

0 comments on commit 6512188

Please sign in to comment.