generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
Notifications
You must be signed in to change notification settings - Fork 1
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
a85f71f
commit 3dcb026
Showing
22 changed files
with
365 additions
and
79 deletions.
There are no files selected for viewing
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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/leclowndu93150/carbort/content/entities/DynamiteEntity.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,61 @@ | ||
package com.leclowndu93150.carbort.content.entities; | ||
|
||
import com.leclowndu93150.carbort.registries.CBEntityTypes; | ||
import com.leclowndu93150.carbort.registries.CBItems; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.projectile.Snowball; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.Explosion; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import net.minecraft.world.phys.EntityHitResult; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class DynamiteEntity extends Snowball { | ||
public DynamiteEntity(EntityType<? extends Snowball> entityType, Level level) { | ||
super(entityType, level); | ||
} | ||
|
||
public DynamiteEntity(Level level, LivingEntity livingEntity) { | ||
super(level, livingEntity); | ||
} | ||
|
||
@Override | ||
protected @NotNull Item getDefaultItem() { | ||
return CBItems.DYNAMITE.asItem(); | ||
} | ||
|
||
@Override | ||
protected void onHitBlock(BlockHitResult result) { | ||
this.level().explode( | ||
this, | ||
Explosion.getDefaultDamageSource(this.level(), this), | ||
null, | ||
this.getX(), | ||
this.getY(0.0625), | ||
this.getZ(), | ||
3.0F, | ||
false, | ||
Level.ExplosionInteraction.TNT | ||
); | ||
} | ||
|
||
@Override | ||
protected void onHitEntity(EntityHitResult result) { | ||
super.onHitEntity(result); | ||
this.level().explode( | ||
this, | ||
Explosion.getDefaultDamageSource(this.level(), this), | ||
null, | ||
this.getX(), | ||
this.getY(0.0625), | ||
this.getZ(), | ||
4.0F, | ||
false, | ||
Level.ExplosionInteraction.TNT | ||
); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/com/leclowndu93150/carbort/content/items/BedrockiumBladeItem.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,66 @@ | ||
package com.leclowndu93150.carbort.content.items; | ||
|
||
import com.leclowndu93150.carbort.CarbortConfig; | ||
import com.leclowndu93150.carbort.api.items.IFluidItem; | ||
import com.leclowndu93150.carbort.data.CBDataComponents; | ||
import com.leclowndu93150.carbort.utils.CapabilityUtils; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.util.FastColor; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResultHolder; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.SwordItem; | ||
import net.minecraft.world.level.Level; | ||
import net.neoforged.neoforge.common.Tags; | ||
import net.neoforged.neoforge.fluids.FluidStack; | ||
import net.neoforged.neoforge.fluids.capability.IFluidHandler; | ||
|
||
public class BedrockiumBladeItem extends SwordItem implements IFluidItem { | ||
public BedrockiumBladeItem(Properties properties) { | ||
super(ToolTiers.BEDROCKIUM, properties); | ||
} | ||
|
||
@Override | ||
public int getCapacity() { | ||
return CarbortConfig.itemFluidCapacity(this); | ||
} | ||
|
||
@Override | ||
public boolean isBarVisible(ItemStack stack) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getBarColor(ItemStack stack) { | ||
return FastColor.ARGB32.color(82, 82, 82); | ||
} | ||
|
||
@Override | ||
public int getBarWidth(ItemStack stack) { | ||
IFluidHandler energyStorage = CapabilityUtils.itemFluidHandler(stack); | ||
return Math.round(13.0F - ((1 - ((float) energyStorage.getFluidInTank(0).getAmount() / energyStorage.getTankCapacity(0))) * 13.0F)); | ||
} | ||
|
||
@Override | ||
public boolean isFluidValid(int tank, FluidStack stack) { | ||
// TODO: Void fluid | ||
return stack.is(Tags.Fluids.LAVA); | ||
} | ||
|
||
@Override | ||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand usedHand) { | ||
if (player.isShiftKeyDown()) { | ||
ItemStack itemInHand = player.getItemInHand(usedHand); | ||
itemInHand.set(CBDataComponents.ACTIVE, !itemInHand.getOrDefault(CBDataComponents.ACTIVE, false)); | ||
player.playSound(SoundEvents.EXPERIENCE_ORB_PICKUP); | ||
return InteractionResultHolder.success(itemInHand); | ||
} | ||
return super.use(level, player, usedHand); | ||
} | ||
|
||
@Override | ||
public boolean isFoil(ItemStack stack) { | ||
return super.isFoil(stack) || stack.getOrDefault(CBDataComponents.ACTIVE, false); | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/leclowndu93150/carbort/content/items/DynamiteItem.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,43 @@ | ||
package com.leclowndu93150.carbort.content.items; | ||
|
||
import com.leclowndu93150.carbort.content.entities.DynamiteEntity; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.stats.Stats; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResultHolder; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
|
||
public class DynamiteItem extends Item { | ||
public DynamiteItem(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand usedHand) { | ||
ItemStack itemstack = player.getItemInHand(usedHand); | ||
level.playSound( | ||
null, | ||
player.getX(), | ||
player.getY(), | ||
player.getZ(), | ||
SoundEvents.SNOWBALL_THROW, | ||
SoundSource.NEUTRAL, | ||
0.5F, | ||
0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) | ||
); | ||
if (!level.isClientSide) { | ||
DynamiteEntity dynamite = new DynamiteEntity(level, player); | ||
dynamite.setItem(itemstack); | ||
dynamite.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, 0.5F, 1.0F); | ||
level.addFreshEntity(dynamite); | ||
} | ||
|
||
player.awardStat(Stats.ITEM_USED.get(this)); | ||
itemstack.consume(1, player); | ||
return InteractionResultHolder.sidedSuccess(itemstack, level.isClientSide()); | ||
} | ||
} |
Oops, something went wrong.