-
Notifications
You must be signed in to change notification settings - Fork 54
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
89ec7ae
commit e9a6496
Showing
23 changed files
with
389 additions
and
16 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/generated/resources/assets/vampirism/blockstates/mother_trophy.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": "vampirism:block/mother_trophy" | ||
} | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
src/generated/resources/data/vampirism/loot_tables/blocks/mother_trophy.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, | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "vampirism:mother_trophy" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
], | ||
"random_sequence": "vampirism:blocks/mother_trophy" | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/de/teamlapen/vampirism/blockentity/MotherTrophyBlockEntity.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,13 @@ | ||
package de.teamlapen.vampirism.blockentity; | ||
|
||
import de.teamlapen.vampirism.core.ModTiles; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public class MotherTrophyBlockEntity extends BlockEntity { | ||
|
||
public MotherTrophyBlockEntity(BlockPos pPos, BlockState pBlockState) { | ||
super(ModTiles.MOTHER_TROPHY.get(), pPos, pBlockState); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/main/java/de/teamlapen/vampirism/blocks/MotherTrophyBlock.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,73 @@ | ||
package de.teamlapen.vampirism.blocks; | ||
|
||
import de.teamlapen.vampirism.blockentity.MotherTrophyBlockEntity; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.*; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
import net.minecraft.world.level.block.state.properties.IntegerProperty; | ||
import net.minecraft.world.level.block.state.properties.RotationSegment; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class MotherTrophyBlock extends BaseEntityBlock { | ||
|
||
public static final int MAX = RotationSegment.getMaxSegmentIndex(); | ||
private static final int ROTATIONS = MAX + 1; | ||
public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16; | ||
private static final VoxelShape SHAPE = makeShape(); | ||
|
||
public MotherTrophyBlock(Properties pProperties) { | ||
super(pProperties); | ||
this.registerDefaultState(this.stateDefinition.any().setValue(ROTATION, 0)); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public RenderShape getRenderShape(@NotNull BlockState state) { | ||
return RenderShape.MODEL; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public BlockEntity newBlockEntity(@NotNull BlockPos pPos, @NotNull BlockState pState) { | ||
return new MotherTrophyBlockEntity(pPos, pState); | ||
} | ||
|
||
@Override | ||
public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) { | ||
return SHAPE; | ||
} | ||
|
||
public @NotNull VoxelShape getOcclusionShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos) { | ||
return Shapes.empty(); | ||
} | ||
|
||
public BlockState getStateForPlacement(@NotNull BlockPlaceContext pContext) { | ||
return this.defaultBlockState().setValue(ROTATION, RotationSegment.convertToSegment(pContext.getRotation())); | ||
} | ||
|
||
public @NotNull BlockState rotate(@NotNull BlockState pState, @NotNull Rotation pRotation) { | ||
return pState.setValue(ROTATION, pRotation.rotate(pState.getValue(ROTATION), ROTATIONS)); | ||
} | ||
|
||
public @NotNull BlockState mirror(@NotNull BlockState pState, @NotNull Mirror pMirror) { | ||
return pState.setValue(ROTATION, pMirror.mirror(pState.getValue(ROTATION), ROTATIONS)); | ||
} | ||
|
||
protected void createBlockStateDefinition(StateDefinition.@NotNull Builder<Block, BlockState> pBuilder) { | ||
pBuilder.add(ROTATION); | ||
} | ||
|
||
|
||
private static @NotNull VoxelShape makeShape() { | ||
return Shapes.box(0.375, 0, 0.375, 0.625, 0.75, 0.625); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
...n/java/de/teamlapen/vampirism/client/renderer/blockentity/ModBlockEntityItemRenderer.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,37 @@ | ||
package de.teamlapen.vampirism.client.renderer.blockentity; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import de.teamlapen.vampirism.blockentity.MotherTrophyBlockEntity; | ||
import de.teamlapen.vampirism.core.ModBlocks; | ||
import net.minecraft.client.model.geom.EntityModelSet; | ||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.packs.resources.ResourceManager; | ||
import net.minecraft.world.item.ItemDisplayContext; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ModBlockEntityItemRenderer extends BlockEntityWithoutLevelRenderer { | ||
|
||
private MotherTrophyBlockEntity mother_trophy; | ||
private final BlockEntityRenderDispatcher pBlockEntityRenderDispatcher; | ||
|
||
public ModBlockEntityItemRenderer(BlockEntityRenderDispatcher pBlockEntityRenderDispatcher, EntityModelSet pEntityModelSet) { | ||
super(pBlockEntityRenderDispatcher, pEntityModelSet); | ||
this.pBlockEntityRenderDispatcher = pBlockEntityRenderDispatcher; | ||
} | ||
|
||
@Override | ||
public void onResourceManagerReload(@NotNull ResourceManager pResourceManager) { | ||
this.mother_trophy = new MotherTrophyBlockEntity(BlockPos.ZERO, ModBlocks.MOTHER_TROPHY.get().defaultBlockState()); | ||
} | ||
|
||
@Override | ||
public void renderByItem(@NotNull ItemStack pStack, @NotNull ItemDisplayContext pDisplayContext, @NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight, int pPackedOverlay) { | ||
if (pStack.is(ModBlocks.MOTHER_TROPHY.get().asItem())) { | ||
this.pBlockEntityRenderDispatcher.renderItem(mother_trophy, pPoseStack, pBuffer, pPackedLight, pPackedOverlay); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/de/teamlapen/vampirism/client/renderer/blockentity/MotherTrophyBESR.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,37 @@ | ||
package de.teamlapen.vampirism.client.renderer.blockentity; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.math.Axis; | ||
import de.teamlapen.vampirism.blockentity.MotherTrophyBlockEntity; | ||
import de.teamlapen.vampirism.blocks.MotherTrophyBlock; | ||
import de.teamlapen.vampirism.client.core.ModEntitiesRender; | ||
import de.teamlapen.vampirism.client.model.GhostModel; | ||
import de.teamlapen.vampirism.client.renderer.entity.GhostRenderer; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||
import net.minecraft.world.level.block.state.properties.RotationSegment; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class MotherTrophyBESR extends VampirismBESR<MotherTrophyBlockEntity> { | ||
|
||
private final GhostModel model; | ||
|
||
public MotherTrophyBESR(BlockEntityRendererProvider.Context context) { | ||
this.model = new GhostModel(context.bakeLayer(ModEntitiesRender.GHOST)); | ||
} | ||
|
||
@Override | ||
public void render(@NotNull MotherTrophyBlockEntity pBlockEntity, float pPartialTick, @NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight, int pPackedOverlay) { | ||
Integer value = pBlockEntity.getBlockState().getValue(MotherTrophyBlock.ROTATION); | ||
pPoseStack.pushPose(); | ||
pPoseStack.translate(0.5, 0, 0.5); | ||
pPoseStack.mulPose(Axis.ZP.rotationDegrees(180)); | ||
pPoseStack.translate(0.0F, -1.701F, 0.0F); | ||
float f1 = RotationSegment.convertToDegrees(value); | ||
pPoseStack.mulPose(Axis.YP.rotationDegrees(f1)); | ||
this.model.setupAnim2(pBlockEntity.getLevel() != null ? pBlockEntity.getLevel().getGameTime() : 0); | ||
this.model.renderToBuffer(pPoseStack, pBuffer.getBuffer(RenderType.itemEntityTranslucentCull(GhostRenderer.TEXTURE)), pPackedLight, pPackedOverlay, 1, 1, 1, 1f); | ||
pPoseStack.popPose(); | ||
} | ||
} |
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.