Skip to content

Commit

Permalink
Added Shulk origin, gave particles to Enderian
Browse files Browse the repository at this point in the history
  • Loading branch information
apace100 committed Jul 29, 2020
1 parent 092ebad commit 2368fd9
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ private void modifyBlockBreakSpeed(BlockState state, PlayerEntity player, BlockV
info.setReturnValue(0F);
}
}
if(PowerTypes.STRONG_ARMS.isActive(player) && !player.inventory.getMainHandStack().isEffectiveOn(state)) {
info.setReturnValue(0.09F);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.github.apace100.origins.power.*;
import io.github.apace100.origins.registry.ModBlocks;
import io.github.apace100.origins.registry.ModComponents;
import io.github.apace100.origins.registry.ModTags;
import io.github.apace100.origins.util.Constants;
import net.minecraft.block.BlockState;
import net.minecraft.entity.*;
Expand Down Expand Up @@ -49,6 +50,23 @@ protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World
super(entityType, world);
}

// ModifyExhaustion
@ModifyVariable(at = @At("HEAD"), method = "addExhaustion", ordinal = 0, name = "exhaustion")
private float modifyExhaustion(float exhaustionIn) {
OriginComponent component = ModComponents.ORIGIN.get(this);
for (ModifyExhaustionPower p : component.getPowers(ModifyExhaustionPower.class)) {
exhaustionIn = exhaustionIn * p.value;
}
return exhaustionIn;
}

@Inject(at = @At("HEAD"), method = "isUsingEffectiveTool", cancellable = true)
private void modifyEffectiveTool(BlockState state, CallbackInfoReturnable<Boolean> info) {
if(state.getBlock().isIn(ModTags.NATURAL_STONE) && PowerTypes.STRONG_ARMS.isActive(this)) {
info.setReturnValue(true);
}
}

