Skip to content

Commit

Permalink
1.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Rin committed Nov 27, 2024
1 parent 6be92e6 commit d9c9eff
Show file tree
Hide file tree
Showing 48 changed files with 541 additions and 47 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ halplibe_version=4.1.3
terrain_api_version=1.4.4-7.2-pre1

# Mod
mod_version=1.1.4
mod_version=1.1.5
mod_group=Mizuri-n
mod_name=Rin's Fortress
5 changes: 5 additions & 0 deletions src/main/java/mizurin/shieldmod/Recipes.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mizurin.shieldmod;

import mizurin.shieldmod.blocks.RinBlocks;
import net.minecraft.core.block.Block;
import net.minecraft.core.data.registry.Registries;
import net.minecraft.core.data.registry.recipe.RecipeNamespace;
Expand Down Expand Up @@ -90,6 +91,10 @@ public void onRecipesReady() {
.addInput(Item.jar)
.create("poisonbottle", new ItemStack(Shields.poisonBottle, 3));

RecipeBuilder.Shapeless(MOD_ID)
.addInput(new ItemStack(RinBlocks.logApple, 1))
.create("apple_log_to_light_grey", new ItemStack(Block.planksOakPainted, 4, 8));


WORKBENCH.register("tearstoneShield", new RecipeEntryRepairable(Shields.tearShield, Item.ingotIron));

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

import mizurin.shieldmod.blocks.RinBlocks;
import mizurin.shieldmod.entities.*;
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.entity.fx.EntityFX;
import net.minecraft.client.entity.fx.EntityFlameFX;
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.enums.ArtType;
import net.minecraft.core.item.Item;
import net.minecraft.core.net.entity.NetEntityHandler;
import net.minecraft.core.world.World;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import turniplabs.halplibe.helper.EntityHelper;
import turniplabs.halplibe.helper.ParticleHelper;
import turniplabs.halplibe.util.ClientStartEntrypoint;
import turniplabs.halplibe.util.ConfigHandler;
import turniplabs.halplibe.util.GameStartEntrypoint;
Expand All @@ -24,6 +29,7 @@ public class ShieldMod implements ModInitializer, GameStartEntrypoint, ClientSta
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static int playerArmorRenderOffset = 0;

public static int blockID;
public static int itemID;
public static int entityID;
public static boolean hurtSound;
Expand All @@ -32,11 +38,13 @@ public class ShieldMod implements ModInitializer, GameStartEntrypoint, ClientSta
public static ArtType paintingRice;
static {
Properties prop = new Properties();
prop.setProperty("starting_block_id", "7000");
prop.setProperty("starting_item_id", "21000");
prop.setProperty("starting_entity_id", "200");
prop.setProperty("enable_hit_sounds", "false");
prop.setProperty("enable_expert_mode", "false");
ConfigHandler config = new ConfigHandler(ShieldMod.MOD_ID, prop);
blockID = config.getInt("starting_block_id");
itemID = config.getInt("starting_item_id");
entityID = config.getInt("starting_entity_id");
hurtSound = config.getBoolean("enable_hit_sounds");
Expand All @@ -49,6 +57,7 @@ public class ShieldMod implements ModInitializer, GameStartEntrypoint, ClientSta
public void onInitialize() {
LOGGER.info("Rin's Fortress has been initialized.");
new Shields().initializeItems();
new RinBlocks().initializeBlocks();
Colorizers.registerColorizers();
}

Expand Down
26 changes: 26 additions & 0 deletions src/main/java/mizurin/shieldmod/WorldFeatureTreeApple.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package mizurin.shieldmod;
import mizurin.shieldmod.blocks.RinBlocks;
import net.minecraft.core.world.World;
import net.minecraft.core.world.generate.feature.tree.WorldFeatureTree;
import net.minecraft.core.world.season.Seasons;

import java.util.Random;

public class WorldFeatureTreeApple extends WorldFeatureTree {
public WorldFeatureTreeApple(int leavesID, int logID, int heightMod) {
super(leavesID, logID, heightMod);
}

public void placeLeaves(World world, int x, int y, int z, Random rand) {
if (rand.nextInt(5) == 0) {
world.setBlockAndMetadataWithNotify(x, y, z, RinBlocks.leavesAppleFlowering.id, world.seasonManager.getCurrentSeason() == Seasons.OVERWORLD_FALL ? 1 : 0);
} else {
world.setBlockWithNotify(x, y, z, RinBlocks.leavesApple.id);
}

}

public boolean isLeaf(int id) {
return id == RinBlocks.leavesAppleFlowering.id || id == RinBlocks.leavesApple.id;
}
}
26 changes: 26 additions & 0 deletions src/main/java/mizurin/shieldmod/blocks/BlockLeavesApple.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package mizurin.shieldmod.blocks;

import java.util.Random;

import net.minecraft.core.block.Block;
import net.minecraft.core.block.BlockLeavesBase;
import net.minecraft.core.block.material.Material;
import net.minecraft.core.world.World;
import net.minecraft.core.world.season.Seasons;

public class BlockLeavesApple extends BlockLeavesBase {
public BlockLeavesApple(String key, int id) {
super(key, id, Material.leaves);
}

public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
if (world.getSeasonManager().getCurrentSeason() != null && world.getSeasonManager().getCurrentSeason() == Seasons.OVERWORLD_FALL && rand.nextInt(40) == 0) {
world.spawnParticle("fallingleaf", (double)x, (double)y - 0.10000000149011612, (double)z, 0.0, 0.0, 0.0, 0);
}

}

protected Block getSapling() {
return RinBlocks.saplingApple;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package mizurin.shieldmod.blocks;

import java.util.Random;

import net.minecraft.core.block.BlockLeavesCherry;
import net.minecraft.core.block.entity.TileEntity;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.enums.EnumDropCause;
import net.minecraft.core.item.IBonemealable;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.util.helper.Side;
import net.minecraft.core.world.World;
import net.minecraft.core.world.season.Seasons;

import static mizurin.shieldmod.blocks.RinBlocks.leavesAppleFlowering;

public class BlockLeavesAppleFlowering extends BlockLeavesCherry implements IBonemealable {
public BlockLeavesAppleFlowering(String key, int id) {
super(key, id);
}

public ItemStack[] getBreakResult(World world, EnumDropCause dropCause, int x, int y, int z, int meta, TileEntity tileEntity) {
int growthRate = (meta & 240) >> 4;
if (dropCause != EnumDropCause.PICK_BLOCK && dropCause != EnumDropCause.SILK_TOUCH) {
return growthRate == 0 ? null : new ItemStack[]{new ItemStack(Item.foodApple, world.rand.nextInt(2) + 1)};
} else {
return new ItemStack[]{new ItemStack(this)};
}
}

public void onBlockLeftClicked(World world, int x, int y, int z, EntityPlayer player, Side side, double xHit, double yHit) {
this.onBlockRightClicked(world, x, y, z, player, (Side)null, 0.0, 0.0);
}

public boolean onBlockRightClicked(World world, int x, int y, int z, EntityPlayer player, Side side, double xPlaced, double yPlaced) {
int meta = world.getBlockMetadata(x, y, z);
int decayData = meta & 15;
int growthRate = (meta & 240) >> 4;
if (growthRate > 0) {
world.playSoundAtEntity(player, player, "random.pop", 0.2F, 0.5F);
if (!world.isClientSide) {
this.dropBlockWithCause(world, EnumDropCause.WORLD, x, y, z, meta, (TileEntity)null);
}

world.setBlockMetadataWithNotify(x, y, z, decayData);
world.scheduleBlockUpdate(x, y, z, leavesAppleFlowering.id, this.tickRate());
return true;
} else {
return super.onBlockRightClicked(world, x, y, z, player, side, xPlaced, yPlaced);
}
}

public void updateTick(World world, int x, int y, int z, Random rand) {
super.updateTick(world, x, y, z, rand);
int meta = world.getBlockMetadata(x, y, z);
int growthRate = (meta & 240) >> 4;
if (world.getSeasonManager().getCurrentSeason() == Seasons.OVERWORLD_FALL) {
if (rand.nextInt(20) == 0 && growthRate == 0) {
world.setBlockMetadataWithNotify(x, y, z, 16 | meta);
world.scheduleBlockUpdate(x, y, z, leavesAppleFlowering.id, this.tickRate());
}
} else if (growthRate > 0) {
world.setBlockMetadataWithNotify(x, y, z, meta & 15);
world.scheduleBlockUpdate(x, y, z, leavesAppleFlowering.id, this.tickRate());
}

}

public boolean onBonemealUsed(ItemStack itemstack, EntityPlayer entityplayer, World world, int blockX, int blockY, int blockZ, Side side, double xPlaced, double yPlaced) {
int meta = world.getBlockMetadata(blockX, blockY, blockZ);
if ((meta & 240) >> 4 == 0) {
if (!world.isClientSide) {
if (world.getSeasonManager().getCurrentSeason() != Seasons.OVERWORLD_FALL) {
return true;
}

world.setBlockMetadataWithNotify(blockX, blockY, blockZ, 16 | meta);
if (entityplayer.getGamemode().consumeBlocks()) {
--itemstack.stackSize;
}
}

return true;
} else {
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package mizurin.shieldmod.blocks;

import net.minecraft.client.render.block.model.BlockModelLeaves;
import net.minecraft.client.render.stitcher.IconCoordinate;
import net.minecraft.client.render.stitcher.TextureRegistry;
import net.minecraft.client.render.tessellator.Tessellator;
import net.minecraft.core.block.Block;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL11;

public class BlockModelAppleLeavesBloom<T extends Block> extends BlockModelLeaves<T> {
private final IconCoordinate grownAppleOverlay = TextureRegistry.getTexture("shieldmod:block/leaves_apple_overlay");
private final IconCoordinate floweringAppleOverlay = TextureRegistry.getTexture("shieldmod:block/leaves_apple_flowering_overlay");

public BlockModelAppleLeavesBloom(Block block) {
super(block, "shieldmod:block/leaves_apple");
}

public boolean render(Tessellator tessellator, int x, int y, int z) {
super.render(tessellator, x, y, z);
int growthRate = (renderBlocks.blockAccess.getBlockMetadata(x, y, z) & 240) >> 4;
if (growthRate > 0) {
renderBlocks.overrideBlockTexture = this.grownAppleOverlay;
} else {
renderBlocks.overrideBlockTexture = this.floweringAppleOverlay;
}

this.renderStandardBlock(tessellator, this.block, x, y, z, 1.0F, 1.0F, 1.0F);
renderBlocks.overrideBlockTexture = null;
return true;
}

public void renderBlockOnInventory(Tessellator tessellator, int metadata, float brightness, float alpha, @Nullable Integer lightmapCoordinate) {
super.renderBlockOnInventory(tessellator, metadata, brightness, alpha, lightmapCoordinate);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
IconCoordinate appleCoord = this.grownAppleOverlay;
GL11.glColor4f(brightness, brightness, brightness, alpha);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
this.renderBottomFace(tessellator, this.block, 0.0, 0.0, 0.0, appleCoord);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
this.renderTopFace(tessellator, this.block, 0.0, 0.0, 0.0, appleCoord);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, -1.0F);
this.renderNorthFace(tessellator, this.block, 0.0, 0.0, 0.0, appleCoord);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 0.0F, 1.0F);
this.renderSouthFace(tessellator, this.block, 0.0, 0.0, 0.0, appleCoord);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
this.renderWestFace(tessellator, this.block, 0.0, 0.0, 0.0, appleCoord);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.setNormal(1.0F, 0.0F, 0.0F);
this.renderEastFace(tessellator, this.block, 0.0, 0.0, 0.0, appleCoord);
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
}
25 changes: 25 additions & 0 deletions src/main/java/mizurin/shieldmod/blocks/BlockSaplingApple.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package mizurin.shieldmod.blocks;

import mizurin.shieldmod.WorldFeatureTreeApple;
import net.minecraft.core.block.BlockSaplingBase;
import net.minecraft.core.world.World;
import net.minecraft.core.world.generate.feature.WorldFeature;
import net.minecraft.core.world.generate.feature.tree.WorldFeatureTreeFancy;

import java.util.Random;

public class BlockSaplingApple extends BlockSaplingBase {
public BlockSaplingApple(String key, int id) {
super(key, id);
}

public void growTree(World world, int i, int j, int k, Random random) {
WorldFeature treeBig = new WorldFeatureTreeFancy(RinBlocks.leavesApple.id, RinBlocks.logApple.id);
WorldFeature treeSmall = new WorldFeatureTreeApple(RinBlocks.leavesApple.id, RinBlocks.logApple.id, 4);
world.setBlock(i, j, k, 0);
if (!((WorldFeature) treeSmall).generate(world, random, i, j, k) && !((WorldFeature) treeBig).generate(world, random, i, j, k)) {
world.setBlock(i, j, k, this.id);
}

}
}
75 changes: 75 additions & 0 deletions src/main/java/mizurin/shieldmod/blocks/RinBlocks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package mizurin.shieldmod.blocks;

import net.minecraft.client.render.block.color.BlockColor;
import net.minecraft.client.render.block.color.BlockColorLeavesOak;
import net.minecraft.client.render.block.model.BlockModelAxisAligned;
import net.minecraft.client.render.block.model.BlockModelCrossedSquares;
import net.minecraft.client.render.block.model.BlockModelLeaves;
import net.minecraft.client.render.colorizer.Colorizer;
import net.minecraft.core.block.Block;
import net.minecraft.core.block.BlockLog;
import net.minecraft.core.block.tag.BlockTags;
import net.minecraft.core.item.block.ItemBlockLeaves;
import net.minecraft.core.sound.BlockSound;
import turniplabs.halplibe.helper.BlockBuilder;


import java.util.function.Function;

import static mizurin.shieldmod.ShieldMod.blockID;
import static mizurin.shieldmod.item.Shields.MOD_ID;

public class RinBlocks {

public static Colorizer apple;
public static Block logApple;
public static Block leavesApple;
public static Block leavesAppleFlowering;
public static Block saplingApple;

public void initializeBlockDetails() {

}

public void initializeBlocks() {
BlockBuilder leaves = new BlockBuilder(MOD_ID)
.setBlockSound(new BlockSound("step.grass", "step.grass", 1.0f, 1.0f))
.setHardness(0.2F)
.setResistance(0.2F)
.setFlammability(30, 60)
.setTickOnLoad()
.setVisualUpdateOnMetadata()
.setItemBlock(ItemBlockLeaves::new)
.setBlockColor(b -> new BlockColorLeavesOak(apple))
.setTags(BlockTags.MINEABLE_BY_AXE, BlockTags.MINEABLE_BY_HOE, BlockTags.MINEABLE_BY_SWORD, BlockTags.MINEABLE_BY_SHEARS, BlockTags.SHEARS_DO_SILK_TOUCH);


BlockBuilder sapling = new BlockBuilder(MOD_ID)
.setBlockSound(new BlockSound("step.grass", "step.grass", 1.0f, 1.0f))
.setHardness(0.0f)
.setResistance(0.0f)
.setBlockModel(BlockModelCrossedSquares::new)
.setTags(BlockTags.BROKEN_BY_FLUIDS, BlockTags.PLANTABLE_IN_JAR);

BlockBuilder log = new BlockBuilder(MOD_ID)
.setBlockSound(new BlockSound("step.wood", "step.wood", 1.0f, 1.0f))
.setHardness(2.0F)
.setResistance(1.0f)
.setFlammability(5, 5)
.setBlockModel(BlockModelAxisAligned::new)
.setTags(BlockTags.MINEABLE_BY_AXE, BlockTags.FENCES_CONNECT);

logApple = log
.setBlockModel(block -> new BlockModelAxisAligned<>(block).withTextures("shieldmod:block/log_apple_top_test", "shieldmod:block/log_apple_side_test"))
.build(new BlockLog("log.apple", ++blockID));
leavesApple = leaves
.setBlockModel(block -> new BlockModelLeaves<>(block, "shieldmod:block/leaves_apple"))
.build(new BlockLeavesApple("leaves.apple", ++blockID));
leavesAppleFlowering = leaves
.setBlockModel(BlockModelAppleLeavesBloom::new)
.build(new BlockLeavesAppleFlowering("leaves.apple.flowering", ++blockID));
saplingApple = sapling
.setBlockModel(block -> new BlockModelCrossedSquares<>(block).withTextures("shieldmod:block/sapling_apple"))
.build(new BlockSaplingApple("sapling.apple", ++blockID));
}
}
2 changes: 1 addition & 1 deletion src/main/java/mizurin/shieldmod/entities/EntityPB.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void init() {
public void onHit(HitResult hitResult) {
if (hitResult.entity != null) {
hitResult.entity.hurt(this.owner, this.damage, DamageType.COMBAT);
((IDazed) hitResult.entity).shieldmod$dazedHurt(300);
((IDazed) hitResult.entity).shieldmod$dazedHurt(450);
//Applies my custom status effect from the IDazed interface.
}
if (this.modelItem != null) {
Expand Down
Loading

0 comments on commit d9c9eff

Please sign in to comment.