Skip to content

Commit

Permalink
Merge pull request #181 from Shnupbups/master
Browse files Browse the repository at this point in the history
Stuff
  • Loading branch information
Shnupbups authored Nov 10, 2019
2 parents 1971e6a + 6e8a687 commit cf20b49
Show file tree
Hide file tree
Showing 28 changed files with 213 additions and 125 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ dependencies {
modImplementation("com.github.emilyploszaj:trinkets:${trinkets_version}") {
transitive = false
}
include "com.github.emilyploszaj:trinkets:${trinkets_version}"

modImplementation "com.github.indi-code:TinyConfig:${project.tiny_config_version}"//"io.github.indicode.fabric:tinyconfig:${project.tiny_config_version}"
include "com.github.indi-code:TinyConfig:${project.tiny_config_version}"//"io.github.indicode.fabric:tinyconfig:${project.tiny_config_version}"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fabric_version=0.4.0+build.240-1.14

maven_group=fabric-community
archives_base_name=TheHallow
mod_version=1.0.0-beta
mod_version=1.1.0-beta

license_header=MIT

Expand Down
8 changes: 2 additions & 6 deletions src/main/java/com/fabriccommunity/thehallow/TheHallow.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import com.fabriccommunity.thehallow.registry.HallowedRecipes;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;

import com.fabriccommunity.thehallow.registry.HallowedBiomes;
import com.fabriccommunity.thehallow.registry.HallowedBlockEntities;
import com.fabriccommunity.thehallow.registry.HallowedBlocks;
Expand All @@ -19,7 +17,6 @@
import com.fabriccommunity.thehallow.registry.HallowedEntities;
import com.fabriccommunity.thehallow.registry.HallowedEvents;
import com.fabriccommunity.thehallow.registry.HallowedFeatures;
import com.fabriccommunity.thehallow.registry.HallowedFluidTags;
import com.fabriccommunity.thehallow.registry.HallowedFluids;
import com.fabriccommunity.thehallow.registry.HallowedItems;
import com.fabriccommunity.thehallow.registry.HallowedNetworking;
Expand All @@ -37,8 +34,8 @@ public class TheHallow implements ModInitializer {
public static final ItemGroup GROUP = FabricItemGroupBuilder.build(id("group"), () -> new ItemStack(HallowedItems.REAPERS_SCYTHE));
public static final ItemGroup PUMPKINS = FabricItemGroupBuilder.build(id("pumpkins"), () -> new ItemStack(HallowedBlocks.WITCHED_PUMPKIN));

public static Identifier id(String key) {
return new Identifier(MOD_ID, key);
public static Identifier id(String name) {
return new Identifier(MOD_ID, name);
}

@Override
Expand All @@ -59,7 +56,6 @@ public void onInitialize() {
HallowedEvents.init();
HallowedSounds.init();
HallowedFluids.init();
HallowedFluidTags.init();
HallowedTags.init();
HallowedNetworking.init();
HallowedEvents.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import net.minecraft.world.World;

import com.fabriccommunity.thehallow.registry.HallowedBlocks;
import com.fabriccommunity.thehallow.registry.HallowedFluidTags;
import com.fabriccommunity.thehallow.registry.HallowedTags;

import java.util.Random;

Expand All @@ -39,7 +39,7 @@ public BlockState getStateForNeighborUpdate(BlockState state, Direction dir, Blo
@Override
public void onRandomTick(BlockState state, World world, BlockPos pos1, Random rand) {
BlockPos pos2 = pos1.up();
if (world.getFluidState(pos1).matches(HallowedFluidTags.WITCH_WATER)) {
if (world.getFluidState(pos1).matches(HallowedTags.Fluids.WITCH_WATER)) {
world.playSound(null, pos1, SoundEvents.ENTITY_DROWNED_HURT_WATER, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
if (world instanceof ServerWorld) {
((ServerWorld) world).spawnParticles(ParticleTypes.CURRENT_DOWN, (double) pos2.getX() + 0.5D, (double) pos2.getY() + 0.25D, (double) pos2.getZ() + 0.5D, 8, 0.5D, 0.25D, 0.5D, 0.0D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
import com.fabriccommunity.thehallow.registry.HallowedEntities;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;

import net.minecraft.block.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ProjectileUtil;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Packet;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RayTraceContext;
Expand All @@ -24,8 +31,12 @@ public class ShotgunProjectileEntity extends Entity {

public Entity owner;

public float damage = 5.0f;
public int lifetime = 40; // ticks to live before despawn, in this case 2 seconds til despawn
public static final int DEFAULT_LIFETIME = 40; // ticks to live before despawn, in this case 2 seconds til despawn
public static final float DEFAULT_DAMAGE = 5.0f;

public static final TrackedData<Float> DAMAGE = DataTracker.registerData(ShotgunProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
public static final TrackedData<Integer> AGE = DataTracker.registerData(ShotgunProjectileEntity.class, TrackedDataHandlerRegistry.INTEGER);
public static final TrackedData<Integer> LIFETIME = DataTracker.registerData(ShotgunProjectileEntity.class, TrackedDataHandlerRegistry.INTEGER);

public ShotgunProjectileEntity(EntityType<? extends ShotgunProjectileEntity> entityType, World world) {
super(entityType, world);
Expand All @@ -43,7 +54,7 @@ public ShotgunProjectileEntity(World world, Entity owner, double x, double y, do
double velX, double velY, double velZ) {
super(HallowedEntities.SHOTGUN_PROJECTILE, world);

this.owner = owner;
this.setOwner(owner);
setPositionAndAngles(x, y, z, yaw, pitch);
setVelocity(velX + random.nextGaussian() * 0.05f, velY + random.nextGaussian() * 0.05f, velZ + random.nextGaussian() * 0.05f);

Expand All @@ -59,25 +70,22 @@ public void tick() {
this.prevRenderY = y;
this.prevRenderZ = z;

if (lifetime > 0) {
lifetime--;
} else {
remove();
}
this.age();

Box box = getBoundingBox().stretch(getVelocity()).expand(1.0d);

HitResult hitResult = ProjectileUtil.getCollision(this, box, entity -> !entity.isSpectator() && entity.collides(), RayTraceContext.ShapeType.OUTLINE, true);
HitResult hitResult = this.getCollision();

HitResult.Type type = hitResult.getType();
if (type != HitResult.Type.MISS) {
if (type == HitResult.Type.BLOCK) {
remove();
} else if (type == HitResult.Type.ENTITY) {
if (type == HitResult.Type.ENTITY) {
Entity hitEntity = ((EntityHitResult) hitResult).getEntity();
hitEntity.damage(DamageSource.GENERIC, damage);
remove();
hitEntity.damage(DamageSource.GENERIC, getDamage());
} else if(type == HitResult.Type.BLOCK) {
BlockPos hitPos = ((BlockHitResult) hitResult).getBlockPos();
if (world.getBlockState(hitPos).getMaterial() == Material.GLASS) {
world.breakBlock(hitPos, false);
}
}
remove();
}

Vec3d vel = getVelocity();
Expand All @@ -96,14 +104,29 @@ public void tick() {

@Override
protected void initDataTracker() {
this.dataTracker.startTracking(DAMAGE, DEFAULT_DAMAGE);
this.dataTracker.startTracking(AGE, 0);
this.dataTracker.startTracking(LIFETIME, DEFAULT_LIFETIME);
}

@Override
protected void readCustomDataFromTag(CompoundTag compoundTag) {
if(compoundTag.containsKey("damage")) {
this.setDamage(compoundTag.getFloat("damage"));
}
if(compoundTag.containsKey("age")) {
this.setAge(compoundTag.getInt("age"));
}
if(compoundTag.containsKey("lifetime")) {
this.setLifetime(compoundTag.getInt("lifetime"));
}
}

@Override
protected void writeCustomDataToTag(CompoundTag compoundTag) {
compoundTag.putFloat("damage", this.getDamage());
compoundTag.putInt("age", this.getAge());
compoundTag.putInt("lifetime", this.getLifetime());
}

@Override
Expand All @@ -122,9 +145,66 @@ public Packet<?> createSpawnPacket() {
packet.writeDouble(vel.y);
packet.writeDouble(vel.z);

packet.writeInt(owner.getEntityId());
packet.writeInt(getOwner().getEntityId());
packet.writeInt(getEntityId());

return ServerSidePacketRegistry.INSTANCE.toPacket(ENTITY_ID, packet);
}

public void age() {
this.setAge(this.getAge()+1);
if(getAge() > getLifetime()) {
remove();
}
}

public int getAge() {
return this.dataTracker.get(AGE);
}

public Entity getOwner() {
return owner;
}

public int getLifetime() {
return this.dataTracker.get(LIFETIME);
}

public float getDamage() {
return this.dataTracker.get(DAMAGE);
}

public ShotgunProjectileEntity setAge(int age) {
this.dataTracker.set(AGE, age);
return this;
}

public ShotgunProjectileEntity setDamage(float damage) {
this.dataTracker.set(DAMAGE, damage);
return this;
}

public ShotgunProjectileEntity setOwner(Entity owner) {
this.owner = owner;
return this;
}

public ShotgunProjectileEntity setLifetime(int lifetime) {
this.dataTracker.set(LIFETIME, lifetime);
return this;
}

public HitResult getCollision() {
return ProjectileUtil.getCollision(this, this.getBoundingBox().stretch(this.getVelocity()).expand(1.0D), (entity) -> !entity.isSpectator() && entity.isAlive() && entity.collides() && entity != this.getOwner(), RayTraceContext.ShapeType.OUTLINE, true);
}

@Override
public boolean isAttackable() {
return false;
}

@Override
protected boolean canClimb() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import net.minecraft.world.ViewableWorld;

import com.fabriccommunity.thehallow.registry.HallowedBlocks;
import com.fabriccommunity.thehallow.registry.HallowedFluidTags;
import com.fabriccommunity.thehallow.registry.HallowedFluids;
import com.fabriccommunity.thehallow.registry.HallowedItems;
import com.fabriccommunity.thehallow.registry.HallowedTags;

public class BloodFluid extends BaseFluid {
@Override
Expand Down Expand Up @@ -60,7 +60,7 @@ public ParticleEffect getParticle() {

@Override
public boolean method_15777(FluidState fluidState, BlockView blockView, BlockPos blockPos, Fluid fluid, Direction direction) {
return direction == Direction.DOWN && !fluid.matches(HallowedFluidTags.BLOOD);
return direction == Direction.DOWN && !fluid.matches(HallowedTags.Fluids.BLOOD);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import net.minecraft.world.World;

import com.fabriccommunity.thehallow.registry.HallowedBlocks;
import com.fabriccommunity.thehallow.registry.HallowedFluidTags;
import com.fabriccommunity.thehallow.registry.HallowedFluids;
import com.fabriccommunity.thehallow.registry.HallowedItems;
import com.fabriccommunity.thehallow.registry.HallowedTags;

import java.util.Random;

Expand Down Expand Up @@ -63,7 +63,7 @@ public ParticleEffect getParticle() {

@Override
public boolean method_15777(FluidState fluidState, BlockView blockView, BlockPos blockPos, Fluid fluid, Direction direction) {
return direction == Direction.DOWN && !fluid.matches(HallowedFluidTags.WITCH_WATER);
return direction == Direction.DOWN && !fluid.matches(HallowedTags.Fluids.WITCH_WATER);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand h

@Override
public void appendTooltip(ItemStack itemStack, World world, List<Text> list, TooltipContext tooltipContext) {
String translatedTooltip = new TranslatableText("tooltip.thehallow.paper_bag").asString();
String translatedTooltip = new TranslatableText("text.thehallow.paper_bag").asString();
String[] translatedTooltipWords = translatedTooltip.split(" ");

StringBuilder tooltipBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand h

@Override
public void appendTooltip(ItemStack itemStack, World world, List<Text> list, TooltipContext context) {
list.add(new TranslatableText("tooltip.thehallow.pumpkin_ring").formatted(Formatting.GRAY));
list.add(new TranslatableText("text.thehallow.pumpkin_ring").formatted(Formatting.GRAY));
super.appendTooltip(itemStack, world, list, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private void addPumpkinRingBonus(World world, ItemStack itemStack, CallbackInfoR

if (mainHandStack.getItem().equals(HallowedItems.PUMPKIN_RING) || offHandStack.getItem().equals(HallowedItems.PUMPKIN_RING)) {
if (item.isFood()) {
if (item.isIn(HallowedTags.PUMPKIN_FOODS)) {
if (item.isIn(HallowedTags.Items.PUMPKIN_FOODS)) {
FoodComponent foodComponent = item.getFoodComponent();
int extraHunger = (int) Math.ceil(foodComponent.getHunger() * .25);
this.hungerManager.add(extraHunger, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void init() {
if (!witch.hasStatusEffect(StatusEffects.WATER_BREATHING)) {
if (witch.getEntityWorld().hasRain(witch.getBlockPos().up())) {
witch.damage(DamageSource.DROWN, 4.0F);
} else if (witch.checkWaterState() && !witch.updateMovementInFluid(HallowedFluidTags.WITCH_WATER)) {
} else if (witch.checkWaterState() && !witch.updateMovementInFluid(HallowedTags.Fluids.WITCH_WATER)) {
witch.damage(DamageSource.DROWN, 4.0F);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import com.fabriccommunity.thehallow.TheHallow;

public class HallowedSounds {
public static final SoundEvent DOOT = register("doot");
public static final SoundEvent MEGALADOOT = register("megaladoot");
public static final SoundEvent SHOTGUN_SHOT = register("shotgun_shot");
public static final SoundEvent SHOTGUN_NO_AMMO = register("shotgun_no_ammo");
public static final SoundEvent SHOTGUN_SHELL_RELOAD = register("shotgun_shell_reload");
public static final SoundEvent DOOT = register("trumpet.doot");
public static final SoundEvent MEGALADOOT = register("trumpet.megaladoot");
public static final SoundEvent SHOTGUN_SHOT = register("shotgun.shot");
public static final SoundEvent SHOTGUN_NO_AMMO = register("shotgun.no_ammo");
public static final SoundEvent SHOTGUN_SHELL_RELOAD = register("shotgun.shell_reload");
public static final SoundEvent CROW_AMBIENT = register("entity.crow.ambient");

private HallowedSounds() {
Expand Down
Loading

0 comments on commit cf20b49

Please sign in to comment.