-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Showing
17 changed files
with
199 additions
and
7 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
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
7 changes: 7 additions & 0 deletions
7
src/generated/resources/assets/biomancy/blockstates/acid_cauldron.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "biomancy:block/acid_cauldron" | ||
} | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/biomancy/models/block/acid_cauldron.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "minecraft:block/lava_cauldron", | ||
"textures": { | ||
"content": "biomancy:fluid/acid_overlay" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/generated/resources/data/biomancy/loot_tables/blocks/acid_cauldron.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"functions": [ | ||
{ | ||
"function": "minecraft:explosion_decay" | ||
} | ||
], | ||
"name": "minecraft:cauldron" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
], | ||
"random_sequence": "biomancy:blocks/acid_cauldron" | ||
} |
5 changes: 5 additions & 0 deletions
5
src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"values": [ | ||
"biomancy:acid_cauldron" | ||
] | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/github/elenterius/biomancy/block/cauldron/AcidCauldron.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,69 @@ | ||
package com.github.elenterius.biomancy.block.cauldron; | ||
|
||
import com.github.elenterius.biomancy.fluid.AcidFluid; | ||
import com.github.elenterius.biomancy.init.ModFluids; | ||
import com.github.elenterius.biomancy.init.ModItems; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.cauldron.CauldronInteraction; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.AbstractCauldronBlock; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import net.minecraftforge.common.SoundActions; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class AcidCauldron extends AbstractCauldronBlock { | ||
public AcidCauldron() { | ||
super(Properties.copy(Blocks.CAULDRON),getInteractions()); | ||
} | ||
|
||
private static Map<Item, CauldronInteraction> getInteractions() { | ||
Map<Item,CauldronInteraction> map = CauldronInteraction.newInteractionMap(); | ||
map.put(Items.BUCKET, (pBlockState, pLevel, pPos, pPlayer, pHand, pEmptyStack) -> CauldronInteraction.fillBucket(pBlockState, pLevel, pPos, pPlayer, pHand, pEmptyStack, ModItems.ACID_BUCKET.get().getDefaultInstance(), (_stack)->true, Objects.requireNonNull(ModFluids.ACID_TYPE.get().getSound(SoundActions.BUCKET_FILL)))); | ||
return map; | ||
} | ||
|
||
@Override | ||
public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { | ||
if (!(entity instanceof LivingEntity)) return; | ||
AcidFluid.onEntityInside((LivingEntity)entity); | ||
} | ||
|
||
@Override | ||
public boolean isFull(BlockState pState) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { | ||
//No idea why, but MC freaks out without this line. super.use() should cover it, but it doesn't so... | ||
if (getInteractions().containsKey(player.getItemInHand(hand).getItem())) return getInteractions().get(player.getItemInHand(hand).getItem()).interact(state,level,pos,player,hand,player.getItemInHand(hand)); | ||
|
||
//An attempt to allow the player to do all the erosion interactions inside the cauldron. | ||
//It mostly works, copper being a weird exception. | ||
Block block = ForgeRegistries.BLOCKS.getValue(ForgeRegistries.ITEMS.getKey(player.getItemInHand(hand).getItem())); | ||
if (!Objects.isNull(block)) { | ||
BlockState eroded = AcidFluid.getEroded(block.defaultBlockState()); | ||
if (!Objects.isNull(eroded)) { | ||
player.setItemInHand(hand,new ItemStack(eroded.getBlock().asItem(),player.getItemInHand(hand).getCount())); | ||
return InteractionResult.SUCCESS; | ||
} | ||
} | ||
|
||
return super.use(state, level, pos, player, hand, hit); | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/main/java/com/github/elenterius/biomancy/mixin/AbstractCauldronBlockMixin.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,32 @@ | ||
package com.github.elenterius.biomancy.mixin; | ||
|
||
import com.github.elenterius.biomancy.init.ModBlocks; | ||
import com.github.elenterius.biomancy.init.ModFluids; | ||
import com.github.elenterius.biomancy.init.ModItems; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.cauldron.CauldronInteraction; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.AbstractCauldronBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import net.minecraftforge.common.SoundActions; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.Objects; | ||
|
||
@Mixin(value= AbstractCauldronBlock.class) | ||
public abstract class AbstractCauldronBlockMixin { | ||
@Inject(at=@At("TAIL"),method="Lnet/minecraft/world/level/block/AbstractCauldronBlock;use(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;", cancellable = true) | ||
public void biomancy$use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir) { | ||
//Allow the Acid bucket to fill Cauldrons. I have no idea why this should require a mixin, beyond "Just Vanilla Things". | ||
if (player.getItemInHand(hand).getItem().equals(ModItems.ACID_BUCKET.get())) { | ||
cir.setReturnValue(CauldronInteraction.emptyBucket(level,pos,player,hand,player.getItemInHand(hand), ModBlocks.ACID_CAULDRON.get().defaultBlockState(), Objects.requireNonNull(ModFluids.ACID_TYPE.get().getSound(SoundActions.BUCKET_FILL)))); | ||
} | ||
} | ||
} |
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