Skip to content

Commit

Permalink
Merge pull request #13 from UselessBullets/1.7.7.x
Browse files Browse the repository at this point in the history
Fixed fire projectile the best I can
  • Loading branch information
mizuri-n authored Oct 24, 2024
2 parents ceed76b + 2450df0 commit d35882b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

//Special thanks to UselessBullets for being extremely awesome https://github.com/UselessBullets/Lunacy/tree/7.1
//Mixin for custom recipe colors.
public class recipeColor extends RecipeEntryCraftingDynamic {
public class RecipeColor extends RecipeEntryCraftingDynamic {
public static boolean nonamedyesOn = ModVersionHelper.isModPresent("nonamedyes");

public static HashMap<Item, Map<Integer, Color>> dyeMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import mizurin.shieldmod.item.Shields;


public class recipes implements RecipeEntrypoint {
public class Recipes implements RecipeEntrypoint {
public static final String MOD_ID = ShieldMod.MOD_ID;
public static final RecipeGroup<RecipeEntryCrafting<?, ?>> WORKBENCH = new RecipeGroup<>(new RecipeSymbol(new ItemStack(Block.workbench)));

Expand Down Expand Up @@ -98,8 +98,8 @@ public void onRecipesReady() {
WORKBENCH.register("rockyHelmetHat", new RecipeEntryRepairable(Shields.rockyHelmet, Block.cobbleStone.asItem()));
}
public void initializeRecipe(){
Registries.RECIPE_TYPES.register("colored/shield", recipeColor.class);
WORKBENCH.register("leather", new recipeColor());
Registries.RECIPE_TYPES.register("colored/shield", RecipeColor.class);
WORKBENCH.register("leather", new RecipeColor());
}
}

Expand Down
10 changes: 1 addition & 9 deletions src/main/java/mizurin/shieldmod/ShieldMod.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package mizurin.shieldmod;

import com.mojang.nbt.CompoundTag;
import mizurin.shieldmod.entities.*;
import mizurin.shieldmod.item.ArmorColored;
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.render.colorizer.Colorizers;
import net.minecraft.client.render.entity.SnowballRenderer;
import net.minecraft.core.block.Block;
import net.minecraft.core.crafting.LookupFuelFurnace;
import net.minecraft.core.data.registry.recipe.SearchQuery;
import net.minecraft.core.data.registry.recipe.entry.RecipeEntryCraftingDynamic;
import net.minecraft.core.enums.ArtType;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemDye;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.net.entity.NetEntityHandler;
import net.minecraft.core.player.inventory.InventoryCrafting;
import net.minecraft.core.util.helper.Color;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import turniplabs.halplibe.helper.EntityHelper;
Expand Down Expand Up @@ -74,7 +66,7 @@ public void beforeGameStart() {
@Override
public void afterGameStart() {
LookupFuelFurnace.instance.addFuelEntry(Shields.woodenShield.id, 600);
new recipes().initializeRecipe();
new Recipes().initializeRecipe();
LOGGER.info("RF initialized");
}

Expand Down
31 changes: 24 additions & 7 deletions src/main/java/mizurin/shieldmod/entities/EntityFire.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@
import net.minecraft.core.world.World;

public class EntityFire extends EntityProjectile {

public EntityFire(World world) {
super(world);
this.modelItem = Item.ammoFireball;
}

public EntityFire(World world, EntityLiving entityliving){
super(world, entityliving);
this.modelItem = Item.ammoFireball;
}
public EntityFire(World world, double d, double d1, double d2){
super(world, d, d1, d2);
public EntityFire(World world, double x, double y, double z){
super(world, x, y, z);
this.modelItem = Item.ammoFireball;
}

public EntityFire(World world, double x, double y, double z, double xd, double yd, double zd){
super(world, x, y, z);
this.modelItem = Item.ammoFireball;
this.xd = xd;
this.yd = yd;
this.zd = zd;
}

public void init() {
Expand Down Expand Up @@ -51,13 +65,16 @@ protected void checkOnWater(boolean addVelocity) {
public void tick() {
super.tick();

this.xd *= 7.5;
this.yd *= 7.5;
this.zd *= 7.5;
if (!world.isClientSide) {
this.xd *= 7.5;
this.yd *= 7.5;
this.zd *= 7.5;

if(this.tickCount > 8){
this.remove();
if(this.tickCount > 8){
this.remove();
}
}

if(this.tickCount > 1) {
world.spawnParticle("flame", this.x, this.y, this.z, this.random.nextFloat()*.1, this.random.nextFloat()*.1, this.random.nextFloat()*.1, 0);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/mizurin/shieldmod/entities/NetFireEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public void onEntityTracked(EntityTracker tracker, EntityTrackerEntry trackerEnt

@Override
public Entity getEntity(World world, double x, double y, double z, int metadata, boolean hasVelocity, double xd, double yd, double zd, Entity owner) {
EntityFire fire = new EntityFire(world, x, y, z, xd, yd, zd);
if (owner instanceof EntityLiving) {
return new EntityFire(world, (EntityLiving) owner);
} else {
return new EntityFire(world, x, y, z);
fire.owner = (EntityLiving) owner;
}
return fire;
}

@Override
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/mizurin/shieldmod/item/SteelShield.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ public void onBlock(ItemStack itemstack, World world, EntityPlayer entityplayer)
if (entityplayer.isSneaking() && ((ParryInterface)entityplayer).shieldmod$getFireTicks() == 0){
if(entityplayer.inventory.consumeInventoryItem(Item.flint.id)){
itemstack.damageItem(4, entityplayer);
for (int i = 4; i != 0; i--) {
for (int i = 0; i < 4; i++) {
Vec3d plylook = entityplayer.getLookAngle();
EntityFire flame = new EntityFire(world, entityplayer);
if (!world.isClientSide) {
world.entityJoinedWorld(flame);

flame.setHeading(flame.xd, flame.yd, flame.zd, .55f, 10);
double newX = flame.x + plylook.xCoord * .5;
double newY = flame.y + plylook.yCoord * .5;
double newZ = flame.z + plylook.zCoord * .5;
flame.setHeading(plylook.xCoord, plylook.yCoord, plylook.zCoord, .5f, 10);
}
}
world.playSoundAtEntity(entityplayer, entityplayer, "fire.ignite", 3.6F, 1.5F);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mizurin/shieldmod/mixins/WorldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ public EntityPlayer getClosestPlayer(double x, double y, double z, double radius
entityplayer = entityPlayer1;
}
} else {
double armorTotal = 16;
double rSquared = radius * radius;
for (EntityPlayer entityPlayer1 : thisObject.players) {
double armorTotal = 16;
double currentDistance = entityPlayer1.distanceToSqr(x, y, z);
if (!(currentDistance < rSquared) || !(currentDistance < closestDistance)) continue;
closestDistance = currentDistance;

boolean plyInvis = false;

Expand All @@ -62,6 +61,7 @@ public EntityPlayer getClosestPlayer(double x, double y, double z, double radius

if(plyInvis & currentDistance < rThirdSquared || !plyInvis){
entityplayer = entityPlayer1;
closestDistance = currentDistance;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"mizurin.shieldmod.ShieldMod"
],
"recipesReady": [
"mizurin.shieldmod.recipes"
"mizurin.shieldmod.Recipes"
]
},
"mixins": [
Expand Down

0 comments on commit d35882b

Please sign in to comment.