Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into biome
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/client/java/minicraft/level/LevelGen.java
  • Loading branch information
BenCheung0422 committed Aug 30, 2024
2 parents 5a563a7 + 9e2e579 commit 8a44019
Show file tree
Hide file tree
Showing 158 changed files with 3,049 additions and 3,604 deletions.
130 changes: 130 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community admins.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

At the moment, enforcement may not be taken strictly under the circumference
of being a small public community project.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
9 changes: 9 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Security Policy

We take security vulnerability seriously. Only the vulnerabilities valid in the latest published build are considered.
Any resolved vulnerabilities in the latest version are considered resolved and anymore new duplicates are regarded as invalid.

## Reporting a Vulnerability

To report a vulnerability, go to [issues](https://github.com/MinicraftPlus/minicraft-plus-revived/issues) and report a bug.
If we see the bug report as a security vulnerability, we will categorize it so that it is in high priority.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
allprojects {
apply plugin: "java"

version = "2.2.1-dev1"
version = "2.2.1-dev2"

sourceCompatibility = 8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
Expand Down
2 changes: 1 addition & 1 deletion src/client/java/minicraft/core/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected Game() {

public static final String NAME = "Minicraft Plus"; // This is the name on the application window.

public static final Version VERSION = new Version("2.2.1-dev1");
public static final Version VERSION = new Version("2.2.1-dev2");

public static InputHandler input; // Input used in Game, Player, and just about all the *Menu classes.
public static Player player;
Expand Down
27 changes: 25 additions & 2 deletions src/client/java/minicraft/entity/furniture/Bed.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,45 @@
import minicraft.core.Updater;
import minicraft.core.io.Localization;
import minicraft.entity.mob.Player;
import minicraft.gfx.SpriteAnimation;
import minicraft.gfx.SpriteLinker.LinkedSprite;
import minicraft.gfx.SpriteLinker.SpriteType;
import minicraft.item.DyeItem;
import minicraft.level.Level;
import minicraft.util.MyUtils;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;

public class Bed extends Furniture {

private static final HashMap<DyeItem.DyeColor, LinkedSprite> sprites = new HashMap<>();
private static final HashMap<DyeItem.DyeColor, LinkedSprite> itemSprites = new HashMap<>();

@Override
public @NotNull Furniture copy() {
return new Bed(color);
}

static {
for (DyeItem.DyeColor color : DyeItem.DyeColor.values()) {
sprites.put(color, new LinkedSprite(SpriteType.Entity, color.toString().toLowerCase() + "_bed"));
itemSprites.put(color, new LinkedSprite(SpriteType.Item, color.toString().toLowerCase() + "_bed"));
}
}

private static int playersAwake = 1;
private static final HashMap<Player, Bed> sleepingPlayers = new HashMap<>();

public final DyeItem.DyeColor color;

/**
* Creates a new furniture with the name Bed and the bed sprite and color.
*/
public Bed() {
super("Bed", new LinkedSprite(SpriteType.Entity, "bed"), new LinkedSprite(SpriteType.Item, "bed"), 3, 2);
public Bed() { this(DyeItem.DyeColor.RED); }
public Bed(DyeItem.DyeColor color) {
super(MyUtils.capitalizeFully(color.toString().replace('_', ' ')) + " Bed", sprites.get(color), itemSprites.get(color), 3, 2);
this.color = color;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/client/java/minicraft/entity/furniture/Crafter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public enum Type {
Furnace(new LinkedSprite(SpriteType.Entity, "furnace"), new LinkedSprite(SpriteType.Item, "furnace"), 3, 2, Recipes.furnaceRecipes),
Anvil(new LinkedSprite(SpriteType.Entity, "anvil"), new LinkedSprite(SpriteType.Item, "anvil"), 3, 2, Recipes.anvilRecipes),
Enchanter(new LinkedSprite(SpriteType.Entity, "enchanter"), new LinkedSprite(SpriteType.Item, "enchanter"), 7, 2, Recipes.enchantRecipes),
Loom(new LinkedSprite(SpriteType.Entity, "loom"), new LinkedSprite(SpriteType.Item, "loom"), 7, 2, Recipes.loomRecipes);
Loom(new LinkedSprite(SpriteType.Entity, "loom"), new LinkedSprite(SpriteType.Item, "loom"), 7, 2, Recipes.loomRecipes),
DyeVat(new LinkedSprite(SpriteType.Entity, "dyevat"), new LinkedSprite(SpriteType.Item, "dyevat"), 0, 0, Recipes.dyeVatRecipes);

public ArrayList<Recipe> recipes;
protected LinkedSprite sprite;
Expand All @@ -45,12 +46,12 @@ public enum Type {
* @param type What type of crafter this is.
*/
public Crafter(Crafter.Type type) {
super(type.name(), type.sprite, type.itemSprite, type.xr, type.yr);
super((type.name().equalsIgnoreCase("DyeVat") ? "Dye Vat" : type.name()), type.sprite, type.itemSprite, type.xr, type.yr);
this.type = type;
}

public boolean use(Player player) {
Game.setDisplay(new CraftingDisplay(type.recipes, type.name(), player));
Game.setDisplay(new CraftingDisplay(type.recipes, (type.name().equalsIgnoreCase("DyeVat") ? "Dye Vat" : type.name()), player));
return true;
}

Expand All @@ -61,6 +62,6 @@ public boolean use(Player player) {

@Override
public String toString() {
return type.name() + getDataPrints();
return (type.name().equalsIgnoreCase("DyeVat") ? "Dye Vat" : type.name()) + getDataPrints();
}
}
2 changes: 1 addition & 1 deletion src/client/java/minicraft/entity/mob/Mob.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static LinkedSprite[][] compileMobSpriteAnimations(int sheetX, int sheetY
private boolean isWooling() { // supposed to walk at half speed on wool
if (level == null) return false;
Tile tile = level.getTile(x >> 4, y >> 4);
return tile == Tiles.get("wool");
return tile == Tiles.get("white wool");
}

/**
Expand Down
50 changes: 39 additions & 11 deletions src/client/java/minicraft/entity/mob/Sheep.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package minicraft.entity.mob;

import minicraft.item.DyeItem;
import org.jetbrains.annotations.Nullable;

import minicraft.core.io.Settings;
import minicraft.entity.Direction;
import minicraft.gfx.Screen;
Expand All @@ -11,27 +14,50 @@
import minicraft.level.tile.GrassTile;
import minicraft.level.tile.Tile;
import minicraft.level.tile.Tiles;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;

public class Sheep extends PassiveMob {
private static final LinkedSprite[][] sprites = Mob.compileMobSpriteAnimations(0, 0, "sheep");
private static final LinkedSprite[][] cutSprites = Mob.compileMobSpriteAnimations(0, 2, "sheep");
private static final HashMap<DyeItem.DyeColor, LinkedSprite[][]> sprites = new HashMap<>();
private static final HashMap<DyeItem.DyeColor, LinkedSprite[][]> cutSprites = new HashMap<>();

static {
for (DyeItem.DyeColor color : DyeItem.DyeColor.values()) {
LinkedSprite[][] mobSprites = Mob.compileMobSpriteAnimations(0, 0, "sheep");
for (LinkedSprite[] mobSprite : mobSprites) {
for (LinkedSprite linkedSprite : mobSprite) {
linkedSprite.setColor(color.color);
}
}
sprites.put(color, mobSprites);
mobSprites = Mob.compileMobSpriteAnimations(0, 2, "sheep");
for (LinkedSprite[] mobSprite : mobSprites) {
for (LinkedSprite linkedSprite : mobSprite) {
linkedSprite.setColor(color.color);
}
}
cutSprites.put(color, mobSprites);
}
}

public boolean cut = false;
public DyeItem.DyeColor color;

/**
* Creates a sheep entity.
*/
public Sheep() {
super(sprites);
public Sheep() { this(DyeItem.DyeColor.WHITE); }
public Sheep(DyeItem.DyeColor color) {
super(null);
this.color = color;
}

@Override
public void render(Screen screen) {
int xo = x - 8;
int yo = y - 11;

LinkedSprite[][] curAnim = cut ? cutSprites : sprites;
LinkedSprite[][] curAnim = cut ? cutSprites.get(color) : sprites.get(color);

LinkedSprite curSprite = curAnim[dir.getDir()][(walkDist >> 3) % curAnim[dir.getDir()].length];
if (hurtTime > 0) {
Expand All @@ -52,15 +78,17 @@ public void tick() {
}

public boolean interact(Player player, @Nullable Item item, Direction attackDir) {
if (cut) return false;

if (item instanceof ToolItem) {
if (((ToolItem) item).type == ToolType.Shears) {
if (!cut && ((ToolItem) item).type == ToolType.Shears) {
cut = true;
dropItem(1, 3, Items.get("Wool"));
dropItem(1, 3, Items.get(color.toString().replace('_', ' ') + " Wool"));
((ToolItem) item).payDurability();
return true;
}
} else if (item instanceof DyeItem) {
color = ((DyeItem) item).color;
((DyeItem) item).count--;
return true;
}
return false;
}
Expand All @@ -80,7 +108,7 @@ public void die() {
max = 2;
}

if (!cut) dropItem(min, max, Items.get("wool"));
if (!cut) dropItem(min, max, Items.get(color.toString().replace('_', ' ') + " Wool"));
dropItem(min, max, Items.get("Raw Beef"));

super.die();
Expand Down
2 changes: 1 addition & 1 deletion src/client/java/minicraft/gfx/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public double getOverlayOpacity(int currentLevel, double darkFactor) {
return 1;
} else {
// Outside the caves, not being lit simply means being darker.
return darkFactor / 128; // darkens the color one shade.
return darkFactor / 160; // darkens the color one shade.
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/java/minicraft/item/ClothingItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected static ArrayList<Item> getAllInstances() {
items.add(new ClothingItem("Orange Clothes", new LinkedSprite(SpriteType.Item, "orange_clothes"), Color.get(1, 255, 102, 0)));
items.add(new ClothingItem("Purple Clothes", new LinkedSprite(SpriteType.Item, "purple_clothes"), Color.get(1, 102, 0, 153)));
items.add(new ClothingItem("Cyan Clothes", new LinkedSprite(SpriteType.Item, "cyan_clothes"), Color.get(1, 0, 102, 153)));
items.add(new ClothingItem("Reg Clothes", new LinkedSprite(SpriteType.Item, "reg_clothes"), Color.get(1, 51, 51, 0)));
items.add(new ClothingItem("Reg Clothes", new LinkedSprite(SpriteType.Item, "reg_clothes"), Color.get(1, 51, 51, 0))); // Dark Green

return items;
}
Expand Down
Loading

0 comments on commit 8a44019

Please sign in to comment.