-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9bcaae
commit 8568c0b
Showing
24 changed files
with
338 additions
and
23 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// 1.19.2 2024-04-23T16:27:26.7336147 Language | ||
d04d40d92f525332cba17675dca053783f282d5b assets\the_origin_of_magic\lang\en_us.json | ||
// 1.19.2 2024-04-23T22:39:15.7231787 Language | ||
7cd0c9ec37de0a8d5af1a51cd38da5908dffbc8b assets\the_origin_of_magic\lang\en_us.json |
2 changes: 1 addition & 1 deletion
2
src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// 1.19.2 2024-04-23T16:27:26.736128 Block Loot Tables | ||
// 1.19.2 2024-04-23T22:39:15.7256416 Block Loot Tables | ||
fe57f13449a11436bbede8c37e01bd0d1cd87191 data\the_origin_of_magic\loot_tables\blocks\magic_workbench.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/RayMagic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
package com.ictye.the_origin_of_magic.foundation.Entitys.Magics; | ||
|
||
import com.google.common.collect.Sets; | ||
import com.ictye.the_origin_of_magic.Contents.AllItem; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.data.DataTracker; | ||
import net.minecraft.entity.data.TrackedData; | ||
import net.minecraft.entity.data.TrackedDataHandlerRegistry; | ||
import net.minecraft.entity.effect.StatusEffectInstance; | ||
import net.minecraft.entity.projectile.thrown.ThrownEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.nbt.NbtElement; | ||
import net.minecraft.nbt.NbtList; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.potion.Potion; | ||
import net.minecraft.potion.PotionUtil; | ||
import net.minecraft.potion.Potions; | ||
import net.minecraft.util.hit.EntityHitResult; | ||
import net.minecraft.util.registry.Registry; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class RayMagic extends StdThrownMagic{ | ||
private static final TrackedData<Integer> COLOR = DataTracker.registerData(RayMagic.class, TrackedDataHandlerRegistry.INTEGER); | ||
private boolean colorSet; | ||
private Potion potion = Potions.EMPTY; | ||
private final Set<StatusEffectInstance> effects = Sets.newHashSet(); | ||
|
||
public RayMagic(EntityType<? extends ThrownEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
|
||
public RayMagic(EntityType<? extends ThrownEntity> type, LivingEntity owner, World world, float explosionRate, int ageRate) { | ||
super(type, owner, world, explosionRate, ageRate); | ||
} | ||
|
||
public RayMagic(EntityType<? extends ThrownEntity> type, LivingEntity owner, World world, float explosionRate, int ageRate, ItemStack stack) { | ||
super(type, owner, world, explosionRate, ageRate); | ||
if (stack.isOf(AllItem.RAY_MAGIC_ITEM)) { | ||
int i; | ||
this.potion = PotionUtil.getPotion(stack); | ||
List<StatusEffectInstance> collection = PotionUtil.getCustomPotionEffects(stack); | ||
if (!collection.isEmpty()) { | ||
for (StatusEffectInstance statusEffectInstance : collection) { | ||
this.effects.add(new StatusEffectInstance(statusEffectInstance)); | ||
} | ||
} | ||
if ((i = RayMagic.getCustomPotionColor(stack)) == -1) { | ||
this.initColor(); | ||
} else { | ||
this.setColor(i); | ||
} | ||
} else { | ||
this.potion = Potions.EMPTY; | ||
this.effects.clear(); | ||
this.dataTracker.set(COLOR, -1); | ||
} | ||
} | ||
|
||
public static int getCustomPotionColor(ItemStack stack) { | ||
NbtCompound nbtCompound = stack.getNbt(); | ||
if (nbtCompound != null && nbtCompound.contains("CustomPotionColor", NbtElement.NUMBER_TYPE)) { | ||
return nbtCompound.getInt("CustomPotionColor"); | ||
} | ||
return -1; | ||
} | ||
|
||
@Override | ||
protected void initDataTracker() { | ||
super.initDataTracker(); | ||
this.dataTracker.startTracking(COLOR, -1); | ||
} | ||
|
||
public int getColor() { | ||
return this.dataTracker.get(COLOR); | ||
} | ||
|
||
private void setColor(int color) { | ||
this.colorSet = true; | ||
this.dataTracker.set(COLOR, color); | ||
} | ||
|
||
@Override | ||
protected float getGravity() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
protected void onEntityHit(EntityHitResult entityHitResult) { | ||
LivingEntity target = (LivingEntity) entityHitResult.getEntity(); | ||
Entity entity = this.getEffectCause(); | ||
for (StatusEffectInstance statusEffectInstance : this.potion.getEffects()) { | ||
target.addStatusEffect(new StatusEffectInstance(statusEffectInstance.getEffectType(), Math.max(statusEffectInstance.getDuration() / 8, 1), statusEffectInstance.getAmplifier(), statusEffectInstance.isAmbient(), statusEffectInstance.shouldShowParticles()), entity); | ||
} | ||
if (!this.effects.isEmpty()) { | ||
for (StatusEffectInstance statusEffectInstance : this.effects) { | ||
target.addStatusEffect(statusEffectInstance, entity); | ||
} | ||
} | ||
|
||
super.onEntityHit(entityHitResult); | ||
this.remove(RemovalReason.CHANGED_DIMENSION); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
int i = this.getColor(); | ||
double d = (double)(i >> 16 & 0xFF) / 255.0; | ||
double e = (double)(i >> 8 & 0xFF) / 255.0; | ||
double f = (double)(i >> 0 & 0xFF) / 255.0; | ||
this.world.addParticle(ParticleTypes.ENTITY_EFFECT, this.getParticleX(0.5), this.getRandomBodyY(), this.getParticleZ(0.5), d, e, f); | ||
super.tick(); | ||
} | ||
|
||
@Override | ||
public ItemStack getStack() { | ||
return new ItemStack(Items.AIR); | ||
} | ||
|
||
@Override | ||
public void writeCustomDataToNbt(NbtCompound nbt) { | ||
super.writeCustomDataToNbt(nbt); | ||
if (this.potion != Potions.EMPTY) { | ||
nbt.putString("Potion", Registry.POTION.getId(this.potion).toString()); | ||
} | ||
if (this.colorSet) { | ||
nbt.putInt("Color", this.getColor()); | ||
} | ||
if (!this.effects.isEmpty()) { | ||
NbtList nbtList = new NbtList(); | ||
for (StatusEffectInstance statusEffectInstance : this.effects) { | ||
nbtList.add(statusEffectInstance.writeNbt(new NbtCompound())); | ||
} | ||
nbt.put("CustomPotionEffects", nbtList); | ||
} | ||
} | ||
|
||
private void initColor() { | ||
this.colorSet = false; | ||
if (this.potion == Potions.EMPTY && this.effects.isEmpty()) { | ||
this.dataTracker.set(COLOR, -1); | ||
} else { | ||
this.dataTracker.set(COLOR, PotionUtil.getColor(PotionUtil.getPotionEffects(this.potion, this.effects))); | ||
} | ||
} | ||
|
||
public void addEffect(StatusEffectInstance effect) { | ||
this.effects.add(effect); | ||
this.getDataTracker().set(COLOR, PotionUtil.getColor(PotionUtil.getPotionEffects(this.potion, this.effects))); | ||
} | ||
|
||
@Override | ||
public void readCustomDataFromNbt(NbtCompound nbt) { | ||
super.readCustomDataFromNbt(nbt); | ||
if (nbt.contains("Potion", NbtElement.STRING_TYPE)) { | ||
this.potion = PotionUtil.getPotion(nbt); | ||
} | ||
for (StatusEffectInstance statusEffectInstance : PotionUtil.getCustomPotionEffects(nbt)) { | ||
this.addEffect(statusEffectInstance); | ||
} | ||
if (nbt.contains("Color", NbtElement.NUMBER_TYPE)) { | ||
this.setColor(nbt.getInt("Color")); | ||
} else { | ||
this.initColor(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.