// ModifyDamageDealt
@ModifyVariable(method = "attack", at = @At(value = "STORE", ordinal = 0), name = "f", ordinal = 0)
public float modifyDamage(float f) {
Expand Down Expand Up @@ -114,7 +132,7 @@ private void preventArmorDispensing(ItemStack stack, CallbackInfoReturnable<Bool

// HUNGER_OVER_TIME & BURN_IN_DAYLIGHT
// WATER_BREATHING & WATER_VULNERABILITY
// PARTICLES
// PARTICLES & EXHAUSTING_WATER_BREATHING
@Inject(at = @At("TAIL"), method = "tick")
private void tick(CallbackInfo info) {
if(!world.isClient) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.github.apace100.origins.power;

import net.minecraft.entity.player.PlayerEntity;

public class HudRenderedVariableIntPower extends VariableIntPower implements HudRendered {

private final int barIndex;

public HudRenderedVariableIntPower(PowerType<?> type, PlayerEntity player, int barIndex, int startValue, int min, int max) {
super(type, player, startValue, min, max);
this.barIndex = barIndex;
}

@Override
public int getBarIndex() {
return barIndex;
}

@Override
public float getFill() {
return (this.getValue() - this.getMin()) / (float)(this.getMax() - this.getMin());
}

@Override
public boolean shouldRender() {
return true;
}
}
95 changes: 95 additions & 0 deletions src/main/java/io/github/apace100/origins/power/InventoryPower.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package io.github.apace100.origins.power;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.screen.Generic3x3ContainerScreenHandler;
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.collection.DefaultedList;

public class InventoryPower extends Power implements Active, Inventory {

private static final int SIZE = 3 * 3;
private DefaultedList<ItemStack> inventory;
private TranslatableText containerName;

public InventoryPower(PowerType<?> type, PlayerEntity player, String containerName) {
super(type, player);
this.inventory = DefaultedList.ofSize(SIZE, ItemStack.EMPTY);
this.containerName = new TranslatableText(containerName);
}

@Override
public void onUse() {
if(!player.world.isClient) {
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> {
return new Generic3x3ContainerScreenHandler(i, playerInventory, this);
}, containerName));
}
}

@Override
public Tag toTag() {
CompoundTag tag = new CompoundTag();
Inventories.toTag(tag, inventory);
return tag;
}

@Override
public void fromTag(Tag tag) {
Inventories.fromTag((CompoundTag)tag, inventory);
}

@Override
public int size() {
return SIZE;
}

@Override
public boolean isEmpty() {
return inventory.isEmpty();
}

@Override
public ItemStack getStack(int slot) {
return inventory.get(slot);
}

@Override
public ItemStack removeStack(int slot, int amount) {
return inventory.get(slot).split(amount);
}

@Override
public ItemStack removeStack(int slot) {
ItemStack stack = inventory.get(slot);
setStack(slot, ItemStack.EMPTY);
return stack;
}

@Override
public void setStack(int slot, ItemStack stack) {
inventory.set(slot, stack);
}

@Override
public void markDirty() {

}

@Override
public boolean canPlayerUse(PlayerEntity player) {
return player == this.player;
}

@Override
public void clear() {
for(int i = 0; i < SIZE; i++) {
setStack(i, ItemStack.EMPTY);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.apace100.origins.power;

import net.minecraft.entity.player.PlayerEntity;

public class ModifyExhaustionPower extends FloatPower {

public ModifyExhaustionPower(PowerType<?> type, PlayerEntity player, float exhaustionMultiplier) {
super(type, player, exhaustionMultiplier);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.github.apace100.origins.power;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.ItemStack;

import java.util.function.Function;
import java.util.function.Predicate;

public class ModifyFoodPower extends Power {

private final Predicate<ItemStack> applicableFood;
private final Function<FoodComponent, Integer> foodLevel;
private final Function<FoodComponent, Float> saturation;

public ModifyFoodPower(PowerType<?> type, PlayerEntity player, Predicate<ItemStack> applicableFood, Function<FoodComponent, Integer> additionalFood, Function<FoodComponent, Float> additionalSaturation) {
super(type, player);
this.applicableFood = applicableFood;
this.foodLevel = additionalFood;
this.saturation = additionalSaturation;
}

public boolean doesApply(ItemStack stack) {
return applicableFood.test(stack);
}

public int getFoodLevel(FoodComponent food) {
return foodLevel.apply(food);
}

public float getSaturation(FoodComponent food) {
return saturation.apply(food);
}
}
18 changes: 18 additions & 0 deletions src/main/java/io/github/apace100/origins/power/PowerTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Items;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.recipe.Ingredient;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
Expand Down Expand Up @@ -72,9 +73,17 @@ public class PowerTypes {
public static final PowerType<PreventItemUsePower> PUMPKIN_HATE;
public static final PowerType<ActiveCooldownPower> THROW_ENDER_PEARL;
public static final PowerType<AttributePower> EXTRA_REACH;
public static final PowerType<ParticlePower> ENDER_PARTICLES;

public static final PowerType<InventoryPower> INVENTORY;
public static final PowerType<AttributePower> NATURAL_ARMOR;
public static final PowerType<PreventItemUsePower> NO_SHIELD;
public static final PowerType<ModifyExhaustionPower> MORE_EXHAUSTION;
public static final PowerType<Power> STRONG_ARMS;

// Unused Powers
public static final PowerType<Power> LAVA_STRIDER;
public static final PowerType<PreventItemUsePower> NO_RANGED_WEAPONS;

static {
INVULNERABILITY = register("invulnerability", new PowerType<>(InvulnerablePower::new));
Expand Down Expand Up @@ -145,8 +154,17 @@ public class PowerTypes {
EXTRA_REACH = register("extra_reach", new PowerType<>((type, player) -> new AttributePower(type, player)
.addModifier(ReachEntityAttributes.REACH, new EntityAttributeModifier("power_type:extra_reach", 1.5, EntityAttributeModifier.Operation.ADDITION))
.addModifier(ReachEntityAttributes.ATTACK_RANGE, new EntityAttributeModifier("power_type:extra_reach", 1.5, EntityAttributeModifier.Operation.ADDITION))));
ENDER_PARTICLES = register("ender_particles", new PowerType<>((type, player) -> new ParticlePower(type, player, ParticleTypes.PORTAL, 4)).setHidden());

LAVA_STRIDER = register("lava_strider", new PowerType<>(Power::new));

INVENTORY = register("shulker_inventory", new PowerType<>((type, player) -> new InventoryPower(type, player, "container.shulker_inventory_power")));
NATURAL_ARMOR = register("natural_armor", new PowerType<>((type, player) -> new AttributePower(type, player, EntityAttributes.GENERIC_ARMOR, new EntityAttributeModifier("power_type:natural_armor", 8.0, EntityAttributeModifier.Operation.ADDITION))));
NO_SHIELD = register("no_shield", new PowerType<>((type, player) -> new PreventItemUsePower(type, player, Ingredient.ofItems(Items.SHIELD))));
MORE_EXHAUSTION = register("more_exhaustion", new PowerType<>((type, player) -> new ModifyExhaustionPower(type, player, 1.6F)));
STRONG_ARMS = register("strong_arms", new PowerType<>(Power::new));

NO_RANGED_WEAPONS = register("no_ranged_weapons", new PowerType<>((type, player) -> new PreventItemUsePower(type, player, Ingredient.fromTag(ModTags.RANGED_WEAPONS))));
}

public static void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ModTags {
public static final Tag<Item> MEAT = TagRegistry.item(new Identifier(Origins.MODID, "meat"));
public static final Tag<Block> UNPHASABLE = TagRegistry.block(new Identifier(Origins.MODID, "unphasable"));
public static final Tag<Block> NATURAL_STONE = TagRegistry.block(new Identifier(Origins.MODID, "natural_stone"));
public static final Tag<Item> RANGED_WEAPONS = TagRegistry.item(new Identifier(Origins.MODID, "ranged_weapons"));

public static void register() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.tag.FluidTags;
import net.minecraft.util.Identifier;

import java.util.List;
Expand All @@ -33,7 +34,7 @@ public void register() {
if(vehicle instanceof LivingEntity && ((LivingEntity)vehicle).getMaxHealth() > 20F) {
y -= 8;
}
if(client.player.getAir() < client.player.getMaxAir()) {
if(client.player.isSubmergedIn(FluidTags.WATER) || client.player.getAir() < client.player.getMaxAir()) {
y -= 8;
}
int barWidth = 71;
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/assets/origins/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"origin.origins.enderian.name": "Enderian",
"origin.origins.enderian.description": "Born as sons and daughters of the Ender Dragon, Enderians are capable of teleporting but are vulnerable to water.",

"origin.origins.shulk.name": "Shulk",
"origin.origins.shulk.description": "Related to Shulkers, the bodies of the Shulk are outfitted with a protective shell-like skin.",

"power.origins.water_breathing.name": "Gills",
"power.origins.water_breathing.description": "You can breathe underwater, but not on land.",

Expand Down Expand Up @@ -137,6 +140,21 @@
"power.origins.extra_reach.name": "Slender Body",
"power.origins.extra_reach.description": "You can reach blocks and entities further away.",

"power.origins.shulker_inventory.name": "Hoarder",
"power.origins.shulker_inventory.description": "You have access to an additional 9 slots of inventory, which keep the items on death.",

"power.origins.natural_armor.name": "Sturdy Skin",
"power.origins.natural_armor.description": "Even without wearing armor, your skin provides natural protection.",

"power.origins.more_exhaustion.name": "Large appetite",
"power.origins.more_exhaustion.description": "You exhaust much quicker than others, thus requiring you to eat more.",

"power.origins.no_shield.name": "Unwieldy",
"power.origins.no_shield.description": "The way your hands are formed provide no way of holding a shield upright.",

"power.origins.strong_arms.name": "Strong Arms",
"power.origins.strong_arms.description": "You are strong enough to break natural stones without using a pickaxe.",

"category.origins": "Origins",
"key.origins.active_power": "Active Power",
"key.origins.view_origin": "View Origin",
Expand All @@ -145,6 +163,8 @@

"enchantment.origins.water_protection": "Water Protection",

"container.shulker_inventory_power": "Shulker Inventory",

"origins.gui.select": "Select",
"origins.gui.close": "Close",
"origins.gui.choose_origin.title": "Choose your Origin",
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/data/origins/origins/enderian.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"origins:throw_ender_pearl",
"origins:water_vulnerability",
"origins:pumpkin_hate",
"origins:extra_reach"
"origins:extra_reach",
"origins:ender_particles"
],
"icon": "minecraft:ender_pearl",
"order": 1,
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/data/origins/origins/shulk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"powers": [
"origins:shulker_inventory",
"origins:natural_armor",
"origins:strong_arms",
"origins:no_shield",
"origins:more_exhaustion"
],
"icon": "minecraft:shulker_shell",
"order": 4,
"impact": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"minecraft:bow",
"minecraft:crossbow",
"minecraft:trident"
]
}

0 comments on commit 2368fd9

Please sign in to comment.