Added the muffler upgrade (#2928)
* Added flag for ability to play sound. * Added muffler functionality * Added muffler to upgrade advancement * Added muffler model * Added muffler lang entry * Added muffler placeholder texture * Added muffler recipe + toast * Added muffler tooltip
This commit is contained in:
parent
b14a4c72a1
commit
a574c7f67e
12 changed files with 135 additions and 5 deletions
|
@ -102,6 +102,12 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
|
|||
* </ul>
|
||||
*/
|
||||
double powerMultiplier = 1;
|
||||
/**
|
||||
* <p>
|
||||
* This is used to change the sound of the crafting operation.
|
||||
* <p/>
|
||||
*/
|
||||
boolean muffled = false;
|
||||
|
||||
public MachineBaseBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
@ -187,6 +193,7 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
|
|||
public void resetUpgrades() {
|
||||
resetPowerMultiplier();
|
||||
resetSpeedMultiplier();
|
||||
resetMuffler();
|
||||
}
|
||||
|
||||
protected void afterUpgradesApplication() {
|
||||
|
@ -356,6 +363,21 @@ public class MachineBaseBlockEntity extends BlockEntity implements BlockEntityTi
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void muffle() {
|
||||
muffled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetMuffler() {
|
||||
muffled = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMuffled() {
|
||||
return muffled;
|
||||
}
|
||||
|
||||
public boolean hasSlotConfig() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -43,4 +43,10 @@ public interface IUpgradeHandler {
|
|||
|
||||
void addSpeedMultiplier(double amount);
|
||||
|
||||
void muffle();
|
||||
|
||||
void resetMuffler();
|
||||
|
||||
boolean isMuffled();
|
||||
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public class RecipeCrafter implements IUpgradeHandler {
|
|||
long useRequirement = getEuPerTick(currentRecipe.getPower());
|
||||
if (energy.tryUseExact(useRequirement)) {
|
||||
currentTickTime++;
|
||||
if ((currentTickTime == 1 || currentTickTime % 20 == 0 && cachedWorldTime > lastSoundTime+ 10) && soundHandler != null) {
|
||||
if ((currentTickTime == 1 || currentTickTime % 20 == 0 && cachedWorldTime > lastSoundTime+ 10) && soundHandler != null && !isMuffled()) {
|
||||
lastSoundTime = cachedWorldTime;
|
||||
soundHandler.playSound(false, blockEntity);
|
||||
}
|
||||
|
@ -416,4 +416,19 @@ public class RecipeCrafter implements IUpgradeHandler {
|
|||
public void addSpeedMultiplier(double amount) {
|
||||
parentUpgradeHandler.ifPresent(iUpgradeHandler -> iUpgradeHandler.addSpeedMultiplier(amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void muffle() {
|
||||
parentUpgradeHandler.ifPresent(IUpgradeHandler::muffle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetMuffler() {
|
||||
parentUpgradeHandler.ifPresent(IUpgradeHandler::resetMuffler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMuffled() {
|
||||
return parentUpgradeHandler.map(IUpgradeHandler::isMuffled).orElse(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,8 +89,13 @@ public class AbstractBlockBlockEntity extends GenericMachineBlockEntity implemen
|
|||
//BlockBreakerProcessable
|
||||
@Override
|
||||
public void playSound() {
|
||||
if (RecipeCrafter.soundHandler != null) {
|
||||
if (RecipeCrafter.soundHandler != null && canPlaySound()) {
|
||||
RecipeCrafter.soundHandler.playSound(false, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaySound() {
|
||||
return !isMuffled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,19 @@ public interface BlockProcessable extends IUpgradeHandler, RedstoneConfigurable,
|
|||
*/
|
||||
boolean consumeEnergy(int amount);
|
||||
|
||||
|
||||
/**
|
||||
* <b>Play a sound to the Minecraft world</b>
|
||||
*
|
||||
* @see #canPlaySound()
|
||||
*/
|
||||
void playSound();
|
||||
|
||||
/**
|
||||
* <b>If a sound can be played.</b>
|
||||
*
|
||||
* @see #playSound()
|
||||
*/
|
||||
default boolean canPlaySound() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1496,6 +1496,9 @@ public class TRContent {
|
|||
if (aesu != null) {
|
||||
aesu.superconductors += TechRebornConfig.superConductorCount;
|
||||
}
|
||||
}),
|
||||
MUFFLER((blockEntity, handler, stack) -> {
|
||||
blockEntity.muffle();
|
||||
});
|
||||
|
||||
public String name;
|
||||
|
|
|
@ -699,6 +699,7 @@
|
|||
"item.techreborn.transformer_upgrade": "Transformer Upgrade",
|
||||
"item.techreborn.energy_storage_upgrade": "Energy Storage Upgrade",
|
||||
"item.techreborn.superconductor_upgrade": "Superconductor Upgrade",
|
||||
"item.techreborn.muffler_upgrade": "Muffler Upgrade",
|
||||
|
||||
"item.techreborn.bronze_sword": "Bronze Sword",
|
||||
"item.techreborn.bronze_pickaxe": "Bronze Pickaxe",
|
||||
|
@ -768,6 +769,7 @@
|
|||
"techreborn.message.info.item.techreborn.transformer_upgrade": "Increase energy tier",
|
||||
"techreborn.message.info.item.techreborn.energy_storage_upgrade": "Increase energy store",
|
||||
"techreborn.message.info.item.techreborn.superconductor_upgrade": "Increases energy flow rate",
|
||||
"techreborn.message.info.item.techreborn.muffler_upgrade": "Muffles the machine",
|
||||
|
||||
"techreborn.message.info.unplaceable_fluid": "Cannot be placed",
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "techreborn:item/upgrade/muffler_upgrade"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 579 B |
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"techreborn:crafting_table/upgrade/muffler_upgrade"
|
||||
]
|
||||
},
|
||||
"criteria": {
|
||||
"has_electronic_circuit": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": ["techreborn:electronic_circuit"]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"trigger": "minecraft:recipe_unlocked",
|
||||
"conditions": {
|
||||
"recipe": "techreborn:crafting_table/upgrade/muffler_upgrade"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_electronic_circuit",
|
||||
"has_the_recipe"
|
||||
]
|
||||
]
|
||||
}
|
|
@ -51,9 +51,19 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"muffler": {
|
||||
"trigger": "minecraft:inventory_changed",
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": ["techreborn:muffler_upgrade"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
["overclocker", "transformer","energystorage","superconductor"]
|
||||
["overclocker", "transformer","energystorage","superconductor","muffler"]
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
" W ",
|
||||
"WCW",
|
||||
" W "
|
||||
],
|
||||
"key": {
|
||||
"C": {
|
||||
"item": "techreborn:electronic_circuit"
|
||||
},
|
||||
"W": {
|
||||
"tag": "minecraft:wool"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:muffler_upgrade"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue